-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathTaskfile.yaml
More file actions
467 lines (425 loc) · 15.6 KB
/
Copy pathTaskfile.yaml
File metadata and controls
467 lines (425 loc) · 15.6 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
# https://taskfile.dev
version: "3"
silent: true
includes:
vm-route-forge:
taskfile: ./images/vm-route-forge
dir: ./images/vm-route-forge
virtualization-controller:
aliases: [controller]
taskfile: ./images/virtualization-artifact
dir: ./images/virtualization-artifact
gohooks:
taskfile: ./images/hooks
dir: ./images/hooks
pvc-artifact:
taskfile: ./images/pvc-artifact
dir: ./images/pvc-artifact
e2e:
taskfile: ./test/e2e
dir: ./test/e2e
perf:
taskfile: ./test/performance
dir: ./test/performance
d8v-cli:
taskfile: ./src/cli
dir: ./src/cli
vars:
deckhouse_lib_helm_ver: 1.72.0
TRIVY_VERSION: 0.55.0
target: ""
VALIDATION_FILES: "tools/validation/{main,messages,diff,no_cyrillic,doc_changes}.go"
DLV_IMAGE:
sh: if [ -z $DLV_IMAGE ]; then echo "ttl.sh/$(uuidgen | awk '{print tolower($0)}'):10m" ; else echo $DLV_IMAGE ; fi
tasks:
go:sync:
desc: "Sync module go.mod/go.sum files via go work sync. Use instead of go mod tidy."
cmds:
- go work sync
check-werf:
cmds:
- which werf >/dev/null || (echo "werf not found."; exit 1)
silent: true
check-yq:
cmds:
- which yq >/dev/null || (echo "yq not found."; exit 1)
silent: true
check-jq:
cmds:
- which jq >/dev/null || (echo "jq not found."; exit 1)
silent: true
report:render:slowest:
desc: "Render slowest-specs chart for one Describe (DESCRIBE=..., JSON=...)"
silent: true
vars:
JSON: '{{.JSON | default ""}}'
DESCRIBE: '{{.DESCRIBE | default ""}}'
OUT_DIR: '{{.OUT_DIR | default "tmp"}}'
cmds:
- test -n "{{.JSON}}" || (echo "JSON=... is required"; exit 1)
- test -n "{{.DESCRIBE}}" || (echo "DESCRIBE=... is required"; exit 1)
- >-
python3 .github/scripts/python/e2e_report/charts.py slowest
--json "{{.JSON}}"
--describe "{{.DESCRIBE}}" --out-dir "{{.OUT_DIR}}/charts"
report:render:top-slowest:
desc: "Render slowest-specs charts for top-N slowest Describes"
silent: true
vars:
REPORTS_DIR: '{{.REPORTS_DIR | default "tmp/test-ci/report/out"}}'
OUT_DIR: '{{.OUT_DIR | default "tmp"}}'
TOP_N: "{{.TOP_N | default 5}}"
cmds:
- mkdir -p "{{.OUT_DIR}}" "{{.REPORTS_DIR}}"
- >-
python3 .github/scripts/python/e2e_report/charts.py top
--reports-dir "{{.REPORTS_DIR}}"
--out-dir "{{.OUT_DIR}}/charts"
--top-n "{{.TOP_N}}"
check-helm:
cmds:
- which helm >/dev/null || (echo "helm not found."; exit 1)
silent: true
golangci-lint:check:
desc: "Check golangci-lint version"
cmds:
- |
GOLANGCI_LINT_MIN_VERSION="2.0"
CURRENT_VERSION=$(golangci-lint --version 2>/dev/null | grep -oP 'version \K[0-9]+\.[0-9]+' || echo "0.0")
if [ "$(printf '%s\n' "$GOLANGCI_LINT_MIN_VERSION" "$CURRENT_VERSION" | sort -V | head -n1)" != "$GOLANGCI_LINT_MIN_VERSION" ]; then
echo "golangci-lint version $CURRENT_VERSION is below minimum $GOLANGCI_LINT_MIN_VERSION"
echo "Installing golangci-lint..."
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin
fi
silent: true
helm-update-subcharts:
deps:
- check-helm
cmds:
- |
echo -e "Step 1: Add deckhouse Helm repo\n"
helm repo add deckhouse https://deckhouse.github.io/lib-helm
echo -e "\nStep 2: Update deckhouse Helm repo\n"
helm repo update deckhouse
echo -e "\nStep 3: Update dependencies\n"
helm dep update
helm-bump-helm-lib:
deps:
- check-yq
cmds:
- |
lib_helm_ver=$(yq '.dependencies[] | select(.name == "deckhouse_lib_helm").version' Chart.yaml)
echo lib_helm version before update: $lib_helm_ver && echo
- yq -i '.dependencies[] |= select(.name == "deckhouse_lib_helm").version = "{{ .deckhouse_lib_helm_ver }}"' Chart.yaml
- task: helm-update-subcharts
- |
lib_helm_ver=$(yq '.dependencies[] | select(.name == "deckhouse_lib_helm").version' Chart.yaml)
echo && echo lib_helm version after update: $lib_helm_ver
helm-render:
deps:
- check-helm
cmds:
- helm template virtualization . -f tools/kubeconform/fixtures/module-values.yaml --debug --devel > helm-template-render.yaml
build:
deps:
- check-werf
cmds:
- werf build {{ .target }}
dev:format:yaml:
desc: "Format non-templated YAML files, e.g. CRDs"
cmds:
- |
docker run --rm \
-v ./:/tmp/virt ghcr.io/deckhouse/virtualization/prettier:3.2.5 \
sh -c "cd /tmp/virt ; prettier -w \"**/*.yaml\" \"**/*.yml\""
dev:addlicense:
desc: |-
Add Flant CE license to files sh,go,py. Default directory is root of project, custom directory path can be passed like: "task dev:addlicense -- <somedir>"
cmds:
- |
{{if .CLI_ARGS}}
go run tools/addlicense/{main,variables,msg,utils}.go -directory {{ .CLI_ARGS }}
{{else}}
go run tools/addlicense/{main,variables,msg,utils}.go -directory ./
{{end}}
golangci-lint:sync:
desc: "Sync root .golangci.yaml to all subprojects"
cmds:
- |
ROOT_CONFIG="images/virtualization-artifact/.golangci.yaml"
TARGETS=(
"images/hooks"
"images/dvcr-artifact"
"images/virtualization-dra"
"src/cli"
"test/e2e"
"test/performance/tools/shatal"
"tools/addlicense"
"tools/moduleversions"
)
for target in "${TARGETS[@]}"; do
cp "$ROOT_CONFIG" "$target/.golangci.yaml"
echo "Synced $ROOT_CONFIG -> $target/.golangci.yaml"
done
lint:
cmds:
- task: lint:doc-ru
- task: lint:prettier:yaml
- task: lint:shellcheck
- task: lint:actionlint
- task: virtualization-controller:dvcr:lint
- task: virtualization-controller:lint
lint:shellcheck:
desc: "Run shellcheck for CI shell scripts."
cmds:
- |
set -e
# The .gitlab/ci/scripts tree is split into bash/ and python/ folders,
# so lint:shellcheck points directly at the bash folder (no find scan).
EXPLICIT=".github/scripts/bash/e2e/*.sh
.gitlab/ci/scripts/bash/*.sh
.gitlab/ci/scripts/bash/lib/*.sh
api/scripts/update-codegen.sh
images/virtualization-artifact/hack/args.sh
images/virtualization-artifact/hack/dlv.sh
images/virtualization-artifact/hack/pyroscope.sh"
EXPANDED="$(for f in $EXPLICIT; do [ -f "$f" ] && echo "$f"; done | sort -u)"
if [ -z "$EXPANDED" ]; then
echo "No shell scripts found to lint."; exit 0
fi
echo "==> shellcheck will scan $(printf '%s\n' "$EXPANDED" | wc -l | tr -d ' ') files:"
printf ' %s\n' $EXPANDED
echo "==> running shellcheck (koalaman/shellcheck-alpine:v0.11.0)"
docker run --rm \
-v "$PWD:/mnt" \
-w /mnt \
koalaman/shellcheck-alpine:v0.11.0 \
shellcheck \
$EXPANDED
echo "==> shellcheck: no issues found"
lint:actionlint:
desc: "Run actionlint for E2E GitHub workflows."
cmds:
- |
docker run --rm \
-v "$PWD:/repo" \
-w /repo \
rhysd/actionlint:1.7.7 \
-color \
-shellcheck= \
.github/workflows/e2e*.yml
lint:doc-ru:
desc: "Check the correspondence between description fields in the original crd and the Russian language version"
cmds:
- |
docker run \
--rm -it -v "$PWD:/src" docker.io/fl64/d8-doc-ru-linter:v0.0.1-dev0 \
sh -c \
'for crd in /src/crds/*.yaml; do [[ "$(basename "$crd")" =~ ^doc-ru ]] || (echo ${crd}; /d8-doc-ru-linter -s "$crd" -d "/src/crds/doc-ru-$(basename "$crd")" -n /dev/null); done'
lint:prettier:yaml:
desc: "Check if yaml files are prettier-formatted."
cmds:
- |
docker run --rm \
-v ./:/tmp/virt ghcr.io/deckhouse/virtualization/prettier:3.2.5 \
sh -c "cd /tmp/virt ; prettier -c \"**/*.yaml\" \"**/*.yml\""
validation:no-cyrillic:
desc: "No cyrillic"
cmds:
- go run {{ .VALIDATION_FILES }} --type no-cyrillic
validation:doc-changes:
desc: "Doc-changes"
cmds:
- go run {{ .VALIDATION_FILES }} --type doc-changes
validation:go-work:
desc: "Check go.work sync freshness and replace consistency across modules"
deps:
- check-jq
cmds:
- task: go:sync
- git diff --exit-code -- go.work.sum ':(glob)**/go.mod' ':(glob)**/go.sum'
- ./hack/validate-go-work.sh
validation:helm-templates:
desc: "Check Helm templates"
cmds:
- |
cd tools/kubeconform
./kubeconform.sh
dlv:kubevirt:build:
internal: true
desc: "Clone-and-build a kubevirt fork component with dlv (COMPONENT var)"
cmds:
- |
BRANCH="${BRANCH:-$(yq '.core.kubevirt' build/components/versions.yml)}"
if ! LSOUT=$(git ls-remote "ssh://git@fox.flant.com/deckhouse/virtualization/fork/kubevirt.git" "refs/heads/${BRANCH}" "refs/tags/${BRANCH}"); then
echo "git ls-remote to fox failed — ssh agent locked? Try: ssh-add ~/.ssh/id_rsa" >&2; exit 1
fi
COMMIT=$(echo "$LSOUT" | head -1 | cut -f1)
if [ -z "$COMMIT" ]; then echo "No branch or tag '${BRANCH}' on the fox kubevirt fork" >&2; exit 1; fi
docker build --ssh default --build-arg BRANCH="$BRANCH" --build-arg COMMIT="$COMMIT" -f ./images/{{ .COMPONENT }}/debug/dlv.Dockerfile -t "{{ .DLV_IMAGE }}" --platform linux/amd64 .
dlv:virt-controller:build:
desc: "Build image virt-controller with dlv (clones the kubevirt fork from fox via the host ssh agent)"
cmds:
- task: dlv:kubevirt:build
vars: { COMPONENT: virt-controller }
dlv:virt-controller:build-push:
desc: "Build and Push image virt-controller with dlv"
cmds:
- task: dlv:virt-controller:build
- docker push "{{ .DLV_IMAGE }}"
- task: dlv:virt-controller:print
dlv:virt-controller:print:
desc: "Print commands for debug"
env:
IMAGE: "{{ .DLV_IMAGE }}"
cmd: |
cat <<EOF
kubectl patch mc virtualization --type merge --patch '{"spec":{"maintenance":"NoResourceReconciliation"}}'
kubectl -n d8-virtualization scale deploy virt-operator --replicas=0
kubectl -n d8-virtualization patch deploy virt-controller --type='strategic' -p '{
"spec": {
"template": {
"spec": {
"containers": [
{
"name": "virt-controller",
"image": "${IMAGE}",
"ports": [ { "containerPort": 2345, "name": "dlv" } ],
"readinessProbe": null,
"livenessProbe": null,
"command": null
}
]
}
}
}
}'
kubectl -n d8-virtualization port-forward deploy/virt-controller 2345:2345
EOF
dlv:virt-handler:build:
desc: "Build image virt-handler with dlv (clones the kubevirt fork from fox via the host ssh agent)"
cmds:
- task: dlv:kubevirt:build
vars: { COMPONENT: virt-handler }
dlv:virt-handler:build-push:
desc: "Build and Push image virt-handler with dlv"
cmds:
- task: dlv:virt-handler:build
- docker push "{{ .DLV_IMAGE }}"
- task: dlv:virt-handler:print
dlv:virt-handler:print:
desc: "Print commands for debug"
env:
IMAGE: "{{ .DLV_IMAGE }}"
cmd: |
cat <<EOF
kubectl patch mc virtualization --type merge --patch '{"spec":{"maintenance":"NoResourceReconciliation"}}'
kubectl -n d8-virtualization scale deploy virt-operator --replicas=0
kubectl -n d8-virtualization patch ds virt-handler --type='strategic' -p '{
"spec": {
"template": {
"spec": {
"containers": [
{
"name": "virt-handler",
"image": "${IMAGE}",
"ports": [ { "containerPort": 2345, "name": "dlv" } ],
"readinessProbe": null,
"livenessProbe": null,
"command": null
}
]
}
}
}
}'
kubectl -n d8-virtualization port-forward pod/<virt-handler-pod> 2345:2345
EOF
dlv:virt-api:build:
desc: "Build image virt-api with dlv (clones the kubevirt fork from fox via the host ssh agent)"
cmds:
- task: dlv:kubevirt:build
vars: { COMPONENT: virt-api }
dlv:virt-api:build-push:
desc: "Build and Push image virt-api with dlv"
cmds:
- task: dlv:virt-api:build
- docker push "{{ .DLV_IMAGE }}"
- task: dlv:virt-api:print
dlv:virt-api:print:
desc: "Print commands for debug"
env:
IMAGE: "{{ .DLV_IMAGE }}"
cmd: |
cat <<EOF
kubectl patch mc virtualization --type merge --patch '{"spec":{"maintenance":"NoResourceReconciliation"}}'
kubectl -n d8-virtualization scale deploy virt-operator --replicas=0
kubectl -n d8-virtualization patch deploy virt-api --type='strategic' -p '{
"spec": {
"template": {
"spec": {
"containers": [
{
"name": "virt-api",
"image": "${IMAGE}",
"ports": [ { "containerPort": 2345, "name": "dlv" } ],
"readinessProbe": null,
"livenessProbe": null,
"command": null
},
{
"name": "proxy",
"readinessProbe": null,
"livenessProbe": null
},
{
"name": "kube-rbac-proxy",
"readinessProbe": null,
"livenessProbe": null
}
]
}
}
}
}'
kubectl -n d8-virtualization port-forward deploy/virt-api 2345:2345
EOF
dlv:virtualization-dra-usb:build:
desc: "Build image virtualization-dra-usb with dlv (binary is cross-built on the host in workspace mode)"
cmds:
- GOOS=linux GOARCH=amd64 go install github.com/go-delve/delve/cmd/dlv@latest
- mkdir -p images/virtualization-dra-usb/debug/out
- |
DLV_SRC="$(go env GOPATH)/bin/linux_amd64/dlv"
[ -f "$DLV_SRC" ] || DLV_SRC="$(go env GOPATH)/bin/dlv"
cp "$DLV_SRC" images/virtualization-dra-usb/debug/out/dlv
- GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -gcflags "all=-N -l" -o images/virtualization-dra-usb/debug/out/virtualization-dra-usb ./images/virtualization-dra/cmd/usb/dra
- docker build -f ./images/virtualization-dra-usb/debug/dlv.Dockerfile -t "{{ .DLV_IMAGE }}" --platform linux/amd64 .
dlv:virtualization-dra-usb:build-push:
desc: "Build and Push image virtualization-dra-usb with dlv"
cmds:
- task: dlv:virtualization-dra-usb:build
- docker push "{{ .DLV_IMAGE }}"
- task: dlv:virtualization-dra-usb:print
dlv:virtualization-dra-usb:print:
desc: "Print commands for debug"
env:
IMAGE: "{{ .DLV_IMAGE }}"
cmd: |
cat <<EOF
kubectl patch mc virtualization --type merge --patch '{"spec":{"maintenance":"NoResourceReconciliation"}}'
kubectl -n d8-virtualization patch ds virtualization-dra --type='strategic' -p '{
"spec": {
"template": {
"spec": {
"containers": [ {
"name": "virtualization-dra",
"image": "${IMAGE}",
"ports": [ { "containerPort": 2345, "name": "dlv" } ]
}]
}
}
}
}'
kubectl -n d8-virtualization port-forward pod/<virtualization-dra-pod> 2345:2345
EOF