Skip to content

Commit

Permalink
chore: update to sage
Browse files Browse the repository at this point in the history
  • Loading branch information
mlveggo committed Jun 16, 2022
1 parent 2796be0 commit a8e54a6
Show file tree
Hide file tree
Showing 24 changed files with 253 additions and 260 deletions.
5 changes: 5 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,8 @@ updates:
schedule:
interval: "weekly"
day: "monday"

- package-ecosystem: gomod
directory: .sage
schedule:
interval: weekly
20 changes: 10 additions & 10 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
name: CI
name: ci

on:
push:
branches:
- master
pull_request:
branches:
- "*"
types: [opened, reopened, synchronize]

env:
GOPRIVATE: github.com/einride/*

jobs:
make:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/[email protected]

- name: Setup Go
uses: actions/[email protected]
steps:
- name: Setup Sage
uses: einride/sage/actions/setup@master
with:
go-version: ^1.17
go-version: 1.18

- name: Make
run: make
25 changes: 25 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Release

on:
push:
branches: [master]

permissions: write-all

jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Setup Sage
uses: einride/sage/actions/setup@master
with:
go-version: 1.18

- name: Make
run: make

- name: Release
uses: go-semantic-release/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
allow-initial-development-versions: true
30 changes: 0 additions & 30 deletions .golangci.yml

This file was deleted.

5 changes: 5 additions & 0 deletions .sage/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module sage

go 1.18

require go.einride.tech/sage v0.116.0
2 changes: 2 additions & 0 deletions .sage/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
go.einride.tech/sage v0.116.0 h1:Z1ru00FnZ5ew4Wyni9tfbbcerzgZJ2nQa9n4Y01Uj88=
go.einride.tech/sage v0.116.0/go.mod h1:EzV5uciFX7/2ho8EKB5K9JghOfXIxlzs694b+Tkl5GQ=
82 changes: 82 additions & 0 deletions .sage/sagefile.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
package main

import (
"context"

"go.einride.tech/sage/sg"
"go.einride.tech/sage/sgtool"
"go.einride.tech/sage/tools/sgconvco"
"go.einride.tech/sage/tools/sggit"
"go.einride.tech/sage/tools/sggo"
"go.einride.tech/sage/tools/sggolangcilint"
"go.einride.tech/sage/tools/sggoreview"
"go.einride.tech/sage/tools/sgmarkdownfmt"
"go.einride.tech/sage/tools/sgyamlfmt"
)

func main() {
sg.GenerateMakefiles(
sg.Makefile{
Path: sg.FromGitRoot("Makefile"),
DefaultTarget: All,
},
)
}

func All(ctx context.Context) error {
sg.Deps(ctx, ConvcoCheck, GoGenerate, GoLint, GoReview, GoTest, FormatMarkdown, FormatYAML)
sg.SerialDeps(ctx, GoModTidy, GitVerifyNoDiff)
return nil
}

func FormatYAML(ctx context.Context) error {
sg.Logger(ctx).Println("formatting YAML files...")
return sgyamlfmt.Command(ctx, "-d", sg.FromGitRoot(), "-r").Run()
}

func GoModTidy(ctx context.Context) error {
sg.Logger(ctx).Println("tidying Go module files...")
return sg.Command(ctx, "go", "mod", "tidy", "-v").Run()
}

func GoTest(ctx context.Context) error {
sg.Logger(ctx).Println("running Go tests...")
return sggo.TestCommand(ctx).Run()
}

func GoReview(ctx context.Context) error {
sg.Logger(ctx).Println("reviewing Go files...")
return sggoreview.Command(ctx, "-c", "1", "./...").Run()
}

func GoLint(ctx context.Context) error {
sg.Logger(ctx).Println("linting Go files...")
return sggolangcilint.Run(ctx)
}

func FormatMarkdown(ctx context.Context) error {
sg.Logger(ctx).Println("formatting Markdown files...")
return sgmarkdownfmt.Command(ctx, "-w", ".").Run()
}

func ConvcoCheck(ctx context.Context) error {
sg.Logger(ctx).Println("checking git commits...")
return sgconvco.Command(ctx, "check", "origin/master..HEAD").Run()
}

func GitVerifyNoDiff(ctx context.Context) error {
sg.Logger(ctx).Println("verifying that git has no diff...")
return sggit.VerifyNoDiff(ctx)
}

func Stringer(ctx context.Context) error {
sg.Logger(ctx).Println("building...")
_, err := sgtool.GoInstall(ctx, "golang.org/x/tools/cmd/stringer", "v0.1.10")
return err
}

func GoGenerate(ctx context.Context) error {
sg.Deps(ctx, Stringer)
sg.Logger(ctx).Println("generating Go code...")
return sg.Command(ctx, "go", "generate", "./...").Run()
}
116 changes: 57 additions & 59 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,68 +1,66 @@
export GO111MODULE := on
export GOPRIVATE := github.com/mlveggo/*
# Code generated by go.einride.tech/sage. DO NOT EDIT.
# To learn more, see .sage/sagefile.go and https://github.com/einride/sage.

.DEFAULT_GOAL := all

sagefile := .sage/bin/sagefile

$(sagefile): .sage/go.mod .sage/*.go
@cd .sage && go mod tidy && go run .

.PHONY: sage
sage:
@git clean -fxq $(sagefile)
@$(MAKE) $(sagefile)

.PHONY: update-sage
update-sage:
@cd .sage && go get -d go.einride.tech/sage@latest && go mod tidy && go run .

.PHONY: clean-sage
clean-sage:
@git clean -fdx .sage/tools .sage/bin .sage/build

.PHONY: all
all: \
go-generate \
go-fmt \
go-mod-tidy \
go-vet \
go-review \
go-lint \
go-test \

include tools/golangci-lint/rules.mk
include tools/goreview/rules.mk
include tools/stringer/rules.mk

.PHONY: clean
clean:
rm -rf build
all: $(sagefile)
@$(sagefile) All

.PHONY: go-mod-tidy
go-mod-tidy:
go mod tidy -v
.PHONY: convco-check
convco-check: $(sagefile)
@$(sagefile) ConvcoCheck

.PHONY: go-fmt
go-fmt:
go fmt ./...
.PHONY: format-markdown
format-markdown: $(sagefile)
@$(sagefile) FormatMarkdown

.PHONY: go-vet
go-vet:
go vet ./...
.PHONY: format-yaml
format-yaml: $(sagefile)
@$(sagefile) FormatYAML

.PHONY: go-test
go-test:
go test -race -cover ./...
.PHONY: git-verify-no-diff
git-verify-no-diff: $(sagefile)
@$(sagefile) GitVerifyNoDiff

.PHONY: go-generate
go-generate: \
protocol_string.go \
commands_string.go \
parameters_string.go \
packet_string.go \
file_string.go \
pkg/packets/timecode_string.go \
pkg/packets/image_string.go

%_string.go: %.go $(stringer)
$(info generating $@...)
@go generate ./$<

.PHONY: go-build
go-build:
mkdir build
go build -o build ./...

.PHONY: run
run:
go run cmd/streaming/main.go

.PHONY: run-discover
run-discover:
go run cmd/discover/main.go

.PHONY: run-settings
run-settings:
go run cmd/settings/main.go
go-generate: $(sagefile)
@$(sagefile) GoGenerate

.PHONY: go-lint
go-lint: $(sagefile)
@$(sagefile) GoLint

.PHONY: go-mod-tidy
go-mod-tidy: $(sagefile)
@$(sagefile) GoModTidy

.PHONY: go-review
go-review: $(sagefile)
@$(sagefile) GoReview

.PHONY: go-test
go-test: $(sagefile)
@$(sagefile) GoTest

.PHONY: stringer
stringer: $(sagefile)
@$(sagefile) Stringer
21 changes: 14 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
# qualisys-go
Go sdk for Qualisys Track Manager streaming of motion capture data.
qualisys-go
===========

Go sdk for Qualisys Track Manager streaming of motion capture data.

Discovery example
-----------------

## Discovery example
```Go
package main

Expand All @@ -25,7 +29,10 @@ func main() {
}
```

## Issues
- It should always fail to connect to older QTM version (Support 1.22 and upwards)
- StreamFrames - Missing support for [:channels] handling.
- Makefile doesn't work on Windows (golangci-lint/goreview handling)
Issues
------

- It should always fail to connect to older QTM version (Support 1.22 and upwards)
- StreamFrames - Missing support for \[:channels] handling.
- Makefile doesn't work on Windows (golangci-lint/goreview handling)
- Support passing in an context.Context in NewProtocol()
2 changes: 1 addition & 1 deletion cmd/settings/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func main() {
break
}
}
rt := qualisys.NewRtProtocol(ip, basePort)
rt := qualisys.NewProtocol(ip, basePort)
log.Println("Connecting to:", ip)
if err := rt.Connect(); err != nil {
log.Println(err)
Expand Down
4 changes: 2 additions & 2 deletions cmd/streaming/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/mlveggo/qualisys-go/pkg/discover"
)

func HandlePackets(p *qualisys.RtPacket) {
func HandlePackets(p *qualisys.Packet) {
switch p.Type {
case qualisys.PacketTypeEvent:
log.Println("Event:", p.Event)
Expand Down Expand Up @@ -42,7 +42,7 @@ func main() {
ip = os.Args[1]
}
log.Println("Connecting to: ", ip)
rt := qualisys.NewRtProtocol(ip, basePort)
rt := qualisys.NewProtocol(ip, basePort)
parametersFetched := false
streaming := false
for {
Expand Down
Loading

0 comments on commit a8e54a6

Please sign in to comment.