-
Notifications
You must be signed in to change notification settings - Fork 74
Expand file tree
/
Copy pathTaskfile.dist.yml
More file actions
283 lines (252 loc) · 7.64 KB
/
Taskfile.dist.yml
File metadata and controls
283 lines (252 loc) · 7.64 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
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
version: '3'
includes:
internal:
taskfile: ./TaskInternal.yml
internal: true
vars:
CHANGELOG_FILE: CHANGELOG.md
CHANGELOG_BACKUP: CHANGELOG.md.bak
VERSION_PATTERN: '^[0-9]+\.[0-9]+\.[0-9]+(-.*)?$'
env:
PROVIDER_AIVEN_ENABLE_BETA: true
tasks:
default:
desc: Lists available tasks defined in this file
silent: true
cmds:
- task --list
#################################################
# Build Tasks
#################################################
build:
desc: Build the provider binary
env:
PROVIDER_AIVEN_ENABLE_BETA: false
cmds:
- "{{.GO_CMD}} build"
build-dev:
desc: Build the development version for local Terraform testing
cmds:
- mkdir -p {{.BUILD_DEV_DIR}}
- "{{.GO_CMD}} build -gcflags='all=-N -l' -o {{.BUILD_DEV_BIN}}"
sources:
- "**/*.go"
generates:
- "{{.BUILD_DEV_BIN}}"
#################################################
# Test Tasks
#################################################
test:
desc: Run all tests (unit, acceptance, examples)
deps:
- test-unit
- test-acc
- test-examples
test-unit:
desc: Run unit tests
aliases:
- unit
env:
TF_ACC: 0
cmds:
- env -u AIVEN_TOKEN
{{.TESTSUM}}
--format pkgname
--hide-summary=skipped
--
-json ./...
-cover
-timeout=120s
test-acc:
desc: "Run acceptance tests (e.g., task test-acc -- -run TestAccResourceMyThing)"
env:
TF_ACC: 1
vars:
EFFECTIVE_PKG_PATH: '{{env "PKG_PATH" | default .PKG_PATH}}'
TAGS: '{{.TAGS | default (env "GO_BUILD_TAGS")}}'
TAGS_FLAG: '{{if .TAGS}}-tags={{.TAGS}}{{end}}'
cmds:
- cmd: "{{.GO_CMD}} test ./{{.EFFECTIVE_PKG_PATH}}/... {{.TAGS_FLAG}} -v -count {{.TEST_COUNT}} -parallel {{.ACC_TEST_PARALLELISM}} {{.CLI_ARGS}} -timeout {{.ACC_TEST_TIMEOUT}}"
test-examples:
desc: "Run examples tests (e.g., task test-examples -- -run TestAccExampleMyThing)"
deps:
- build-dev
- internal:clean-examples
env:
AIVEN_PROVIDER_PATH: "{{.BUILD_DEV_DIR}}"
cmds:
- "{{.TESTSUM}}
--format testname
--hide-summary=skipped
--
--tags=examples
-json ./examples_tests/...
-v
-count {{.TEST_COUNT}}
-parallel {{.ACC_TEST_PARALLELISM}}
-timeout {{.ACC_TEST_TIMEOUT}}
{{.CLI_ARGS}}"
test-backward:
desc: Run backward compatibility tests
cmds:
- task: test-acc
vars:
TAGS: backwardcompat
#################################################
# Code Style Tasks
#################################################
lint:
desc: Run all linters (Go, Tests, Docs, Semgrep)
deps:
- internal:lint-go
- internal:lint-test
- internal:lint-docs
- internal:semgrep
fmt:
desc: "Run all formatters (Go, Terraform, whitespace). Use FAST_FORMAT=true for quick formatting"
vars:
FAST_FORMAT: '{{default "false" .FAST_FORMAT}}'
cmds:
- defer:
task: internal:fmt-imports
- task: internal:fmt-go
- task: internal:fmt-test
- task: internal:fmt-changelog
- task: '{{if ne .FAST_FORMAT "true"}}internal:fmt-precommit{{else}}internal:fmt-fast{{end}}'
#################################################
# Utility Tasks
#################################################
generate:
desc: Generate Go code, documentation, and mocks
vars:
no_spec: '{{.no_spec | default "false"}}'
cmds:
- defer:
task: fmt
vars:
FAST_FORMAT: true
- task: internal:generate
vars:
no_spec: '{{.no_spec}}'
docs:
desc: Generate documentation for the provider
cmds:
- defer:
task: fmt
- task: internal:gen-docs
update-schemas:
desc: "Update Go client codegen and API schemas, regenerate mocks, and update CHANGELOG.md"
cmds:
- defer:
task: fmt
- task: internal:dump-schemas
- task: internal:load-schemas
- task: internal:generate
- task: internal:diff-schemas
update-client:
desc: "Update Go client codegen"
aliases:
- client
cmds:
- task: internal:load-codegen
- task: internal:dump-mockery
sweep:
desc: "Run resource sweepers (WARNING: Destroys infrastructure!)."
prompt: This will destroy infrastructure. Use only in development accounts. Do you want to continue?
env:
TF_SWEEP: 1
cmds:
- "{{.GO_CMD}} test ./internal/sweep -v -sweep={{.SWEEP}} {{.CLI_ARGS}} -timeout 15m"
debug:
desc: Run the development build in debug mode
deps:
- build-dev
cmds:
- "{{.BUILD_DEV_BIN}} -debug"
#################################################
# OPA Tasks
#################################################
opa:test:
desc: Run OPA policy tests
deps:
- internal:opa:verify
cmds:
- "{{.OPA}} test ./opa/policies"
opa:bundle:
desc: "Build OPA bundle for distribution"
deps:
- opa:test
vars:
VERSION: '{{.VERSION | default "dev"}}'
BUNDLE_NAME: "aiven-terraform-provider-policies"
OUTPUT_FILE: "./opa/dist/{{.BUNDLE_NAME}}-{{.VERSION}}.tar.gz"
cmds:
- task: opa:fmt
- mkdir -p opa/dist
- |
{{.OPA}} build --bundle ./opa/policies \
--output {{.OUTPUT_FILE}} \
--revision {{.VERSION}} \
--ignore "*_test.rego"
opa:fmt:
desc: "Format OPA policy files"
preconditions:
- sh: command -v {{.OPA}} >/dev/null 2>&1
msg: "OPA is not installed. Please run install it manually."
cmds:
- "{{.OPA}} fmt --write ./opa/policies"
#################################################
# CI Tasks
#################################################
ci:selproj:
desc: "Run selproj tool change detection"
cmds:
- "{{.SELPROJ}}"
ci:sweep-check:
desc: "Run sweeper test checks (TestCheckSweepers) without deleting resources"
cmds:
- task: internal:sweep-check
ci:docs:
desc: "Generate Terraform provider documentation (only for CI usage, does not run fmt afterwards)"
cmds:
- task: internal:gen-docs
ci:discover-test-matrix:
desc: "Finds Go tests, partitions them into normal/slow via SLOW_TESTS_CSV, and generates a JSON matrix for CI. Usage: task ci:discover-test-matrix SLOW_TESTS_CSV=slow_test1,slow_test2"
vars:
SLOW_TESTS_CSV: '{{.SLOW_TESTS_CSV | default "sdk-service-vpc"}}'
cmds:
- task: internal:discover-test-matrix
vars:
SLOW_TESTS_CSV: '{{.SLOW_TESTS_CSV}}'
ci:changelog-update:
desc: Update CHANGELOG.md with new version entry
vars:
VERSION: '{{.VERSION}}'
DATE: '{{.DATE | default ""}}'
preconditions:
- sh: test -f "{{.CHANGELOG_FILE}}"
msg: "{{.CHANGELOG_FILE}} not found"
- sh: test -n "{{.VERSION}}"
msg: "VERSION is required"
cmds:
- "{{.GO_CMD}} run ./tools changelog update {{.VERSION}} --date '{{.DATE}}'"
ci:changelog-extract:
desc: Extract changelog content for a specific version
silent: true
vars:
VERSION: '{{.VERSION | default "0.0.0"}}'
preconditions:
- sh: test -f "{{.CHANGELOG_FILE}}"
msg: "{{.CHANGELOG_FILE}} not found"
- sh: test -n "{{.VERSION}}"
msg: "VERSION is required"
cmds:
- "{{.GO_CMD}} run ./tools/main.go changelog extract {{.VERSION}}"
ci:verify-version:
desc: "Verifies the new version doesn't exist and is a sequential bump. Usage: task ci:verify-version VERSION=x.y.z"
cmds:
- task: internal:verify-version
vars:
VERSION: '{{.VERSION}}'
requires:
vars: [VERSION]