-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtaskfile.yml
More file actions
113 lines (102 loc) · 2.48 KB
/
Copy pathtaskfile.yml
File metadata and controls
113 lines (102 loc) · 2.48 KB
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
#https://taskfile.dev/
version: "3"
vars:
BETTERALIGN: github.com/dkorunic/betteralign/cmd/betteralign@v0.11.0
STATICCHECK: honnef.co/go/tools/cmd/staticcheck@v0.7.0
GOFUMPT: mvdan.cc/gofumpt@v0.10.0
REVIVE: github.com/mgechev/revive@v1.15.0
GOTESTSUM: gotest.tools/gotestsum@v1.13.0
env:
TMP: tmp
dotenv:
- .env
tasks:
ci:
desc: "run all checks"
cmds:
- task: tidy
- task: format
- task: lint
- task: test
test:
desc: "run Go tests"
vars:
PKG: '{{default "./..." .PKG}}'
FORMAT: '{{default "testdox" .FORMAT}}'
GOTESTSUM_BIN:
sh: go run . {{.GOTESTSUM}}
cmds:
- |
{{.GOTESTSUM_BIN}} \
--format-icons=hivis \
--format={{.FORMAT}} \
--format-hide-empty-pkg \
-- {{if .COUNT}}-count={{.COUNT}}{{end}} \
-v \
-coverprofile=coverage.out \
{{.PKG}}
- go tool cover -func=coverage.out
- defer: rm -f coverage.out
tidy:
desc: "run Go mod tidy"
cmds:
- go mod tidy
lint:
desc: "run Go linters"
deps:
- task: check-go-tools
vars:
TOOLS: [BETTERALIGN, REVIVE, STATICCHECK]
vars:
REVIVE_BIN:
sh: go run . {{.REVIVE}}
STATICCHECK_BIN:
sh: go run . {{.STATICCHECK}}
BETTERALIGN_BIN:
sh: go run . {{.BETTERALIGN}}
cmds:
- "{{.REVIVE_BIN}} -formatter friendly -set_exit_status ./..."
- "{{.STATICCHECK_BIN}} ./..."
- "{{.BETTERALIGN_BIN}} ./..."
format:
desc: "format the code"
deps:
- task: check-go-tools
vars:
TOOLS: [BETTERALIGN, GOFUMPT]
vars:
BETTERALIGN_BIN:
sh: go run . {{.BETTERALIGN}}
GOFUMPT_BIN:
sh: go run . {{.GOFUMPT}}
cmds:
- go fix ./...
- "{{.BETTERALIGN_BIN}} -apply ./... || true"
- "{{.GOFUMPT_BIN}} -l -w ."
govulncheck:
deps:
- task: check-go-tool
vars:
TOOL: GOVULNCHECK
vars:
GOVULNCHECK_BIN:
sh: go run . {{.GOVULNCHECK}}
cmds:
- "{{.GOVULNCHECK_BIN}} -show verbose ./..."
# Internal tasks
check-go-tool:
desc: 'ensure go tool is installed/available'
silent: true
internal: true
cmds:
- go run . '{{ index . .TOOL }}' >/dev/null
check-go-tools:
desc: 'ensure all go tools are installed'
silent: true
internal: true
cmds:
- for:
var: TOOLS
task: check-go-tool
vars:
TOOL: '{{.ITEM}}'