-
Notifications
You must be signed in to change notification settings - Fork 13
/
.gitlab-ci.yml
482 lines (451 loc) · 16.5 KB
/
.gitlab-ci.yml
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
image: ${CI_DEPENDENCY_PROXY_DIRECT_GROUP_IMAGE_PREFIX}/docker:git
variables:
RASPIOS_VERSION: '2023-05-03'
DOCKER_REPOSITORY: 'mendersoftware/mender-test-containers'
DOCKER_HUB_USERNAME: 'menderbuildsystem'
DOCKER_BUILDKIT: 1
.mender-dist-packages-image-matrix:
parallel:
matrix:
- BUILD: simulated
DISTRO: raspberrypios
RELEASE: [bullseye, bookworm]
ARCH: [armhf]
- BUILD: crosscompile
DISTRO: debian
RELEASE: [bullseye, bookworm]
ARCH: [amd64, armhf, arm64]
- BUILD: crosscompile
DISTRO: ubuntu
RELEASE: [focal, jammy, noble]
ARCH: [amd64, armhf, arm64]
.tag_n_push_to_gitlab_registry: &tag_n_push_to_gitlab_registry
- docker pull ${CI_REGISTRY_IMAGE}:${CONTAINER_TAG}-${CI_PIPELINE_ID}
- docker tag ${CI_REGISTRY_IMAGE}:${CONTAINER_TAG}-${CI_PIPELINE_ID} ${CI_REGISTRY_IMAGE}:${CONTAINER_TAG}-${CI_COMMIT_BRANCH}
- docker push ${CI_REGISTRY_IMAGE}:${CONTAINER_TAG}-${CI_COMMIT_BRANCH}
include:
- project: 'Northern.tech/Mender/mendertesting'
file: '.gitlab-ci-check-commits-signoffs.yml'
- project: 'Northern.tech/Mender/mendertesting'
file: '.gitlab-ci-github-status-updates.yml'
- project: 'Northern.tech/Mender/mendertesting'
file: '.gitlab-ci-check-python3-format.yml'
.dind-login: &dind-login
- mkdir -p $HOME/.docker && echo $DOCKER_AUTH_CONFIG > $HOME/.docker/config.json
stages:
- build
- test
- publish
build:prepare:raspios:
tags:
- mender-qa-worker-generic-light
stage: build
needs: []
image: ${CI_DEPENDENCY_PROXY_DIRECT_GROUP_IMAGE_PREFIX}/buildpack-deps:scm
script:
- cd docker/docker-files-raspbian
- apt-get update && apt-get install -yyq sudo unzip xz-utils fdisk
- ./prepare-raspbian-img.sh ${RASPIOS_VERSION}
- cd .. && tar -cvf $CI_PROJECT_DIR/docker-files-raspbian.tar docker-files-raspbian
artifacts:
expire_in: 2w
paths:
- docker-files-raspbian.tar
build:raspios:
tags:
- hetzner-amd-beefy
stage: build
needs:
- job: build:prepare:raspios
artifacts: true
services:
- name: ${CI_DEPENDENCY_PROXY_DIRECT_GROUP_IMAGE_PREFIX}/docker:dind
alias: docker
variables:
CONTAINER_TAG: "raspios-bullseye"
before_script:
- *dind-login
script:
- echo "INFO - Building and Pushing ${CONTAINER_TAG}-${CI_PIPELINE_ID} to the registry ${CI_REGISTRY_IMAGE}"
- echo $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER $CI_REGISTRY --password-stdin
- tar -xvf docker-files-raspbian.tar
- docker build
--cache-from ${CI_REGISTRY_IMAGE}:${CONTAINER_TAG}-master
-t ${CI_REGISTRY_IMAGE}:${CONTAINER_TAG}-${CI_PIPELINE_ID}
--build-arg raspios_version=${RASPIOS_VERSION}
--push
docker-files-raspbian
# Upload to artifact storage left for backwards compatibility
- docker save ${CI_REGISTRY_IMAGE}:${CONTAINER_TAG}-${CI_PIPELINE_ID} > raspbianImage.tar
artifacts:
expire_in: 2w
paths:
- raspbianImage.tar
build:gui-e2e-testing:
tags:
- hetzner-amd-beefy
stage: build
needs: []
variables:
CONTAINER_TAG: "gui-e2e-testing"
services:
- name: ${CI_DEPENDENCY_PROXY_DIRECT_GROUP_IMAGE_PREFIX}/docker:dind
alias: docker
before_script:
- apk add --no-cache aws-cli curl
- eval "$(curl https://raw.githubusercontent.com/mendersoftware/mendertesting/master/mender-ci-common.sh)"
- *dind-login
script:
- echo "INFO - Building and Pushing ${CONTAINER_TAG} to the registry ${CI_REGISTRY_IMAGE}"
- echo $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER $CI_REGISTRY --password-stdin
- docker build
--cache-from ${CI_REGISTRY_IMAGE}:${CONTAINER_TAG}-master
-t ${CI_REGISTRY_IMAGE}:${CONTAINER_TAG}-${CI_PIPELINE_ID}
-f gui-e2e-testing/Dockerfile
--push
gui-e2e-testing
- docker save ${CI_REGISTRY_IMAGE}:${CONTAINER_TAG}-${CI_PIPELINE_ID} > guiE2eTestingImage.tar
# Upload to temporary S3 bucket left for backwards compatibility
- mender_ci_save_tmp_artifact guiE2eTestingImage.tar
artifacts:
paths:
- checksums
build:mender-client-acceptance-testing:
tags:
# KVM support requires the same type of GCP machine as the tests will use
- mender-qa-worker-client-acceptance-tests
stage: build
needs: []
variables:
CONTAINER_TAG: "mender-client-acceptance-testing"
services:
- name: ${CI_DEPENDENCY_PROXY_DIRECT_GROUP_IMAGE_PREFIX}/docker:dind
alias: docker
before_script:
- apk add --no-cache aws-cli curl
- eval "$(curl https://raw.githubusercontent.com/mendersoftware/mendertesting/master/mender-ci-common.sh)"
script:
- echo "INFO - Building and Pushing ${CONTAINER_TAG} to the registry ${CI_REGISTRY_IMAGE}"
- echo $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER $CI_REGISTRY --password-stdin
- docker build
--cache-from ${CI_REGISTRY_IMAGE}:${CONTAINER_TAG}-master
-t ${CI_REGISTRY_IMAGE}:${CONTAINER_TAG}-${CI_PIPELINE_ID}
-f mender-client-acceptance-testing/Dockerfile
--push
mender-client-acceptance-testing
- docker save ${CI_REGISTRY_IMAGE}:${CONTAINER_TAG}-${CI_PIPELINE_ID} > qaTestingImage.tar
# Upload to temporary S3 bucket
- mender_ci_save_tmp_artifact qaTestingImage.tar
artifacts:
paths:
- checksums
build:aws-k8s-pipeline-toolbox:
tags:
- hetzner-amd-beefy
stage: build
image: ${CI_DEPENDENCY_PROXY_DIRECT_GROUP_IMAGE_PREFIX}/docker
needs: []
variables:
CONTAINER_TAG: "aws-k8s-v1"
CI_KUBECTL_VERSION: "1.24.0"
CI_HELM_VERSION: "v3.12.0"
CI_KUBECONFORM_VERSION: "0.6.3"
services:
- name: ${CI_DEPENDENCY_PROXY_DIRECT_GROUP_IMAGE_PREFIX}/docker:dind
alias: docker
before_script:
- *dind-login
script:
- echo "INFO - Building and Pushing ${CONTAINER_TAG}-${CI_PIPELINE_ID} to the registry ${CI_REGISTRY_IMAGE}"
- echo $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER $CI_REGISTRY --password-stdin
- docker build
--cache-from ${CI_REGISTRY_IMAGE}:${CONTAINER_TAG}-master
-t ${CI_REGISTRY_IMAGE}:${CONTAINER_TAG}-${CI_PIPELINE_ID}
--build-arg KUBECTL_VERSION=${CI_KUBECTL_VERSION}
--build-arg HELM_VERSION=${CI_HELM_VERSION}
--build-arg KUBECONFORM_VERSION=${CI_KUBECONFORM_VERSION}
-f aws-k8s-toolbox/Dockerfile
--push
aws-k8s-toolbox
.build:mender-dist-packages-image:
tags:
- hetzner-amd-beefy-privileged
stage: build
needs: []
image: ${CI_DEPENDENCY_PROXY_DIRECT_GROUP_IMAGE_PREFIX}/docker:git
services:
- name: ${CI_DEPENDENCY_PROXY_DIRECT_GROUP_IMAGE_PREFIX}/docker:dind
alias: docker
before_script:
- *dind-login
script:
- apk add bash
- CONTAINER_TAG=mender-dist-packages-builder-${BUILD}-${DISTRO}-${RELEASE}-${ARCH}
- echo "INFO - Building and Pushing ${CONTAINER_TAG}-${CI_PIPELINE_ID} to the registry ${CI_REGISTRY_IMAGE}"
- echo $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER $CI_REGISTRY --password-stdin
- cd mender-dist-packages-building
- ./build.sh
--container-tag ${CI_REGISTRY_IMAGE}:${CONTAINER_TAG}
--distro ${DISTRO}
--release ${RELEASE}
--arch ${ARCH}
--ci-pipeline-id ${CI_PIPELINE_ID}
parallel: !reference [.mender-dist-packages-image-matrix, parallel]
build:mender-dist-packages-image:
rules:
- if: $CI_COMMIT_BRANCH == "master"
extends: .build:mender-dist-packages-image
build:mender-dist-packages-image:manual:
when: manual
extends: .build:mender-dist-packages-image
build:docker-multiplatform-buildx:
tags:
- hetzner-amd-beefy
stage: build
image: ${CI_DEPENDENCY_PROXY_DIRECT_GROUP_IMAGE_PREFIX}/docker
needs: []
variables:
CONTAINER_TAG: "docker-multiplatform-buildx-v1"
services:
- name: ${CI_DEPENDENCY_PROXY_DIRECT_GROUP_IMAGE_PREFIX}/docker:dind
alias: docker
before_script:
- *dind-login
script:
- echo "INFO - Building and Pushing ${CONTAINER_TAG}-${CI_PIPELINE_ID} to the registry ${CI_REGISTRY_IMAGE}"
- echo $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER $CI_REGISTRY --password-stdin
- docker build
--cache-from ${CI_REGISTRY_IMAGE}:${CONTAINER_TAG}-master
-t ${CI_REGISTRY_IMAGE}:${CONTAINER_TAG}-${CI_PIPELINE_ID}
-f docker-multiplatform-buildx/Dockerfile
--push
docker-multiplatform-buildx
build:goveralls:
tags:
- hetzner-amd-beefy
stage: build
image: ${CI_DEPENDENCY_PROXY_DIRECT_GROUP_IMAGE_PREFIX}/docker
needs: []
variables:
CONTAINER_TAG: "goveralls"
services:
- name: ${CI_DEPENDENCY_PROXY_DIRECT_GROUP_IMAGE_PREFIX}/docker:dind
alias: docker
before_script:
- *dind-login
script:
- echo "INFO - Building and Pushing ${CONTAINER_TAG}-${CI_PIPELINE_ID} to the registry ${CI_REGISTRY_IMAGE}"
- echo $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER $CI_REGISTRY --password-stdin
- docker build
--cache-from ${CI_REGISTRY_IMAGE}:${CONTAINER_TAG}-master
-t ${CI_REGISTRY_IMAGE}:${CONTAINER_TAG}-${CI_PIPELINE_ID}
-f goveralls/Dockerfile
--push
goveralls
build:mongodb-backup-runner:
tags:
- hetzner-amd-beefy
stage: build
image: ${CI_DEPENDENCY_PROXY_DIRECT_GROUP_IMAGE_PREFIX}/docker
needs: []
variables:
CONTAINER_TAG: "mongodb-backup-runner"
services:
- name: ${CI_DEPENDENCY_PROXY_DIRECT_GROUP_IMAGE_PREFIX}/docker:dind
alias: docker
before_script:
- *dind-login
script:
- echo "INFO - Building and Pushing ${CONTAINER_TAG}-${CI_PIPELINE_ID} to the registry ${CI_REGISTRY_IMAGE}"
- echo $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER $CI_REGISTRY --password-stdin
- docker build
--cache-from ${CI_REGISTRY_IMAGE}:${CONTAINER_TAG}-master
-t ${CI_REGISTRY_IMAGE}:${CONTAINER_TAG}-${CI_PIPELINE_ID}
-f mongodb-backup-runner/Dockerfile
--push
mongodb-backup-runner
build:terragrunt-trivy-toolbox:
tags:
- hetzner-amd-beefy
stage: build
image: ${CI_DEPENDENCY_PROXY_DIRECT_GROUP_IMAGE_PREFIX}/docker
needs: []
variables:
CONTAINER_TAG: "terragrunt-trivy-v1"
services:
- name: ${CI_DEPENDENCY_PROXY_DIRECT_GROUP_IMAGE_PREFIX}/docker:dind
alias: docker
before_script:
- *dind-login
script:
- echo "INFO - Building and Pushing ${CONTAINER_TAG}-${CI_PIPELINE_ID} to the registry ${CI_REGISTRY_IMAGE}"
- echo $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER $CI_REGISTRY --password-stdin
- docker build
--cache-from ${CI_REGISTRY_IMAGE}:${CONTAINER_TAG}-master
-t ${CI_REGISTRY_IMAGE}:${CONTAINER_TAG}-${CI_PIPELINE_ID}
-f terragrunt-trivy-toolbox/Dockerfile
--push
terragrunt-trivy-toolbox
build:release-please:
tags:
- hetzner-amd-beefy
stage: build
image: ${CI_DEPENDENCY_PROXY_DIRECT_GROUP_IMAGE_PREFIX}/docker
needs: []
variables:
CONTAINER_TAG: "release-please-v1"
services:
- name: ${CI_DEPENDENCY_PROXY_DIRECT_GROUP_IMAGE_PREFIX}/docker:dind
alias: docker
before_script:
- *dind-login
- echo $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER $CI_REGISTRY --password-stdin
- docker context create builder
- docker buildx create builder --use --driver-opt network=host --buildkitd-flags '--debug --allow-insecure-entitlement network.host'
script:
- echo "INFO - Building and Pushing ${CONTAINER_TAG}-${CI_PIPELINE_ID} to the registry ${CI_REGISTRY_IMAGE}"
- apk add --no-cache git
- cd release-please
- docker buildx build
--cache-to type=registry,ref=${CI_REGISTRY_IMAGE}:${CONTAINER_TAG}_ci_cache,mode=max
--cache-from type=registry,ref=${CI_REGISTRY_IMAGE}:${CONTAINER_TAG}_ci_cache
--tag ${CI_REGISTRY_IMAGE}:${CONTAINER_TAG}-${CI_PIPELINE_ID}
--file ${DOCKER_DIR:-.}/${DOCKERFILE:-Dockerfile}
--provenance false
--push
${DOCKER_DIR:-.}
.template:publish:
tags:
- hetzner-amd-beefy
stage: publish
services:
- name: ${CI_DEPENDENCY_PROXY_DIRECT_GROUP_IMAGE_PREFIX}/docker:dind
alias: docker
rules:
- if: $CI_COMMIT_BRANCH == "master"
before_script:
- echo -n $DOCKER_HUB_PASSWORD | docker login -u $DOCKER_HUB_USERNAME --password-stdin
- echo $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER $CI_REGISTRY --password-stdin
publish:raspios-bullseye:
extends: .template:publish
needs:
- job: build:raspios
artifacts: true
variables:
CONTAINER_TAG: "raspios-bullseye"
script:
# backward compatibility: pushing to the Docker Hub
- echo "publishing image to Docker Hub"
- docker load -i raspbianImage.tar
- docker tag ${CI_REGISTRY_IMAGE}:${CONTAINER_TAG}-${CI_PIPELINE_ID} $DOCKER_REPOSITORY:$CONTAINER_TAG
- docker push $DOCKER_REPOSITORY:$CONTAINER_TAG
# Gitlab registry
- *tag_n_push_to_gitlab_registry
publish:gui-e2e-testing:
extends: .template:publish
needs:
- job: build:gui-e2e-testing
artifacts: true
variables:
CONTAINER_TAG: "gui-e2e-testing"
script:
# backward compatibility: pushing to the Docker Hub
- apk add --no-cache aws-cli curl
- eval "$(curl https://raw.githubusercontent.com/mendersoftware/mendertesting/master/mender-ci-common.sh)"
# Fetch from temporary S3 bucket
- mender_ci_load_tmp_artifact guiE2eTestingImage.tar
- echo "publishing image to Docker Hub"
- docker load -i guiE2eTestingImage.tar
- docker tag ${CI_REGISTRY_IMAGE}:${CONTAINER_TAG}-${CI_PIPELINE_ID} $DOCKER_REPOSITORY:$CONTAINER_TAG
- docker push $DOCKER_REPOSITORY:$CONTAINER_TAG
# Gitlab registry
- *tag_n_push_to_gitlab_registry
publish:mender-client-acceptance-testing:
extends: .template:publish
needs:
- job: build:mender-client-acceptance-testing
artifacts: true
variables:
CONTAINER_TAG: "mender-client-acceptance-testing"
script:
# backward compatibility: pushing to the Docker Hub
- apk add --no-cache aws-cli curl
- eval "$(curl https://raw.githubusercontent.com/mendersoftware/mendertesting/master/mender-ci-common.sh)"
# Fetch from temporary S3 bucket
- mender_ci_load_tmp_artifact qaTestingImage.tar
- echo "publishing image to Docker Hub"
- docker load -i qaTestingImage.tar
- docker tag ${CI_REGISTRY_IMAGE}:${CONTAINER_TAG}-${CI_PIPELINE_ID} $DOCKER_REPOSITORY:$CONTAINER_TAG
- docker push $DOCKER_REPOSITORY:$CONTAINER_TAG
# Gitlab registry
- *tag_n_push_to_gitlab_registry
publish:aws-k8s-pipeline-toolbox:
extends: .template:publish
needs:
- job: build:aws-k8s-pipeline-toolbox
artifacts: true
variables:
CONTAINER_TAG: "aws-k8s-v1"
script:
- *tag_n_push_to_gitlab_registry
publish:docker-multiplatform-buildx:
extends: .template:publish
needs:
- job: build:docker-multiplatform-buildx
artifacts: true
variables:
CONTAINER_TAG: "docker-multiplatform-buildx-v1"
script:
- *tag_n_push_to_gitlab_registry
publish:mender-dist-packages-image:
extends: .template:publish
dependencies:
# NOTE: We should depend on each of the jobs individually with:
# - "build:mender-dist-packages-image: [${BUILD}, ${DISTRO}, ${RELEASE}, ${ARCH}]"
# However GitLab does not seem to expand these variables on a dependencies
# key. Use arbitrary one of them and assume that they all passed (using
# depends instead of needs ensures that the whole previous build stage
# needs to pass, so it should be safe).
- "build:mender-dist-packages-image: [crosscompile, debian, bullseye, amd64]"
rules:
- if: $CI_COMMIT_BRANCH == "master"
script:
- CONTAINER_TAG=mender-dist-packages-builder-${BUILD}-${DISTRO}-${RELEASE}-${ARCH}
- *tag_n_push_to_gitlab_registry
parallel: !reference [.mender-dist-packages-image-matrix, parallel]
publish:goveralls:
extends: .template:publish
needs:
- job: build:goveralls
artifacts: true
variables:
CONTAINER_TAG: "goveralls"
script:
- *tag_n_push_to_gitlab_registry
publish:mongodb-backup-runner:
extends: .template:publish
needs:
- job: build:mongodb-backup-runner
artifacts: true
variables:
CONTAINER_TAG: "mongodb-backup-runner"
script:
- *tag_n_push_to_gitlab_registry
publish:terragrunt-trivy-toolbox:
extends: .template:publish
needs:
- job: build:aws-k8s-pipeline-toolbox
artifacts: true
variables:
CONTAINER_TAG: "terragrunt-trivy-v1"
script:
- *tag_n_push_to_gitlab_registry
publish:release-please:
extends: .template:publish
needs:
- job: build:release-please
artifacts: true
variables:
CONTAINER_TAG: "release-please-v1"
script:
- *tag_n_push_to_gitlab_registry