-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTaskfile.yaml
More file actions
244 lines (202 loc) · 5.61 KB
/
Taskfile.yaml
File metadata and controls
244 lines (202 loc) · 5.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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
version: "3"
vars:
GO_FILES_CMD: >-
go list -f {{"{{.Dir}}"}} ./... | xargs -I {} find {} -name "*.go"
PRETTIER_TARGETS: "*.{yaml,md,json} **/*.{yaml,md,json}"
env:
HOSTNAME:
sh: hostname
tasks:
default:
cmds:
- task: format
- task: lint
- task: test
- task: build
format:
desc: Runs all format targets
deps: [go-format, prettier-format]
lint:
desc: Runs all lint targets
deps:
- go-lint
- renovate-lint
- actions-lint
- goreleaser-lint
- prettier-lint
test:
desc: Runs all test targets
deps: [go-test]
pre-commit:
desc: Runs all pre-commit targets
deps: [lint, test]
build:
desc: Runs all build targets
deps: [go-build]
release:
desc: Runs all release targets
deps: [go-release]
dev-install:
desc: Installs development dependencies
cmds:
- devbox install
- nix-collect-garbage
install:
desc: Builds and installs binaries
cmds:
- goreleaser build --snapshot --clean --single-target
go-format:
desc: Formats Go code including imports
cmds:
- golangci-lint run --fix
go-lint:
desc: Lints Go code
cmds:
- golangci-lint run
go-test:
desc: Run Go tests
summary: |
Run Go tests
Args:
PKG: Go package to test (default: ./...)
FLAGS: Additional flags to pass to `go test` (default: "")
PKG_FLAGS: Additional flags to pass to test packages (default: "")
vars:
PKG: '{{.PKG | default "./..."}}'
FLAGS: '{{.FLAGS | default ""}}'
PKG_FLAGS: '{{.PKG_FLAGS | default ""}}'
cmds:
- go test {{.FLAGS}} {{.PKG}} {{.PKG_FLAGS}}
go-cover:
desc: Runs Go tests with coverage
cmds:
- go install gotest.tools/gotestsum@latest
- cmd: mkdir -p .test/
silent: true
- gotestsum --junitfile=.test/junit.xml --format=pkgname -- -race -vet=all -coverprofile=.test/cover.out ./...
go-bench:
desc: Run Go benchmarks
summary: |
Run Go benchmarks
Args:
PKG: Go package to test (default: ./...)
FLAGS: Additional flags to pass to `go test` (default: "")
Examples:
task go-bench PKG=./pkg/helm FLAGS="-cpuprofile profile.out -run=^\$"
vars:
PKG: '{{.PKG | default "./..."}}'
FLAGS: '{{.FLAGS | default ""}}'
cmds:
- go test -bench=. -benchmem -tags={{.BUILD_TAGS}} {{.FLAGS}} {{.PKG}}
go-gen:
desc: Generates Go code
cmds:
- go generate ./...
go-build:
desc: Builds Go binaries
vars:
FLAGS: '{{.FLAGS | default "--skip=docker,homebrew,nix,sign"}}'
cmds:
- goreleaser release --snapshot --clean {{ .FLAGS }}
go-build-images:
desc: Builds Go binaries and Docker images
vars:
FLAGS: '{{.FLAGS | default "--skip=homebrew,nix,sign"}}'
cmds:
- goreleaser release --snapshot --clean {{ .FLAGS }}
go-release:
desc: Releases Go binaries
vars:
FLAGS: '{{.FLAGS | default ""}}'
cmds:
- goreleaser release --clean {{.FLAGS}}
prettier-format:
desc: Formats YAML, JSON, and Markdown files
cmds:
- prettier --config ./.prettierrc.yaml -w {{.PRETTIER_TARGETS}}
prettier-lint:
desc: Lints YAML, JSON, and Markdown files
cmds:
- prettier --config ./.prettierrc.yaml --check {{.PRETTIER_TARGETS}}
go-deadcode:
desc: Finds dead code in Go
summary: |
Finds dead code in Go.
Args:
PKG: Go package(s) to evaluate (default: ./...)
FLAGS: Additional flags to pass to `deadcode` (default: "")
Examples:
task go-deadcode FLAGS="-test -generated"
vars:
PKG: '{{.PKG | default "./..."}}'
FLAGS: '{{.FLAGS | default ""}}'
cmds:
- go install golang.org/x/tools/cmd/deadcode@latest
- deadcode {{.FLAGS}} {{.PKG}}
renovate-lint:
desc: Lints Renovate configuration
cmds:
- renovate-config-validator .github/renovate.json5
actions-lint:
desc: Lints GitHub Actions
cmds:
- zizmor .github/workflows --config .github/zizmor.yaml
goreleaser-lint:
desc: Lints GoReleaser configuration
cmds:
- goreleaser check
install-hooks:
desc: Install git hooks
vars:
PRE_COMMIT_FILE: "{{.ROOT_DIR}}/.git/hooks/pre-commit"
COMMIT_MSG_FILE: "{{.ROOT_DIR}}/.git/hooks/commit-msg"
env:
PRE_COMMIT: |-
#!/bin/bash
git stash --keep-index --include-untracked --quiet
exitCode=0
devbox run -- task {{.TASK}} || exitCode=$?
devbox run -- task pre-commit || exitCode=$?
if [ $exitCode -eq 0 ]; then
git add .
else
git stash --keep-index --include-untracked --quiet && git stash drop --quiet
fi
git stash pop --quiet
exit $exitCode
COMMIT_MSG: |-
#!/bin/bash
devbox run -- conform enforce --commit-msg-file $1
cmds:
- echo "${PRE_COMMIT}" > {{.PRE_COMMIT_FILE}}
- chmod u+x {{.PRE_COMMIT_FILE}}
- echo "${COMMIT_MSG}" > {{.COMMIT_MSG_FILE}}
- chmod u+x {{.COMMIT_MSG_FILE}}
e2e-test:
internal: true
requires:
vars: [TEST]
cmds:
- vhs e2e/tapes/{{.TEST}}.tape -q
e2e-all:
internal: true
requires:
vars: [TESTS]
cmds:
- for:
var: TESTS
task: e2e-test
vars:
TEST: "{{.ITEM}}"
e2e:
desc: Runs all end-to-end tests
vars:
TESTS:
sh: cd e2e/tapes && ls *.tape | sed 's/\.tape//'
cmds:
- go build -o kat cmd/kat/main.go
- defer: rm -f kat
- task: e2e-all
vars:
TESTS: "{{.TESTS}}"
- git diff --exit-code e2e/golden