-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathTaskfile.yml
More file actions
385 lines (346 loc) · 13 KB
/
Copy pathTaskfile.yml
File metadata and controls
385 lines (346 loc) · 13 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
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
version: '3'
vars:
COMMAND_NAME: exasol
BINARY_SUFFIX:
sh: test "$(go env GOOS)" = "windows" && echo ".exe" || true
BINARY_NAME: "{{.COMMAND_NAME}}{{.BINARY_SUFFIX}}"
MAIN_PATH_REL: "./cmd/exasol"
BUILD_DIR_NAME: "bin"
ROOT_PATH: >-
{{- if eq OS "windows" }}
{{- .ROOT_DIR | replace "\\" "\\\\" }}
{{- else }}
{{- .ROOT_DIR }}
{{- end }}
SEP: '{{if eq OS "windows"}}\\{{else}}/{{end}}'
BUILD_DIR: '{{.ROOT_PATH}}{{.SEP}}{{.BUILD_DIR_NAME}}'
TESTS_DIR: '{{.ROOT_PATH}}{{.SEP}}tests'
includes:
github: ./tasks/github.Taskfile.yml
tasks:
default:
silent: true
cmds:
- "task --list"
generate:
desc: 'Run generation for all packages. TARGET_GOOS/TARGET_GOARCH: also stage a non-host platform''s embedded resources. SKIP_EMBED=true: never fetch real embedded resource data, just write empty placeholders (for lint/test builds that never look at the bytes).'
vars:
TARGET_GOOS: '{{default "" .TARGET_GOOS}}'
TARGET_GOARCH: '{{default "" .TARGET_GOARCH}}'
SKIP_EMBED: '{{default "" .SKIP_EMBED}}'
env:
GOFLAGS: '-tags=containers_image_openpgp'
cmds:
# unset GOOS/GOARCH: an inherited value would cross-compile the
# directives' own tool invocations instead of just running them
# ("exec format error"). TARGET_GOOS/TARGET_GOARCH/SKIP_EMBED carry
# the resourceembedder's own settings instead, without that side effect.
- >-
unset GOOS GOARCH;
TARGET_GOOS="{{.TARGET_GOOS}}" TARGET_GOARCH="{{.TARGET_GOARCH}}" SKIP_EMBED="{{.SKIP_EMBED}}"
go generate ./...
tofu-lock-update:
desc: Regenerate multi-platform .terraform.lock.hcl files (no temp files in assets)
deps:
- generate
cmds:
- >-
go run ./tools/lockfileupdate/main.go
-platform=linux_amd64
-platform=linux_arm64
-platform=windows_amd64
-platform=darwin_amd64
-platform=darwin_arm64
# Using relative paths to build because on Windows the .ROOT_DIR
# variable messes with path separators and results in incompatible
# with Windows path.
build:
desc: 'Build the binary. COVERAGE=true enables coverage instrumentation.'
# {{env "GOOS/GOARCH"}}: passes the ambient cross-compile target (if any)
# through to generate's TARGET_GOOS/TARGET_GOARCH, so its embedded
# resources are staged for that target rather than just the host.
deps:
- task: generate
vars:
TARGET_GOOS: '{{env "GOOS"}}'
TARGET_GOARCH: '{{env "GOARCH"}}'
vars:
DEBUG_BUILD: '{{default "false" .DEBUG_BUILD}}'
COVERAGE: '{{default "false" .COVERAGE}}'
env:
CGO_ENABLED: "0"
cmds:
- |
version=$(git describe --tags --abbrev=0) # First character is "v".
go build \
-tags=containers_image_openpgp \
-o {{.BUILD_DIR_NAME}}/{{.BINARY_NAME}} \
{{if eq .COVERAGE "true"}}-cover -covermode=atomic {{end}}\
{{if eq .DEBUG_BUILD "true"}}-gcflags="all=-N -l"{{else}}-trimpath \
-gcflags=all=-l{{end}} \
-ldflags "{{if ne .DEBUG_BUILD "true"}}-s -w {{end}}-X main.CurrentLauncherVersion=${version:1}" {{.MAIN_PATH_REL}}
build-windows:
desc: Cross-compile the Windows binary (defaults to GOARCH=amd64)
vars:
DEBUG_BUILD: '{{default "false" .DEBUG_BUILD}}'
TARGET_GOARCH: '{{default "amd64" .GOARCH}}'
OUTPUT_NAME: '{{.COMMAND_NAME}}.exe'
deps:
- task: generate
vars:
TARGET_GOOS: windows
TARGET_GOARCH: '{{default "amd64" .GOARCH}}'
env:
GOOS: windows
GOARCH: '{{.TARGET_GOARCH}}'
CGO_ENABLED: "0"
cmds:
- |
version=$(git describe --tags --abbrev=0) # First character is "v".
go build -tags=containers_image_openpgp -o {{.BUILD_DIR_NAME}}/{{.OUTPUT_NAME}} \
{{if eq .DEBUG_BUILD "true"}}-gcflags="all=-N -l"{{else}}-trimpath \
-gcflags=all=-l{{end}} \
-ldflags "{{if ne .DEBUG_BUILD "true"}}-s -w {{end}}-X main.CurrentLauncherVersion=${version:1}" {{.MAIN_PATH_REL}}
deps-update-golang:
desc: Update all Go dependencies
cmds:
- go get -u ./...
deps-update-python:
desc: Update all Python dependencies
dir: '{{.USER_WORKING_DIR}}/{{.TESTS_DIR}}'
cmds:
- poetry update
deps-update:
desc: Update all Go dependencies
deps:
- deps-update-golang
- deps-update-python
deps-install-poetry:
cmds:
- python3 -m pip install poetry
status:
- which poetry
tests-setup:
desc: Install required test tools
dir: '{{.TESTS_DIR}}'
cmds:
- poetry sync
status:
- poetry run ruff --version
- poetry run mypy --version
deps:
- deps-install-poetry
tests-unit:
desc: 'Run unit tests. TEST is a regex for `go test -run` (substring match, e.g. TEST=Ready). COVERAGE=true collects a coverage profile.'
deps:
- task: generate
vars:
SKIP_EMBED: "true"
vars:
TEST: '{{default "" .TEST}}'
COVERAGE: '{{default "false" .COVERAGE}}'
cmds:
- go test -v -tags=containers_image_openpgp -race{{if eq .COVERAGE "true"}} -coverprofile=coverage-unit.out -covermode=atomic{{end}}{{if .TEST}} -run "{{.TEST}}"{{end}} ./...
- '{{if eq .COVERAGE "true"}}go tool cover -func=coverage-unit.out{{end}}'
tests-unit-find:
desc: Find Go unit test names by wildcard on Linux (`task tests-unit-find TEST=*Ready*`)
platforms:
- linux
vars:
TEST: '{{default "*" .TEST}}'
cmds:
- |
go test -tags=containers_image_openpgp -json ./... | jq -r 'select(.Action=="run") | .Test'
tests-integration:
desc: 'Run integration tests. COVERAGE=true collects Go coverage from the exasol binary.'
deps: [tests-setup]
dir: '{{.TESTS_DIR}}'
vars:
COVERAGE: '{{default "false" .COVERAGE}}'
GOCOVERDIR_PATH: '{{.ROOT_PATH}}{{.SEP}}covdata-integration'
env:
GOCOVERDIR: '{{if eq .COVERAGE "true"}}{{.GOCOVERDIR_PATH}}{{end}}'
cmds:
- '{{if eq .COVERAGE "true"}}rm -rf {{.GOCOVERDIR_PATH}} && mkdir -p {{.GOCOVERDIR_PATH}}{{end}}'
- poetry run pytest -vv --exasol-path={{.BUILD_DIR}}{{.SEP}}{{.BINARY_NAME}} {{.TESTS_DIR}}{{.SEP}}tests{{.SEP}}integration
- '{{if eq .COVERAGE "true"}}go tool covdata textfmt -i={{.GOCOVERDIR_PATH}} -o={{.ROOT_PATH}}{{.SEP}}coverage-integration.out{{end}}'
tests-deployment:
desc: Run all cloud tests (deployment, e2e, chaos). Filter with `-k` via TEST, e.g. `task tests-deployment INFRA=aws TEST=test_stop_and_start`
deps: [tests-setup]
dir: '{{.TESTS_DIR}}'
vars:
INFRA: '{{default "aws" .INFRA}}'
TEST: '{{default "" .TEST}}'
STACKIT_PROJECT_ID: '{{default "" .STACKIT_PROJECT_ID}}'
GOCOVERDIR_PATH: '{{.ROOT_PATH}}{{.SEP}}covdata-deployment'
env:
# The exasol binary is always built with COVERAGE=true in CI; without
# GOCOVERDIR it prints a warning on every invocation that pollutes
# stdout and breaks tests asserting exact output.
GOCOVERDIR: '{{.GOCOVERDIR_PATH}}'
cmds:
- rm -rf {{.GOCOVERDIR_PATH}} && mkdir -p {{.GOCOVERDIR_PATH}}
- |
poetry run pytest -vv --exasol-path={{.BUILD_DIR}}{{.SEP}}{{.BINARY_NAME}} --infra={{.INFRA}} {{if .STACKIT_PROJECT_ID}}--stackit-project-id={{.STACKIT_PROJECT_ID}}{{end}} {{if .TEST}}-k "{{.TEST}}"{{end}} {{.TESTS_DIR}}{{.SEP}}tests{{.SEP}}deployment {{.TESTS_DIR}}{{.SEP}}tests{{.SEP}}e2e {{.TESTS_DIR}}{{.SEP}}tests{{.SEP}}chaos
tests-deployment-infrastructure:
desc: Run infrastructure-focused deployment tests
deps: [tests-setup]
dir: '{{.TESTS_DIR}}'
vars:
INFRA: '{{default "aws" .INFRA}}'
STACKIT_PROJECT_ID: '{{default "" .STACKIT_PROJECT_ID}}'
GOCOVERDIR_PATH: '{{.ROOT_PATH}}{{.SEP}}covdata-deployment'
env:
# See tests-deployment: avoids the GOCOVERDIR-not-set warning leaking into test output.
GOCOVERDIR: '{{.GOCOVERDIR_PATH}}'
cmds:
- rm -rf {{.GOCOVERDIR_PATH}} && mkdir -p {{.GOCOVERDIR_PATH}}
- |
poetry run pytest -vv --exasol-path={{.BUILD_DIR}}{{.SEP}}{{.BINARY_NAME}} --infra={{.INFRA}} {{if .STACKIT_PROJECT_ID}}--stackit-project-id={{.STACKIT_PROJECT_ID}}{{end}} -m "infrastructure_e2e" {{.TESTS_DIR}}{{.SEP}}tests{{.SEP}}deployment {{.TESTS_DIR}}{{.SEP}}tests{{.SEP}}e2e {{.TESTS_DIR}}{{.SEP}}tests{{.SEP}}chaos
tests-deployment-installation:
desc: Run installation-focused end-to-end tests
deps: [tests-setup]
dir: '{{.TESTS_DIR}}'
vars:
INFRA: '{{default "aws" .INFRA}}'
STACKIT_PROJECT_ID: '{{default "" .STACKIT_PROJECT_ID}}'
GOCOVERDIR_PATH: '{{.ROOT_PATH}}{{.SEP}}covdata-deployment'
env:
# See tests-deployment: avoids the GOCOVERDIR-not-set warning leaking into test output.
GOCOVERDIR: '{{.GOCOVERDIR_PATH}}'
cmds:
- rm -rf {{.GOCOVERDIR_PATH}} && mkdir -p {{.GOCOVERDIR_PATH}}
- |
poetry run pytest -vv --exasol-path={{.BUILD_DIR}}{{.SEP}}{{.BINARY_NAME}} --infra={{.INFRA}} {{if .STACKIT_PROJECT_ID}}--stackit-project-id={{.STACKIT_PROJECT_ID}}{{end}} -m "installation_e2e" {{.TESTS_DIR}}{{.SEP}}tests{{.SEP}}deployment {{.TESTS_DIR}}{{.SEP}}tests{{.SEP}}e2e {{.TESTS_DIR}}{{.SEP}}tests{{.SEP}}chaos
tests-deployment-local:
desc: Run local deployment tests on supported Linux, Windows, and macOS hosts
deps: [tests-setup]
dir: '{{.TESTS_DIR}}'
vars:
GOCOVERDIR_PATH: '{{.ROOT_PATH}}{{.SEP}}covdata-deployment'
env:
# See tests-deployment: avoids the GOCOVERDIR-not-set warning leaking into test output.
GOCOVERDIR: '{{.GOCOVERDIR_PATH}}'
cmds:
- rm -rf {{.GOCOVERDIR_PATH}} && mkdir -p {{.GOCOVERDIR_PATH}}
- poetry run pytest -vv --exasol-path={{.BUILD_DIR}}{{.SEP}}{{.BINARY_NAME}} --infra=local -m "local_e2e" {{.TESTS_DIR}}{{.SEP}}tests{{.SEP}}deployment {{.TESTS_DIR}}{{.SEP}}tests{{.SEP}}e2e {{.TESTS_DIR}}{{.SEP}}tests{{.SEP}}chaos
lint-ruff:
desc: Run ruff check
cmds:
- task: lint-ruff-check
- task: lint-ruff-format
lint-ruff-fix:
desc: Run ruff check, format and apply automatic fixes
cmds:
- task: lint-ruff-check-fix
- task: lint-ruff-format-fix
lint-ruff-check:
desc: Run ruff check
deps:
- tests-setup
dir: '{{.TESTS_DIR}}'
cmds:
- poetry run ruff check
lint-ruff-check-fix:
desc: Run ruff check and apply automatic fixes
deps:
- tests-setup
dir: '{{.TESTS_DIR}}'
cmds:
- poetry run ruff check --fix
lint-ruff-format:
desc: Run ruff format
deps:
- tests-setup
dir: '{{.TESTS_DIR}}'
cmds:
- poetry run ruff format --check
lint-ruff-format-fix:
desc: Run ruff format and apply automatic fixes
deps:
- tests-setup
dir: '{{.TESTS_DIR}}'
cmds:
- poetry run ruff format
lint-mypy:
desc: Run mypy check
deps: [tests-setup]
dir: '{{.TESTS_DIR}}'
cmds:
- poetry run mypy {{.TESTS_DIR}}
lint-golang:
desc: Run golangci-lint linters and verify go.mod/go.sum are tidy
deps:
- task: generate
vars:
SKIP_EMBED: "true"
cmds:
- go tool golangci-lint run ./...
- go mod tidy
- git diff --exit-code go.mod go.sum
lint-golang-fix:
desc: Run golangci-lint linters and apply automatic fixes
deps:
- task: generate
vars:
SKIP_EMBED: "true"
cmds:
- go tool golangci-lint run ./... --fix
lint-terraform:
desc: Run tflint for Terraform files within assets/infrastructure
cmds:
- go tool tflint --init
- go tool tflint --recursive --format=default --chdir=./assets/infrastructure
lint-licenses:
desc: Run addlicense on check mode for all source files
cmds:
- go tool addlicense -l mit -c "Exasol AG" -check -s=only $(git ls-files '*.go' '*.py')
lint-licenses-fix:
desc: Run addlicense to add the correct license header for all source files
cmds:
- go tool addlicense -l mit -c "Exasol AG" -s=only $(git ls-files '*.go' '*.py')
lint:
desc: Run linters
cmds:
- task: lint-golang
- task: lint-ruff
- task: lint-mypy
- task: lint-terraform
- task: lint-licenses
clean:
desc: Clean build artifacts
cmds:
- rm -rf {{.BUILD_DIR}}
- rm -f coverage-unit.out
- rm -f coverage-integration.out
- rm -rf covdata-integration
- rm -rf coverage-integration-linux
- rm -rf coverage-integration-windows
fmt-golang:
desc: Format Go code
cmds:
- task: lint-golang-fix
fmt-ruff:
desc: Format Python code with Ruff
deps: [tests-setup]
dir: '{{.TESTS_DIR}}'
cmds:
- poetry run ruff format
- poetry run ruff check --fix
fmt-terraform:
desc: Format Terraform code with OpenTofu
cmds:
- go run -tags=containers_image_openpgp ./tools/tofu/main.go fmt -recursive assets/infrastructure
fmt:
desc: Format code
deps:
- fmt-golang
- fmt-ruff
- fmt-terraform
all:
desc: Run all tasks (lint, build, test)
cmds:
- task: lint
- task: build
- task: tests-unit
- task: tests-integration