-
Notifications
You must be signed in to change notification settings - Fork 0
/
Taskfile.yml
114 lines (96 loc) · 2.8 KB
/
Taskfile.yml
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
---
version: "3"
vars:
GIT_ROOT:
sh: git rev-parse --show-toplevel
MAIN_PACKAGE: main.go
includes:
docs:
taskfile: ./docs
dir: ./docs
tasks:
deps:
desc: Install dependencies
cmds:
- go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
- go install github.com/princjef/gomarkdoc/cmd/gomarkdoc@latest
- go install golang.org/x/vuln/cmd/govulncheck@latest
- go install github.com/jstemmer/go-junit-report@latest
- go install github.com/segmentio/golines@latest
- go install github.com/golang/mock/mockgen@latest
- go install github.com/boumenot/gocover-cobertura@latest
- go install mvdan.cc/gofumpt@latest
deps:check:
desc: Check dependencies needed for development
cmds:
- echo "Dependency check OK"
preconditions:
- sh: "[ '{{OS}}' = 'darwin' ]"
msg: Operating System '{{OS}}' not supported
- sh: command -v jq
msg: |
'jq' not found in $PATH
Suggested action: 'brew install jq'
mod:
desc: Module maintenance
cmds:
- go mod download
- go mod tidy
vet:
desc: Report likely mistakes in packages
cmds:
- $(go env GOPATH)/bin/golangci-lint run --config {{ .GIT_ROOT }}/.golangci.yml
vuln:
desc: Run Go's vulnerability scanner
cmds:
- govulncheck ./...
run:
desc: Compile and run Go program
cmds:
- go run {{ .MAIN_PACKAGE }} {{.CLI_ARGS}}
unit:
desc: Test packages
cmds:
- go test -parallel 5 -race -v ./...
unit:int:
desc: Integration test packages
cmds:
-
test:
desc: Test all
cmds:
- task: deps
- task: mod
- task: fmt:check
- task: vet
- task: cov
- task: unit:int
cov:
desc: Generate coverage
env:
# https://github.com/golang/go/issues/65570
GOEXPERIMENT: nocoverageredesign
cmds:
- go test -race -coverprofile=cover.out -v $(go list ./... | grep -v /mocks) 2>&1 | go-junit-report --set-exit-code > result.xml || (cat result.xml && echo "fail" && exit 1)
- gocover-cobertura < cover.out > cobertura.xml
- go tool cover -func=cover.out
cov:map:
desc: Generate coverage and show heatmap
cmds:
- task: cov
- go tool cover -html=cover.out
fmt:
desc: Reformat files whose formatting differs from `go_fmt_command`
cmds:
- gofumpt -l -w .
- golines --base-formatter=gofumpt -w .
fmt:check:
desc: Check files whose formatting differs from `go_fmt_command`
cmds:
# https://github.com/mvdan/gofumpt/issues/114
- test -z "$(gofumpt -d -e . | tee /dev/stderr)"
- test -z "$(golines -l --dry-run --base-formatter=gofumpt -w .)"
build:
desc: Build ARCH compatible binary.
cmds:
- goreleaser release --snapshot --clean