-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtaskfile.yml
More file actions
130 lines (114 loc) · 3.03 KB
/
Copy pathtaskfile.yml
File metadata and controls
130 lines (114 loc) · 3.03 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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#https://taskfile.dev/
version: "3"
vars:
BETTERALIGN: github.com/dkorunic/betteralign/cmd/betteralign@v0.13.0
STATICCHECK: honnef.co/go/tools/cmd/staticcheck@v0.7.0
GOVULNCHECK: golang.org/x/vuln/cmd/govulncheck@v1.5.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:
check-commit:
desc: "check if the commit message follows the conventional commit format"
cmds:
# go run skips VCS version stamping, so build first
- go build -o check-commit .
- ./check-commit
ci:
desc: "do almost all the checks"
cmds:
- task: tidy
- task: format
- task: lint
- task: test
test:
desc: "run Go tests"
deps:
- task: check-go-tool
vars:
TOOL: GOTESTSUM
vars:
PKG: '{{default "./..." .PKG}}'
FORMAT: '{{default "testdox" .FORMAT}}'
cmds:
- |
$(check-go-tool {{.GOTESTSUM}}) \
--format-icons=hivis \
--format={{.FORMAT}} \
--format-hide-empty-pkg \
-- {{if .COUNT}}-count={{.COUNT}}{{end}} \
-v \
{{.PKG}}
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]
cmds:
- "$(check-go-tool {{.REVIVE}}) -config revive.toml -formatter friendly -set_exit_status ./..."
- "$(check-go-tool {{.STATICCHECK}}) ./..."
- "$(check-go-tool {{.BETTERALIGN}}) ./..."
format:
desc: "formats the code"
deps:
- task: check-go-tools
vars:
TOOLS: [BETTERALIGN, GOFUMPT]
cmds:
- go fix ./...
- "$(check-go-tool {{.BETTERALIGN}}) -apply ./... || true"
- "$(check-go-tool {{.GOFUMPT}}) -l -w ."
govulncheck:
desc: "run Go vulnerability check"
deps:
- task: check-go-tool
vars:
TOOL: GOVULNCHECK
cmds:
- "$(check-go-tool {{.GOVULNCHECK}}) -show verbose ./..."
update-x:
desc: 'update golang.org/x/ dependencies'
cmds:
- go get -u golang.org/x/...
- task: tidy
update-deps:
desc: 'update direct dependencies to latest versions'
cmds:
- go get $(go list -m -f '{{`{{if and (not .Indirect) (not .Main)}}{{.Path}}{{end}}`}}' all)
- task: tidy
# internal
ensure-check-go-tool:
desc: 'ensure check-go-tool is installed'
silent: true
internal: true
status:
- command -v check-go-tool
cmds:
- go install github.com/oktalz/check-go-tool@latest
check-go-tool:
desc: 'ensure go tool is installed/available'
silent: true
internal: true
deps:
- task: ensure-check-go-tool
cmds:
- check-go-tool '{{ 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}}'