-
Notifications
You must be signed in to change notification settings - Fork 1
/
Taskfile.yaml
77 lines (75 loc) · 2.71 KB
/
Taskfile.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# https://taskfile.dev
version: '3'
tasks:
build:
cmds:
- go build bin/dmscore/dmscore.go && rm ./dmscore
build-and-run-tests:
desc: Smoke test (for compilation) to build the binary and run the tests
cmds:
- task: build
- task: run-tests
install-schema-generate:
desc: Installs the schema-generate tool
cmds:
- go install github.com/everactive/generate/[email protected]
install-mockery:
desc: Installs the mockery mock generating tool
cmds:
- go install github.com/vektra/mockery/[email protected]
test-prep:
cmds:
- task: update-mocks
- task: generate-message-structs
run-tests:
desc: Runs the unit tests, making sure everything is setup
cmds:
- task: test-prep
- go test ./...
update-mocks:
desc: Update mocks used by unit tests
cmds:
- mockery --dir iot-management/service/manage --all --inpackage
- mockery --dir iot-management/datastore --all --inpackage
- mockery --dir iot-identity/datastore --all --inpackage
- mockery --dir iot-devicetwin/datastore --all --inpackage
- mockery --dir iot-devicetwin/service/controller --all --inpackage
- mockery --dir iot-devicetwin/service/devicetwin --all --inpackage
- mockery --dir iot-devicetwin/service/mqtt --all --inpackage
- mockery --dir pkg/datastores --all --inpackage
- mockery --all --dir $(go env GOPATH)/pkg/mod/github.com/eclipse/[email protected] --output mocks/external/mqtt
generate-message-structs:
desc: This will generate the Go structs from the schema definitions
cmds:
- mkdir -p pkg/messages
- schema-generate -o pkg/messages/messages.go -p messages ./dms-schemas/schemas.json
- schema-generate -o pkg/messages/rest.go -p messages ./dms-schemas/rest_schemas.json
create-migration:
desc: Creates a dmscore database migration (this is for the primary "management" database)
cmds:
- |
if [ -z "${MIGRATION_NAME}" ]; then
echo "Need MIGRATION_NAME"
exit 1
fi
migrate create -ext sql -dir db/migrations $MIGRATION_NAME
test-race:
desc: Run race detection tests
cmds:
- task: test-prep
- rm -rf current
- mkdir -p current
- go test -count=1 -p 1 ./... -race
coverage:
desc: Generate a test coverage report
cmds:
- task: test-prep
- rm -rf current
- mkdir -p current
- go test -coverprofile coverage_report $(go list ./... | grep -v "vendor")
- |
while read p; do
grep -v "${p}" ./coverage_report > ./coverage_report_tmp
mv ./coverage_report_tmp ./coverage_report
done <./exclude-from-code-coverage.txt
- go tool cover -func=coverage_report