-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtaskfile.yml
More file actions
116 lines (102 loc) · 2.61 KB
/
taskfile.yml
File metadata and controls
116 lines (102 loc) · 2.61 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
#https://taskfile.dev/
version: "3"
vars:
BETTERALIGN: github.com/dkorunic/betteralign/cmd/betteralign@v0.12.0
STATICCHECK: honnef.co/go/tools/cmd/staticcheck@v0.7.0
GOVULNCHECK: golang.org/x/vuln/cmd/govulncheck@v1.1.4
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 .
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 ./..."
# 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}}'