-
Notifications
You must be signed in to change notification settings - Fork 239
Expand file tree
/
Copy pathTaskfile.dist.yaml
More file actions
766 lines (676 loc) · 24.9 KB
/
Copy pathTaskfile.dist.yaml
File metadata and controls
766 lines (676 loc) · 24.9 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
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
version: "3"
silent: true
env:
GO111MODULE: "on"
KUBECONFIG:
sh: echo "$HOME/.kube/config"
PRETTIER_VERSION: "3.5.3"
GOLANGCI_LINT_CONFIG: ".golangci.yml"
includes:
_remote-lint:
taskfile: https://raw.githubusercontent.com/werf/common-ci/refs/heads/main/Taskfile.format_lint.yml
vars:
golangciPaths: "./cmd/... ./pkg/... ./test/..."
golangciLintVersion: "v2.11.4"
deps:
taskfile: https://raw.githubusercontent.com/werf/common-ci/refs/heads/main/Taskfile.deps.yml
flatten: true
vars:
golangciLintVersion: "v2.11.4"
vars:
version: "dev"
os: "{{OS}}"
arch: '{{ternary "arm64" ARCH (eq ARCH "arm")}}'
mode: '{{ternary "cgo" "go" (eq .os "linux")}}'
devBinary: './bin/werf{{if (eq .targetOS "windows")}}.exe{{end}}'
withCoverageBinary: './bin/werf-with-coverage{{if (eq .targetOS "windows")}}.exe{{end}}'
package: "github.com/werf/werf/v3/cmd/werf"
kubeVersion: '{{.kubeVersion | default "1.36.1"}}'
goTags: "dfrunsecurity dfrunnetwork dfrunmount dfssh containers_image_openpgp"
goLDFlags: "-s -w -X github.com/werf/werf/v3/pkg/werf.Version={{.version}}"
cgoTags: "{{.goTags}} osusergo exclude_graphdriver_devicemapper netgo no_devmapper static_build"
cgoLDFlags: "{{.goLDFlags}} -linkmode external -extldflags=-static"
buildGoTags: "{{.goTags}} embedstapel"
buildCgoTags: "{{.cgoTags}} embedstapel"
# Deno is embedded for release binaries only: a dev build would pay a ~45 MiB download and ~42 MiB
# of linked blob for a runtime it can just as well fetch on demand.
distGoTags: "{{.buildGoTags}} embedwerfdeno"
distCgoTags: "{{.buildCgoTags}} embedwerfdeno"
tasks:
format:
desc: "Run all code formatters."
cmds:
- task: _remote-lint:format:gci
- task: _remote-lint:format:gofumpt
lint:golangci-lint:go:
desc: 'Lint with golangci-lint without cgo. Important vars: "golangciPaths", "golangciLintVersion".'
cmds:
- |
if [ ! -f "./bin/golangci-lint-v2.11.4" ]; then
echo "golangci-lint not installed, run: task deps:install:golangci-lint"
exit 1
fi
./bin/golangci-lint-v2.11.4 run --build-tags="{{.distGoTags}}" -c .golangci.yml {{.CLI_ARGS}} {{.golangciPaths | default "./cmd/... ./pkg/... ./schemas/... ./test/..."}}
env:
CGO_ENABLED: "0"
lint:golangci-lint:cgo:
desc: 'Lint with golangci-lint for cgo. Important vars: "golangciPaths", "golangciLintVersion".'
cmds:
- |
if [ ! -f "./bin/golangci-lint-v2.11.4" ]; then
echo "golangci-lint not installed, run: task deps:install:golangci-lint"
exit 1
fi
./bin/golangci-lint-v2.11.4 run --build-tags="{{.cgoTags}}" -c .golangci.yml {{.CLI_ARGS}} {{.golangciPaths | default "./cmd/... ./pkg/... ./schemas/... ./test/..."}}
env:
CGO_ENABLED: "1"
lint:golangci-lint:
desc: 'Lint with golangci-lint. Important vars: "golangciPaths".'
deps:
- task: lint:golangci-lint:go
vars:
golangciPaths: "{{.golangciPaths}}"
lint:
desc: "Run all linters."
cmds:
- task: stapel:embed
- task: deno:embed
- task: lint:golangci-lint
- task: verify:builder:go-version
_build-and-lint:
deps:
- build
- lint
default:
cmds:
- task: format
- task: _build-and-lint
stapel:embed:
desc: "Generate embedded stapel image tarballs for linux/amd64 and linux/arm64."
run: once
sources:
- pkg/stapel/stapel.go
generates:
- pkg/stapel/embed/linux/amd64/werf-stapel-toolchain.tar.gz
- pkg/stapel/embed/linux/amd64/werf-stapel-toolchain.tar.sha256
- pkg/stapel/embed/linux/arm64/werf-stapel-toolchain.tar.gz
- pkg/stapel/embed/linux/arm64/werf-stapel-toolchain.tar.sha256
cmds:
- env -u GOOS -u GOARCH -u WERF_STAPEL_IMAGE_NAME WERF_STAPEL_IMAGE_VERSION="$(sed -n 's/.*VERSION *= *"\(.*\)"/\1/p' pkg/stapel/stapel.go | head -1)" go run ./cmd/embed-stapel
deno:embed:
desc: 'Download and embed the Deno binary for one platform. Important vars: "platform".'
run: when_changed
label: 'deno:embed:{{.platform}}'
vars:
platform: '{{.platform | default (printf "%s/%s" .os .arch)}}'
denoVersionSource:
sh: printf '%s/pkg/ts/denolock/data/lock.json' "$(go list -m -f '{{`{{.Dir}}`}}' github.com/werf/nelm/v2)"
sources:
# The pinned nelm version determines the lock, and unlike the path below it always resolves: on
# a cold module cache "go list -m" reports an empty Dir and that entry matches nothing.
- go.mod
- '{{.denoVersionSource}}'
generates:
- pkg/deno/embed/{{.platform}}/deno.gz
cmds:
- env -u GOOS -u GOARCH DENO_EMBED_ROOT=pkg/deno/embed DENO_EMBED_PLATFORM="{{.platform}}" go run github.com/werf/nelm/v2/scripts/embed-deno
_build:cgo:dev: &build_cgo_dev
deps:
- stapel:embed
cmds:
- go build {{if eq .raceDetectorEnabled "true" }}-race{{end}} -o "{{.outputDir | default (printf "./build/%s-%s" .targetOS .targetArch)}}/werf{{if (eq .targetOS "windows")}}.exe{{end}}"
-compiler gc -ldflags="{{.cgoLDFlags}}" -tags="{{.buildCgoTags}}" {{.extraGoBuildArgs}} {{.CLI_ARGS}} {{.pkg | default .package}}
env:
CGO_ENABLED: "1"
GOOS: "{{.targetOS}}"
GOARCH: "{{.targetArch}}"
CC: "{{.cc}}"
vars:
raceDetectorEnabled: '{{.raceDetectorEnabled | default "false"}}'
_build:cgo:dist:
<<: *build_cgo_dev
deps:
- stapel:embed
- task: deno:embed
vars:
platform: "{{.targetOS}}/{{.targetArch}}"
cmds:
- go build -o "{{.outputDir | default (printf "./dist/%s/%s-%s/bin" .version .targetOS .targetArch)}}/werf{{if (eq .targetOS "windows")}}.exe{{end}}"
-compiler gc -ldflags="{{.cgoLDFlags}}" -tags="{{.distCgoTags}}" {{.extraGoBuildArgs}} {{.CLI_ARGS}} {{.pkg | default .package}}
_build:go:dev: &build_go_dev
deps:
- stapel:embed
cmds:
- go build {{if eq .raceDetectorEnabled "true" }}-race{{end}} -o "{{.outputDir | default (printf "./build/%s-%s" .targetOS .targetArch)}}/werf{{if (eq .targetOS "windows")}}.exe{{end}}"
-ldflags="{{.goLDFlags}}" -tags="{{.buildGoTags}}" {{.extraGoBuildArgs}} {{.CLI_ARGS}} {{.pkg | default .package}}
env:
CGO_ENABLED: "0"
GOOS: "{{.targetOS}}"
GOARCH: "{{.targetArch}}"
vars:
raceDetectorEnabled: '{{.raceDetectorEnabled | default "false"}}'
_build:go:dist:
<<: *build_go_dev
deps:
- stapel:embed
- task: deno:embed
vars:
platform: "{{.targetOS}}/{{.targetArch}}"
cmds:
- go build -o "{{.outputDir | default (printf "./dist/%s/%s-%s/bin" .version .targetOS .targetArch)}}/werf{{if (eq .targetOS "windows")}}.exe{{end}}"
-ldflags="{{.goLDFlags}}" -tags="{{.distGoTags}}" {{.extraGoBuildArgs}} {{.CLI_ARGS}} {{.pkg | default .package}}
build:
desc: "Build werf dev binary."
run: once
cmds:
- task: build:dev:{{.os}}:{{.arch}}
vars:
outputDir: '{{.outputDir | default "./bin"}}'
extraGoBuildArgs: "{{.extraGoBuildArgs}}"
raceDetectorEnabled: '{{.raceDetectorEnabled | default "false"}}'
build:dev:all:
desc: "Build all werf dev binaries in parallel."
deps:
- build:dev:linux:amd64:cgo
- build:dev:linux:amd64:go
- build:dev:linux:arm64
- build:dev:darwin:amd64
- build:dev:darwin:arm64
- build:dev:windows:amd64
build:dist:all:
desc: "Build all werf release binaries in parallel."
deps:
- build:dist:linux:amd64
- build:dist:linux:arm64
- build:dist:darwin:amd64
- build:dist:darwin:arm64
- build:dist:windows:amd64
build:dev:linux:amd64:
desc: "Build werf dev binary for linux/amd64."
cmds:
- task: build:dev:linux:amd64:cgo
vars:
outputDir: "{{.outputDir}}"
extraGoBuildArgs: "{{.extraGoBuildArgs}}"
raceDetectorEnabled: "{{.raceDetectorEnabled}}"
build:dev:linux:amd64:cgo:
desc: "Build werf dev binary for linux/amd64 with cgo."
cmds:
- task: _build:cgo:dev
vars:
targetOS: "linux"
targetArch: "amd64"
outputDir: "{{.outputDir}}"
extraGoBuildArgs: "{{.extraGoBuildArgs}}"
raceDetectorEnabled: "{{.raceDetectorEnabled}}"
build:dev:linux:amd64:go:
desc: "Build werf dev binary for linux/amd64 without cgo."
cmds:
- task: _build:go:dev
vars:
targetOS: "linux"
targetArch: "amd64"
outputDir: "{{.outputDir}}"
extraGoBuildArgs: "{{.extraGoBuildArgs}}"
raceDetectorEnabled: "{{.raceDetectorEnabled}}"
build:dist:linux:amd64:
desc: 'Build werf release binary for linux/amd64. Important vars: "version".'
cmds:
- task: _build:cgo:dist
vars:
targetOS: "linux"
targetArch: "amd64"
extraGoBuildArgs: "{{.extraGoBuildArgs}}"
build:dev:linux:arm64:
desc: "Build werf dev binary for linux/arm64."
cmds:
- task: _build:cgo:dev
vars:
targetOS: "linux"
targetArch: "arm64"
cc: "aarch64-linux-gnu-gcc"
outputDir: "{{.outputDir}}"
extraGoBuildArgs: "{{.extraGoBuildArgs}}"
raceDetectorEnabled: "{{.raceDetectorEnabled}}"
build:dist:linux:arm64:
desc: 'Build werf release binary for linux/arm64. Important vars: "version".'
cmds:
- task: _build:cgo:dist
vars:
targetOS: "linux"
targetArch: "arm64"
cc: "aarch64-linux-gnu-gcc"
extraGoBuildArgs: "{{.extraGoBuildArgs}}"
build:dev:darwin:amd64:
desc: "Build werf dev binary for darwin/amd64."
cmds:
- task: _build:go:dev
vars:
targetOS: "darwin"
targetArch: "amd64"
outputDir: "{{.outputDir}}"
extraGoBuildArgs: "{{.extraGoBuildArgs}}"
raceDetectorEnabled: "{{.raceDetectorEnabled}}"
build:dist:darwin:amd64:
desc: 'Build werf release binary for darwin/amd64. Important vars: "version".'
cmds:
- task: _build:go:dist
vars:
targetOS: "darwin"
targetArch: "amd64"
extraGoBuildArgs: "{{.extraGoBuildArgs}}"
build:dev:darwin:arm64:
desc: "Build werf dev binary for darwin/arm64."
cmds:
- task: _build:go:dev
vars:
targetOS: "darwin"
targetArch: "arm64"
outputDir: "{{.outputDir}}"
extraGoBuildArgs: "{{.extraGoBuildArgs}}"
raceDetectorEnabled: "{{.raceDetectorEnabled}}"
build:dist:darwin:arm64:
desc: 'Build werf release binary for darwin/arm64. Important vars: "version".'
cmds:
- task: _build:go:dist
vars:
targetOS: "darwin"
targetArch: "arm64"
extraGoBuildArgs: "{{.extraGoBuildArgs}}"
build:dev:windows:amd64:
desc: "Build werf dev binary for windows/amd64."
cmds:
- task: _build:go:dev
vars:
targetOS: "windows"
targetArch: "amd64"
outputDir: "{{.outputDir}}"
extraGoBuildArgs: "{{.extraGoBuildArgs}}"
raceDetectorEnabled: "{{.raceDetectorEnabled}}"
build:dist:windows:amd64:
desc: 'Build werf release binary for windows/amd64. Important vars: "version".'
cmds:
- task: _build:go:dist
vars:
targetOS: "windows"
targetArch: "amd64"
extraGoBuildArgs: "{{.extraGoBuildArgs}}"
build-with-coverage:
desc: "Build werf binary to run E2E tests with coverage."
cmds:
- task: build:dev:{{.os}}:{{.arch}}
vars:
outputDir: '{{.outputDir | default "./bin"}}'
extraGoBuildArgs: "-cover -coverpkg=./..."
raceDetectorEnabled: '{{.raceDetectorEnabled | default "false"}}'
_test:go-test:cgo:
cmds:
- go test -compiler gc -ldflags="{{.cgoLDFlags}}" -tags="{{.cgoTags}}" {{.extraTestGoTestArgs}} {{.CLI_ARGS}} {{.paths}}
env:
CGO_ENABLED: "1"
requires:
vars:
- paths
_test:go-test:go:
cmds:
- go test -ldflags="{{.goLDFlags}}" -tags="{{.goTags}}" {{.extraTestGoTestArgs}} {{.CLI_ARGS}} {{.paths}}
env:
CGO_ENABLED: "0"
requires:
vars:
- paths
test:go-test: &test_go_test
desc: 'Run raw "go test". Important vars: "paths".'
cmds:
- task: _test:go-test:{{.mode}}
vars:
paths: "{{.paths}}"
extraTestGoTestArgs: "{{.extraTestGoTestArgs}}"
_test:ginkgo:cgo:
cmds:
- |
ginkgo {{if eq .parallel "true" }}-p{{end}} -r -compiler gc -ldflags="{{.cgoLDFlags}}" -tags="{{.cgoTags}}" \
{{if .labelFilter}}--label-filter="{{.labelFilter}}"{{end}} {{.CLI_ARGS}} {{.paths}}
env:
CGO_ENABLED: "1"
vars:
parallel: '{{.parallel | default "true"}}'
requires:
vars:
- paths
_test:ginkgo:go:
cmds:
- |
ginkgo {{if eq .parallel "true" }}-p{{end}} -r -ldflags="{{.goLDFlags}}" -tags="{{.goTags}}" \
{{if .labelFilter}}--label-filter="{{.labelFilter}}"{{end}} {{.CLI_ARGS}} {{.paths}}
env:
CGO_ENABLED: "0"
vars:
parallel: '{{.parallel | default "true"}}'
requires:
vars:
- paths
test:ginkgo: &test_ginkgo
desc: 'Run raw "ginkgo". Important vars: "paths".'
preconditions:
- sh: |
expected_version="$(awk '$1 == "github.com/onsi/ginkgo/v2" && $2 ~ /^v[0-9]/ { print $2; exit }' go.mod)"
test -n "$expected_version" && test "v$(ginkgo version 2>/dev/null | awk '{print $3}')" = "$expected_version"
msg: 'Ginkgo CLI version must match go.mod; run "task deps:install:ginkgo".'
cmds:
- task: _test:ginkgo:{{.mode}}
vars:
paths: "{{.paths}}"
labelFilter: "{{.labelFilter}}"
parallel: "{{.parallel}}"
test:unit:
desc: 'Run unit tests. Important vars: "paths".'
cmds:
- task: test:ginkgo
vars:
paths: '{{.paths | default "./pkg ./cmd ./schemas"}}'
parallel: "{{.parallel}}"
test:unit:embedded:
desc: "Test embedded Stapel and Deno assets."
deps:
- stapel:embed
- deno:embed
cmds:
- go test -ldflags="{{.goLDFlags}}" -tags="{{.distGoTags}}" ./pkg/stapel ./pkg/deno
env:
CGO_ENABLED: "0"
test:integration:
desc: 'Run integration tests. Important vars: "paths".'
cmds:
- task: test:ginkgo
vars:
paths: '{{.paths | default "./test/legacy_e2e"}}'
labelFilter: "{{.labelFilter}}"
parallel: "{{.parallel}}"
test:e2e:
desc: 'Run all e2e tests. Important vars: "paths".'
cmds:
- task: test:ginkgo
vars:
paths: '{{.paths | default "./test/e2e"}}'
labelFilter: "{{.labelFilter}}"
parallel: "{{.parallel}}"
test:e2e:simple:
desc: 'Run e2e tests tagged "simple". Important vars: "paths".'
cmds:
- task: test:ginkgo
vars:
paths: '{{.paths | default "./test/e2e"}}'
labelFilter: '{{.labelFilter | default "simple"}}'
parallel: "{{.parallel}}"
test:e2e:complex:
desc: 'Run e2e tests tagged "complex". Important vars: "paths".'
cmds:
- task: test:ginkgo
vars:
paths: '{{.paths | default "./test/e2e"}}'
labelFilter: '{{.labelFilter | default "complex"}}'
parallel: "{{.parallel}}"
test:e2e:extra:
desc: 'Run e2e tests not tagged "simple" or "complex". Important vars: "paths".'
cmds:
- task: test:ginkgo
vars:
paths: '{{.paths | default "./test/e2e"}}'
labelFilter: '{{.labelFilter | default "!complex && !simple"}}'
parallel: "{{.parallel}}"
test:setup:environment:
desc: "Setup environment on which the tests will be run."
cmds:
- task: deps:install:kind
- task: test:setup:registry
- task: test:setup:kubernetes
- task: test:env:generate
test:setup:registry:
desc: "Setup dev registry."
cmds:
- docker network create kind || true
- docker run -d -p 0.0.0.0::5000 --network kind -e REGISTRY_STORAGE_DELETE_ENABLED=true --restart=always --name kind-registry registry:2
test:setup:kubernetes:
desc: "Setup dev kubernetes cluster."
vars:
registryPort:
sh: docker inspect kind-registry --format '{{"{{"}}(index (index .NetworkSettings.Ports "5000/tcp") 0).HostPort{{"}}"}}'
cmd: |
kind create cluster --image kindest/node:v{{.kubeVersion}} --config=<(echo "
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
containerdConfigPatches:
- |
[plugins.\"io.containerd.grpc.v1.cri\".registry.mirrors.\"localhost:{{.registryPort}}\"]
endpoint = [\"http://kind-registry:5000\"]
")
docker network connect kind kind-registry 2>/dev/null || true
test:env:generate:
desc: "Generate .env file for test environment"
vars:
registryPort:
sh: docker inspect kind-registry --format '{{"{{"}}(index (index .NetworkSettings.Ports "5000/tcp") 0).HostPort{{"}}"}}'
cmds:
- echo "KUBECONFIG=${HOME}/.kube/config" > .env
- echo "WERF_TEST_K8S_DOCKER_REGISTRY=localhost:{{.registryPort}}" >> .env
- echo "Environment file '.env' generated."
- echo "Run 'export $(xargs < .env)' to start working with tests or the environment."
verify:release-pr-selection:
desc: "Verify release tagging selects only merged release PRs for its branch."
cmds:
- python3 scripts/check-release-pr-selection.py
verify:builder:go-version:
desc: "Verify that the release builder image is pinned to the Go version go.mod asks for."
cmds:
- |
want=$(awk '/^toolchain go/ {sub(/^go/, "", $2); print $2}' go.mod)
got=$(awk -F'[:@]' '/^FROM golang:/ {print $2}' scripts/werf-builder/Dockerfile | sed 's/-.*//')
if [ "$want" != "$got" ]; then
echo "go.mod asks for go$want, scripts/werf-builder/Dockerfile pins go$got." >&2
echo "Rebuild the builder image and repin trdl.yaml, or the release build downloads a toolchain over the network." >&2
exit 1
fi
echo "builder image pins go$got, matching go.mod"
verify:binaries:dist:all:
desc: 'Verify that the distributable binaries are built and have correct platform/arch. Important vars: "version".'
cmds:
- ./scripts/verify-dist-binaries.sh {{.version}}
compress:binaries:dist:all:
desc: 'Compress distributable binaries with upx. Important vars: "version".'
cmds:
- |
find "./dist/{{.version}}" -type f \( -path "*/linux-*/bin/werf" -o -path "*/windows-*/bin/werf.exe" \) -exec upx --best {} +
mock:generate:
desc: "Generate mocks."
cmds:
- go generate -run mockgen ./cmd/... ./pkg/...
mock:check:
desc: "Check that mocks are up-to-date."
deps:
- deps:install:mockgen
cmds:
- |
FILES="test/mock/ pkg/config/image_interface_mock.go pkg/giterminism_manager/file_reader/file_reader_deps_mock_test.go pkg/giterminism_manager/file_reader/file_reader_deps_fileinfo_mock_test.go"
go generate -run mockgen ./cmd/... ./pkg/...
git diff --exit-code $FILES || {
echo "ERROR: Mocks are out of date. Run 'task mock:generate' and commit changes."
exit 1
}
echo "Mocks are up-to-date"
enum:generate:
desc: "Generate enums."
cmds:
- go generate -run enumer ./cmd/... ./pkg/...
doc:
desc: "Run all docs generators, formatters and linters."
cmds:
- task: doc:check-source-links
- task: doc:gen
- task: doc:check-broken-links
doc:check-source-links:
desc: "Verify documentation Source links select the matching branch."
cmds:
- node scripts/docs/check_editme_links.js
doc:gen:
desc: "Regenerate docs."
deps:
- build
cmds:
- ./scripts/docs/regen.sh "{{.devBinary}}"
doc:check-broken-links:
desc: "Check docs for broken links."
deps:
- doc:check-broken-links:ru
- doc:check-broken-links:en
doc:check-broken-links:ru:
desc: "Check ru docs for broken links."
deps:
- build
cmds:
- ./scripts/docs/check_broken_links.sh ru "{{.devBinary}}"
doc:check-broken-links:en:
desc: "Check en docs for broken links."
deps:
- build
cmds:
- ./scripts/docs/check_broken_links.sh main "{{.devBinary}}"
github:dispatch:werf:
desc: 'Manually dispatch specified GitHub workflow. Important vars: "eventType", "githubToken".'
cmds:
- |
curl -sSL 'https://api.github.com/repos/werf/werf/dispatches' \
-H 'Content-Type: application/json' \
-H 'Accept: application/vnd.github.everest-preview+json' \
-H "Authorization: token {{.githubToken}}" \
--data-raw '{
"event_type": "{{.eventType}}",
"client_payload": {{.clientPayload | default "{}"}}
}' {{.CLI_ARGS}}
requires:
vars:
- githubToken
_image:build:
cmds:
- docker build {{.CLI_ARGS}} -f "{{.dfilePath}}" -t "{{.imageName}}" "{{.context | default "."}}"
image:build:builder:
desc: 'Build werf builder image. Important vars: "imageName".'
cmds:
- task: _image:build
vars:
dfilePath: scripts/werf-builder/Dockerfile
imageName:
sh: "echo registry-write.werf.io/werf/builder:$(git rev-parse HEAD)"
_image:push:
cmds:
- docker push {{.CLI_ARGS}} "{{.imageName}}"
image:publish:builder:
desc: 'Build and publish werf builder image. Important vars: "imageName".'
deps:
- image:build:builder
cmds:
- task: _image:push
vars:
imageName:
sh: "echo registry-write.werf.io/werf/builder:$(git rev-parse HEAD)"
clean:binaries:
desc: "Clean all built binaries."
deps:
- clean:binaries:dev
- clean:binaries:dist
clean:binaries:dev:
desc: "Clean built dev binaries."
cmds:
- rm -rf ./bin ./build
clean:binaries:dist:
desc: "Clean built release binaries."
cmds:
- rm -rf ./dist
deps:install:all:
desc: "Install common and specific deps"
deps:
- deps:install
- deps:install:kind
- deps:install:mockgen
- deps:install:enumer
deps:install:kind:
desc: "Install kind binary."
cmd: go install sigs.k8s.io/kind@v0.29.0
deps:install:mockgen:
desc: "Install mockgen library."
cmds:
- go install go.uber.org/mock/mockgen@v0.6.0
deps:install:enumer:
desc: "Install enumer library."
cmds:
- go install github.com/dmarkham/enumer@v1.5.11
sign:
desc: 'Sign last created version tag + origin/main and push signatures. Important vars: "refs".'
cmds:
- git fetch --tags -f
- git signatures pull {{.CLI_ARGS}}
- |
for ref in {{.refs | default "$(git for-each-ref --sort=-creatordate --count=1 --format='%(refname:short)' 'refs/tags/v*') origin/main"}}; do
echo Signing $ref...
git signatures add {{.CLI_ARGS}} $ref
git signatures show {{.CLI_ARGS}} $ref
done
- git signatures push {{.CLI_ARGS}}
dev:setup:local-telemetry:
desc: "Setup telemetry dev server."
dir: ./scripts/local-telemetry
cmds:
- docker-compose {{.CLI_ARGS}} up -d
dev:cleanup:local-telemetry:
desc: "Cleanup telemetry dev server."
dir: ./scripts/local-telemetry
cmds:
- docker-compose {{.CLI_ARGS}} down
dev:setup:docker-network:
desc: "Create shared docker network werfio-dev to use with werf/website"
vars:
NETWORK_NAME: werfio-dev
cmds:
- docker network create -d=bridge {{.NETWORK_NAME}}
status:
- docker network inspect {{.NETWORK_NAME}}
_dev:run:compose:up:
deps:
- dev:setup:docker-network
cmds:
- |
services="{{ .lang }}"
services=${services:-"en ru"}
if [[ "yes" == "{{.standalone}}" ]] ; then
services="${services} front"
fi
# Run compose up in docs directory.
cd docs
which werf >/dev/null || source $(trdl use werf 2 beta)
werf compose up jekyll_base --dev --docker-compose-command-options="$services" --platform=linux/amd64 || true
dev:setup:website:standalone:
desc: "Run jekyll in werf compose for content editing without werf/website (scripts/styles/images are proxied from werf.io). Use lang=en or lang=ru to run only specified lang."
cmds:
- task: _dev:run:compose:up
vars:
standalone: "yes"
dev:setup:website:
desc: "Run jekyll in werf compose for local development. Use lang=en or lang=ru to run only specified lang. Run task dev:setup:website in werf/website repository to access documentation."
cmds:
- task: _dev:run:compose:up
vars:
standalone: "no"
dev:cleanup:website:
desc: "Stop and clean after werf compose"
cmds:
- |
cd docs
which werf >/dev/null || source $(trdl use werf 2 beta)
# Workaround: set image variable to stub image.
WERF_JEKYLL_BASE_DOCKER_IMAGE_NAME=nginx:latest \
werf compose down
test:cleanup:environment:
desc: "Cleanup environment"
cmds:
- kind delete cluster || true
- docker rm -f kind-registry || true