forked from mendersoftware/gui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
527 lines (491 loc) · 16.1 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
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
image: node:22-alpine
stages:
- pre-test
- test
- build
- e2e-test
- publish
- version-bump
variables:
DOCKER_REPOSITORY: mendersoftware/gui
DOCS_VERSION: development
MULTIPLATFORM_BUILD: 'true'
MULTIPLATFORM_PLATFORMS: 'linux/amd64,linux/arm64'
include:
- project: 'Northern.tech/Mender/mendertesting'
file: '.gitlab-ci-check-commits.yml'
- project: 'Northern.tech/Mender/mendertesting'
file: '.gitlab-ci-check-docker-build.yml'
- project: 'Northern.tech/Mender/mendertesting'
file: '.gitlab-ci-github-status-updates.yml'
- project: 'Northern.tech/Mender/mender-qa'
file: 'gitlab-pipeline/internal-variables.yml'
.export_docker_vars: &export_docker_vars |
DOCKER_BUILD_TAG=${CI_COMMIT_REF_SLUG:-local}
DOCKER_BUILD_SERVICE_IMAGE=${DOCKER_REPOSITORY}:${DOCKER_BUILD_TAG}
DOCKER_PUBLISH_TAG=${CI_COMMIT_REF_NAME}
DOCKER_PUBLISH_COMMIT_TAG=${CI_COMMIT_REF_NAME}_${CI_COMMIT_SHA}
test:lint:
stage: test
rules:
- if: $CI_COMMIT_REF_NAME !~ /^(staging|saas-[a-zA-Z0-9.]+)$/
needs: []
cache:
key:
files:
- package-lock.json
paths:
- .npm/
script:
- npm ci --cache .npm --prefer-offline
- cd tests/e2e_tests && npm ci && cd ../..
- npm run lint
tags:
- mender-qa-worker-generic-light
test:types:
stage: test
image: python:3.11
needs: []
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
when: always
- when: manual
before_script:
# Prepare SSH key
- eval $(ssh-agent -s)
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- ssh-keyscan github.com >> ~/.ssh/known_hosts
# Configure git
- git config --global user.email "mender@northern.tech"
- git config --global user.name "Mender Test Bot"
# install hub cli + deno + release tool dependency
- apt-get update && apt-get install hub -qqy
- curl -fsSL https://deno.land/x/install/install.sh | sh && export PATH="/root/.deno/bin:$PATH"
- wget https://raw.githubusercontent.com/mendersoftware/integration/master/extra/requirements.txt
- pip3 install -r requirements.txt
# get enterprise api specs from all the repos, based on mender-api-docs tooling
- export GITHUB_TOKEN=${GITHUB_BOT_TOKEN_REPO_FULL}
- cd scripts
- 'wget --header "Authorization: token $GITHUB_TOKEN" https://raw.githubusercontent.com/mendersoftware/mender-api-docs/master/versions.template.js'
- cd typeGeneration
- 'wget --header "Authorization: token $GITHUB_TOKEN" https://raw.githubusercontent.com/mendersoftware/mender-api-docs/master/specs/download.sh'
- chmod +x ./download.sh && TARGET=specs ./download.sh
script:
- deno run --allow-read --allow-write --allow-net convert.js
- deno fmt generated/models
- mkdir -p ../../src/js/api/types && mv -f generated/models/* ../../src/js/api/types
- cd ../..
- git checkout -b update-types-$(date +%s)
- 'git add src/js/api/types && git commit --signoff -m "chore: Types update"'
- git remote add mendersoftware git@github.com:mendersoftware/gui.git
- 'hub pull-request --push --base mendersoftware:master --message "chore: Types update" --message "keeping types aligned"'
allow_failure: true
artifacts:
expire_in: 2w
paths:
- scripts/typeGeneration
- src/js/api/types
test:licenses:
image: denoland/deno:alpine-1.38.0
stage: test
rules:
- if: $CI_COMMIT_REF_NAME !~ /^(staging|saas-[a-zA-Z0-9.]+)$/
needs: []
cache:
key:
files:
- package-lock.json
paths:
- .npm/
before_script:
- apk add --no-cache nodejs npm
- npm ci
script:
- deno run --allow-env --allow-read --allow-sys tests/licenses/licenseCheck.ts
tags:
- mender-qa-worker-generic-light
.template:test:acceptance:
stage: e2e-test
image: tiangolo/docker-with-compose
needs:
- job: build:docker-multiplatform
artifacts: true
services:
- docker:dind
before_script:
- apk add --no-cache bash git jq wget
- git clone --no-tags --depth=1 --single-branch https://github.com/mendersoftware/integration.git
- docker pull ${CI_REGISTRY_IMAGE}:${CI_PIPELINE_ID}
- docker tag ${CI_REGISTRY_IMAGE}:${CI_PIPELINE_ID} ${DOCKER_REPOSITORY}:pr
artifacts:
expire_in: 2w
paths:
- coverage
- screenshots
- logs
- junit
reports:
junit:
- junit/results.xml
when: always
test:acceptance:
extends: .template:test:acceptance
rules:
- if: $CI_COMMIT_REF_NAME !~ /^(staging|saas-[a-zA-Z0-9.]+)$/
script:
- GUI_REPOSITORY=$(pwd) INTEGRATION_PATH=$(pwd)/integration ./tests/e2e_tests/run
- docker rmi $DOCKER_REPOSITORY:pr
test:acceptance:enterprise:
extends: .template:test:acceptance
rules:
- if: $CI_COMMIT_BRANCH == "master"
variables:
TEST_ENVIRONMENT: enterprise
script:
- if [ -n "$REGISTRY_MENDER_IO_USERNAME" ]; then
- docker login -u $REGISTRY_MENDER_IO_USERNAME -p $REGISTRY_MENDER_IO_PASSWORD registry.mender.io
- fi
- GUI_REPOSITORY=$(pwd) INTEGRATION_PATH=$(pwd)/integration ./tests/e2e_tests/run --enterprise
- docker rmi $DOCKER_REPOSITORY:pr
test:acceptance:unprivileged:
extends: .template:test:acceptance
rules:
- if: $CI_COMMIT_BRANCH == "master"
before_script:
- apk add --no-cache bash git jq wget
- git clone --no-tags --depth=1 --single-branch https://github.com/mendersoftware/integration.git
- docker pull ${CI_REGISTRY_IMAGE}:${CI_PIPELINE_ID}-unprivileged
- docker tag ${CI_REGISTRY_IMAGE}:${CI_PIPELINE_ID}-unprivileged ${DOCKER_REPOSITORY}:pr
script:
- GUI_REPOSITORY=$(pwd) INTEGRATION_PATH=$(pwd)/integration ./tests/e2e_tests/run --unprivileged
- docker rmi $DOCKER_REPOSITORY:pr
test:acceptance:enterprise-unprivileged:
extends: .template:test:acceptance
rules:
- if: $CI_COMMIT_BRANCH == "master"
variables:
TEST_ENVIRONMENT: enterprise
before_script:
- apk add --no-cache bash git jq wget
- git clone --no-tags --depth=1 --single-branch https://github.com/mendersoftware/integration.git
- docker pull ${CI_REGISTRY_IMAGE}:${CI_PIPELINE_ID}-unprivileged
- docker tag ${CI_REGISTRY_IMAGE}:${CI_PIPELINE_ID}-unprivileged ${DOCKER_REPOSITORY}:pr
script:
- if [ -n "$REGISTRY_MENDER_IO_USERNAME" ]; then
- docker login -u $REGISTRY_MENDER_IO_USERNAME -p $REGISTRY_MENDER_IO_PASSWORD registry.mender.io
- fi
- GUI_REPOSITORY=$(pwd) INTEGRATION_PATH=$(pwd)/integration ./tests/e2e_tests/run --enterprise --unprivileged
- docker rmi $DOCKER_REPOSITORY:pr
test:unit:
stage: test
rules:
- if: $CI_COMMIT_REF_NAME !~ /^(staging|saas-[a-zA-Z0-9.]+)$/
needs: []
cache:
key:
files:
- package-lock.json
paths:
- .npm/
script:
- npm i -g npm
- npm ci --cache .npm --prefer-offline
- npm run test -- --ci --maxWorkers=2 --reporters=default --reporters=jest-junit
after_script:
- mkdir logs && cp .npm/_logs/* logs/
artifacts:
expire_in: 2w
paths:
- coverage
- logs
reports:
junit: junit.xml
when: always
tags:
- mender-qa-worker-gui-tests
test:docs-links:
stage: test
needs: []
except:
- /^(staging|saas-[a-zA-Z0-9.]+)$/
before_script:
- apk add --no-cache curl
script:
- links=$(grep -r docs.mender.io src/ | grep -v snapshots | sed -e 's,\${docsVersion},'${DOCS_VERSION}'/,g' | sed -e 's,\${path},''/,g' | egrep -o 'https?://[^ `"]+' | sort | uniq)
- error=0
- for url in $links; do
- if ! curl --output /dev/null --silent --head --fail $url; then
- error=1
- echo "[ko] $url"
- else
- echo "[ok] $url"
- fi
- done
- if [ $error -gt 0 ]; then
- exit 1
- fi
tags:
- mender-qa-worker-generic-light
test:docs-links:hosted:
extends: test:docs-links
only:
- /^(staging|saas-[a-zA-Z0-9.]+)$/
except: []
variables:
DOCS_VERSION: hosted
test:prep:
stage: pre-test
image: docker
rules:
- if: $CI_COMMIT_BRANCH == "staging"
services:
- docker:dind
script:
- docker run --rm --entrypoint "/bin/sh" -v $(pwd):/extract mendersoftware/mender-stress-test-client:master -c "cp mender-stress-test-client /extract/"
artifacts:
paths:
- mender-stress-test-client
expire_in: 30 days
tags:
- mender-qa-worker-generic-light
# excludes non multiplatform build job
build:docker:
rules:
- when: never
build:docker-multiplatform:
# by default alvaldi-gui uses the unprivileged mode
script:
- if [[ ! $CI_COMMIT_REF_NAME =~ "(main|master|staging|production|feature-.+|\d+\.\d+\..+)" ]]; then
- export MULTIPLATFORM_PLATFORMS='linux/amd64'
- fi
- echo "building ${CI_PROJECT_NAME} for ${DOCKER_BUILD_SERVICE_IMAGE}"
- docker context create builder
- docker buildx create builder --use --driver-opt network=host --buildkitd-flags '--debug --allow-insecure-entitlement network.host'
# needed for the license generation step
- docker buildx build
--tag ${DOCKER_REPOSITORY}:base
--target base
--output type=docker,dest=baseImage.tar
${DOCKER_DIR:-.}
# build production target
- docker buildx build
--cache-to type=registry,ref=${CI_REGISTRY_IMAGE}:ci_cache,mode=max
--cache-from type=registry,ref=${CI_REGISTRY_IMAGE}:ci_cache
--tag ${CI_REGISTRY_IMAGE}:${CI_PIPELINE_ID}
--file ${DOCKER_DIR:-.}/${DOCKERFILE:-Dockerfile}
--build-arg GIT_COMMIT_TAG="${DOCKER_PUBLISH_COMMIT_TAG}"
--platform $MULTIPLATFORM_PLATFORMS
--provenance false
--target production
--push
${DOCKER_DIR:-.}
# build unprivileged target
- docker buildx build
--cache-to type=registry,ref=${CI_REGISTRY_IMAGE}:ci_cache,mode=max
--cache-from type=registry,ref=${CI_REGISTRY_IMAGE}:ci_cache
--tag ${CI_REGISTRY_IMAGE}:${CI_PIPELINE_ID}-unprivileged
--file ${DOCKER_DIR:-.}/${DOCKERFILE:-Dockerfile}
--build-arg GIT_COMMIT_TAG="${DOCKER_PUBLISH_COMMIT_TAG}"
--platform $MULTIPLATFORM_PLATFORMS
--provenance false
--target unprivileged
--push
${DOCKER_DIR:-.}
artifacts:
paths:
- baseImage.tar
.template:test:staging-deployment:
image: mendersoftware/mender-test-containers:gui-e2e-testing
stage: .post
services:
- docker:dind
cache:
key:
files:
- tests/e2e_tests/package-lock.json
paths:
- .npm/
dependencies:
- test:prep
variables:
CI: 1
DEVICE_TYPE: qemux86-64
TEST_ENVIRONMENT: staging
before_script:
- curl -fsSL https://get.docker.com | sh
- mv mender-stress-test-client tests/e2e_tests/ && cd tests/e2e_tests
- mv /e2e/mender-demo-artifact.mender .
- docker pull mendersoftware/mender-client-docker-addons:mender-3.6.x
- npm ci --cache .npm --prefer-offline
script:
- npm run test-ci
after_script:
- cd $CI_PROJECT_DIR
- mkdir logs && cp /root/.npm/_logs/* logs/
only:
- staging
when: delayed
start_in: 15 minutes
artifacts:
expire_in: 2w
paths:
- tests/e2e_tests/test-results
- logs
when: always
tags:
- mender-qa-worker-generic-light
test:staging-deployment:chrome:
extends: .template:test:staging-deployment
script:
- npm run test-ci
test:staging-deployment:firefox:
extends: .template:test:staging-deployment
script:
- npm run test-ci -- --browser=firefox
test:staging-deployment:webkit:
extends: .template:test:staging-deployment
script:
- npm run test-ci -- --browser=webkit
.template:publish:tests:
stage: publish
before_script:
- export CI_BUILD_REF=${CI_COMMIT_SHA}
- export CI_BUILD_REF_NAME=${CI_COMMIT_REF_NAME}
- export CI_MERGE_REQUEST_IID=${CI_COMMIT_BRANCH#pr_}
- export COVERALLS_PARALLEL=true
- export COVERALLS_SERVICE_JOB_ID=${CI_JOB_ID}
- export COVERALLS_SERVICE_NUMBER=${CI_PIPELINE_ID}
- apk add --no-cache git
- npm i -g coveralls
tags:
- mender-qa-worker-generic-light
publish:tests:
extends: .template:publish:tests
rules:
- if: $CI_COMMIT_REF_NAME !~ /^(staging|saas-[a-zA-Z0-9.]+)$/
needs:
- test:unit
script:
- export COVERALLS_SERVICE_JOB_NUMBER=unittests
- export COVERALLS_FLAG_NAME=unittests
- coveralls < coverage/lcov.info
publish:e2e-tests:
extends: .template:publish:tests
rules:
- if: $CI_COMMIT_BRANCH == "master"
needs:
- test:acceptance:enterprise
script:
- export COVERALLS_SERVICE_JOB_NUMBER=e2etests
- export COVERALLS_FLAG_NAME=e2etests
- sed -i -re 's/(^[SF:]+[../]+)(.*)$/SF:\2/' coverage/lcov.info
- coveralls < coverage/lcov.info
publish:disclaimer:
stage: publish
image: docker:git
needs:
- job: build:docker-multiplatform
artifacts: true
services:
- docker:dind
variables:
DOCKER_BUILDKIT: 1
script:
- docker load -i baseImage.tar
- docker build -t disclaimer --target disclaim .
- docker run --rm --entrypoint "/bin/sh" -v $(pwd):/extract disclaimer -c "cp disclaimer.txt /extract/"
- docker image rm disclaimer
artifacts:
expire_in: 2w
paths:
- disclaimer.txt
rules:
- if: $CI_COMMIT_REF_NAME =~ /^(master|staging|[0-9]+\.[0-9]+\.x)$/
tags:
- mender-qa-worker-generic-light
# excludes non multiplatform build job
publish:image:
rules:
- when: never
# excludes non multiplatform job
publish:image:saas:
rules:
- when: never
# excludes non multiplatform job
publish:image:mender:
rules:
- when: never
publish:image-multiplatform:unprivileged:
extends: publish:image-multiplatform
variables:
GITLAB_REGISTRY_TAG: '${CI_REGISTRY_IMAGE}:${CI_PIPELINE_ID}-unprivileged'
before_script:
- !reference [publish:image:saas, before_script]
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- *export_docker_vars
- DOCKER_PUBLISH_COMMIT_TAG=${CI_COMMIT_REF_NAME}-unprivileged_${CI_COMMIT_SHA}
- DOCKER_PUBLISH_TAG=${CI_COMMIT_REF_NAME}-unprivileged
- SERVICE_IMAGE=${DOCKER_REPOSITORY}:${DOCKER_PUBLISH_TAG}
publish:image-multiplatform:mender-unprivileged:
extends: publish:image-multiplatform:mender
variables:
GITLAB_REGISTRY_TAG: '${CI_REGISTRY_IMAGE}:${CI_PIPELINE_ID}-unprivileged'
script:
# Publish the image for all releases
- for version in $integration_versions; do
- regctl image copy ${GITLAB_REGISTRY_TAG} ${DOCKER_REPOSITORY}:mender-${version}-unprivileged
- regctl image copy ${GITLAB_REGISTRY_TAG} ${DOCKER_REPOSITORY}:mender-${version}-unprivileged_${CI_COMMIT_SHA}
- done
- echo "PUBLISH_IMAGE_DIGEST=${DOCKER_REPOSITORY}@$(regctl image digest ${DOCKER_REPOSITORY}:mender-${version}-unprivileged)" >> publish.env
publish:image-multiplatform:saas-unprivileged:
extends: publish:image-multiplatform:saas
before_script:
- !reference [publish:image:saas, before_script]
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- *export_docker_vars
- DOCKER_PUBLISH_TAG=${CI_COMMIT_REF_NAME}-unprivileged
- SERVICE_IMAGE=${DOCKER_REPOSITORY}:${DOCKER_PUBLISH_TAG}
coveralls:done:
image: curlimages/curl
stage: .post
script:
- curl "https://coveralls.io/webhook?repo_token=$COVERALLS_REPO_TOKEN" -d "payload[build_num]=$CI_PIPELINE_ID&payload[status]=done"
tags:
- mender-qa-worker-generic-light
#
# Mender Helm Rolling release
#
.trigger:mender-helm-version-bump:
stage: version-bump
allow_failure: true
trigger:
project: Northern.tech/Mender/mender-helm
strategy: depend
resource_group: mender-helm
variables:
SYNC_CONTAINER_NAME: $CONTAINER_NAME
SYNC_IMAGE_TAG: $DOCKER_PUBLISH_COMMIT_TAG
CONTAINER: gui
DOCKER_PUBLISH_COMMIT_TAG: ${CI_COMMIT_REF_NAME}_${CI_COMMIT_SHA}
GITHUB_HELM_REPO: 'github.com/mendersoftware/mender-helm.git'
CHART_DIR: 'mender'
trigger:mender-helm-version-bump:staging:
extends:
- .trigger:mender-helm-version-bump
rules:
- if: $CI_COMMIT_BRANCH =~ /^(staging)$/
variables:
SYNC_ENVIRONMENT: staging
HELM_PATCH_VERSION: ${CI_PIPELINE_ID}-staging # pre-release version for trigger staging only deploy
trigger:mender-helm-version-bump:prod:
extends:
- .trigger:mender-helm-version-bump
rules:
- if: '$CI_COMMIT_TAG =~ /^saas-[a-zA-Z0-9.]+$/'
when: manual
variables:
SYNC_ENVIRONMENT: prod
HELM_PATCH_VERSION: ${CI_PIPELINE_ID}
DOCKER_PUBLISH_COMMIT_TAG: ${CI_COMMIT_REF_NAME}