-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
376 lines (342 loc) · 12.8 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
# SPDX-License-Identifier: MIT
# Copyright (C) 2022-2023 iris-GmbH infrared & intelligent sensors
# TODO: implement needs:parallel:matrix once feature is stable: https://docs.gitlab.com/ee/ci/yaml/index.html#needsparallelmatrix
# TODO: use GitLab CI variables for defining parallism, once supported: https://gitlab.com/gitlab-org/gitlab/-/issues/11549
#####################
### INCLUDE FILES ###
#####################
include:
- ".gitlab/common-template.yml"
- ".gitlab/release-template.yml"
- ".gitlab/develop-template.yml"
###############################
### CI VARIABLE DEFINITIONS ###
###############################
variables:
BUILD_IMAGE_TAG: "latest"
RELEASE_BRANCH: "master"
BUILD_IMAGE_IRIS_KAS: "${CI_REGISTRY_IMAGE}:${BUILD_IMAGE_TAG}"
RENOVATE_PLATFORM: "gitlab"
RENOVATE_ENDPOINT: "${CI_API_V4_URL}"
RENOVATE_REPOSITORIES: "[ \"${CI_PROJECT_PATH}\" ]"
RENOVATE_REVIEWERS: "[ \"jasper.orschulko\", \"rico.biedermann\", \"thomas.noack\", \"parian.golchin\", \"an.tran\", \"michael.kirscht\", \"jan.hannig\", \"erik.schumacher\", \"paul.gieseler\" ]"
RENOVATE_PR_CONCURRENT_LIMIT: "0"
RENOVATE_PR_HOURLY_LIMIT: "0"
# Set extra flags for the renovate bot
RENOVATE_EXTRA_FLAGS: ""
FORCE_RENOVATE_RUN: "false"
RENOVATE_DRY_RUN: "false"
KAS_RUNNER_TAG: "kas-large"
USE_IDENTICAL_NAMED_BRANCHES:
value: "true"
description: 'Set to "true" to use identical named branches in iris meta layers during build'
REPRODUCIBLE_BUILD:
value: "false"
description: 'Set to "true" to archive build artifacts required for making the firmware build reproducible. WARNING: We can only guarantee reproducibility for changes done to protected branches!'
SKIP_OCI_TESTS:
value: "false"
description: 'Set to "true" to skip the OCI tests.'
SKIP_PTEST_TESTS:
value: "true"
description: 'Set to "false" to run the PTEST tests.'
SKIP_MAINTENANCE_IMAGE_BUILD:
value: "false"
description: 'Set to "true" to skip the maintenance image build'
SKIP_DEPLOY_IMAGE_BUILD:
value: "true"
description: 'Set to "false" to build the deploy image'
SKIP_DEV_IMAGE_BUILD:
value: "true"
description: 'Set to "false" to build the dev image'
SKIP_SDK_IMAGE_BUILD:
value: "true"
description: 'Set to "false" to build the Yocto SDK'
FORCE_IRIS_KAS_CONTAINER_BUILD:
value: "false"
description: 'Set to "true" to force (re-)build the iris-kas build container on the current branch.'
SKIP_SYSTEMTEST_SMOKE:
value: "true"
description: 'Set to "false" to add execution of systemtest_smoke job. Skipping system smoke test will also skip any additional Systemtests.'
SKIP_SYSTEMTEST_RELIABILITY:
value: "true"
description: 'Set to "false" to add execution of systemtest_reliability job.'
BUILD_FROM_SCRATCH:
value: "false"
description: 'Set to "true" to build from scratch.'
BUILD_TARGETS:
value: ""
description: 'Specify one or more products you want to build as a space separated string. Currently supported products: irma6r2, irma6r1, matrix. If left empty, all available products will be built.'
################
### WORKFLOW ###
################
workflow:
rules:
# Do not run merge pipeline on draft MRs
- if: '$CI_MERGE_REQUEST_TITLE =~ /^Draft:/'
when: never
# Allow scheduled builds
- if: '$CI_PIPELINE_SOURCE == "schedule"'
# Allow manually triggering a build from the webinterface
- if: '$CI_PIPELINE_SOURCE == "web"'
# Allow triggering from upstream pipeline
- if: '$CI_PIPELINE_SOURCE == "pipeline"'
# Automatic build on merge request/changes to merge request
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
# Trigger an automatic build if a new, valid tag is pushed.
# examples for valid tags:
# irma6r1-1.0-1, irma6r2-1.0-1-RC1, irma6r2-1.0-1-support_release
- if: '$CI_COMMIT_TAG && $CI_COMMIT_TAG =~ /^(?<product_identifier>irma6r[1-2])-(?<major>\d+)\.(?<minor>\d+)-(?<feature_version>\d+)(-(?<support_release_suffix>\w+))?$/'
# allow building the latest iris-kas container image if required
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_PIPELINE_SOURCE == "push"'
changes:
- Dockerfile_iris_kas
# automatically start pipeline for CI branches (-ci / _ci suffix)
- if: '$CI_COMMIT_BRANCH =~ /^.*(_|-)ci$/'
########################
### DEFAULT SETTINGS ###
########################
default:
tags:
# run on gitlab runners designed for kas builds
- kas
image:
name: "${BUILD_IMAGE_IRIS_KAS}"
pull_policy:
- always
retry:
max: 2
when:
- unknown_failure
- api_failure
- stuck_or_timeout_failure
- runner_system_failure
- job_execution_timeout
- scheduler_failure
- data_integrity_failure
before_script:
# configure git safe directory
- if command -v git >/dev/null 2>&1; then git config --global --add safe.directory "${CI_PROJECT_DIR}"; fi
# if called from upstream pipeline, attempt to checkout identical named branch in iris-kas
- |
if [ -n "${UPSTREAM_PROJECT_NAME}" ] && [ "${RELEASE}" != "true" ] && command -v git >/dev/null 2>&1; then
echo "Trying to checkout ${BRANCH_NAME} in iris-kas"
if git checkout ${BRANCH_NAME} 2>/dev/null; then
echo "Branch ${BRANCH_NAME} has been checked out in iris-kas"
else
echo "Branch ${BRANCH_NAME} not found in iris-kas. Sticking with develop branch on iris-kas"
fi
fi
##############
### STAGES ###
##############
stages:
- setup
- build-container
- generate-pipeline
- trigger-generated-pipeline
###################
### SETUP STAGE ###
###################
renovate:
stage: setup
rules:
- !reference [.develop_template, rules]
- if: '$CI_PIPELINE_SOURCE == "schedule"'
- if: $FORCE_RENOVATE_RUN == "true"
image: renovate/renovate:39.20.3-full
tags:
- gp
script:
- renovate ${RENOVATE_EXTRA_FLAGS}
allow_failure: true
# We do not want to run a pipeline on merges to non-default branch.
# During a release process (merge target branch master), we are interested in the release candidate builds, not the merge request
# builds, as the development and release pipelines work fundamentally different.
# However, since a merge request is blocked regardless of branch, as long as no pipeline is run, we need a empty placeholder
# job for the pipeline to "turn green".
skip-non-default-branch-merge-pipeline:
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $RELEASE_BRANCH'
stage: setup
variables:
GIT_STRATEGY: none
tags:
- gp-tiny
script:
- echo "Running empty pipeline on merge request targeting release branch ${RELEASE_BRANCH}"
build-container-get-tag:
rules:
- !reference [.common_template, rules, build_container_rules]
stage: setup
tags:
- gp-tiny
image: busybox:1.37.0-uclibc
script:
# Default branch = latest tag
# Release = release tag
# All other branches are tagged with the currently built commit SHA hash
- |
if [[ "$CI_COMMIT_BRANCH" == "$CI_DEFAULT_BRANCH" ]]; then
BUILD_IMAGE_TAG="latest"
elif [[ -n "$CI_COMMIT_TAG" ]]; then
BUILD_IMAGE_TAG="$CI_COMMIT_TAG"
else
BUILD_IMAGE_TAG="git-${CI_COMMIT_SHORT_SHA}"
fi
- echo "BUILD_IMAGE_TAG set to ${BUILD_IMAGE_TAG}."
- echo "BUILD_IMAGE_TAG=${BUILD_IMAGE_TAG}" >> build.env
artifacts:
reports:
dotenv: build.env
###################################
### BUILD BUILD CONTAINER STAGE ###
###################################
build-iris-kas-container:
stage: build-container
needs:
- job: build-container-get-tag
rules:
- !reference [.common_template, rules, build_container_rules]
parallel:
matrix:
- TAG: gp
ARCH: amd64
- TAG: gp-arm
ARCH: arm64
tags:
- ${TAG}
image: gcr.io/kaniko-project/executor:v1.23.2-debug
script:
- >-
/kaniko/executor
--context "${CI_PROJECT_DIR}"
--dockerfile "${CI_PROJECT_DIR}/Dockerfile_iris_kas"
--destination "${BUILD_IMAGE_IRIS_KAS}-${ARCH}"
--tar-path "iris-kas-container-${ARCH}.tar"
artifacts:
name: "iris-kas-container-${ARCH}"
paths:
- "iris-kas-container-*"
expire_in: "7 days"
merge-container-manifests:
stage: build-container
needs:
- job: build-container-get-tag
- job: build-iris-kas-container
tags:
- gp-tiny
rules:
- !reference [.common_template, rules, build_container_rules]
variables:
GIT_STRATEGY: none
image: mplatform/manifest-tool:alpine-v2.0.6
script:
- >-
manifest-tool
--username=${CI_REGISTRY_USER}
--password=${CI_REGISTRY_PASSWORD}
push from-args
--platforms linux/amd64,linux/arm64
--template ${BUILD_IMAGE_IRIS_KAS}-ARCH
--target ${BUILD_IMAGE_IRIS_KAS}
###############################
### GENERATE PIPELINE STAGE ###
###############################
.generate-pipeline:
stage: generate-pipeline
tags:
- gp-tiny
image: mikefarah/yq:4.44.5
artifacts:
paths:
- .gitlab/build-ci-template.yml
release-generate-pipeline:
extends: .generate-pipeline
rules:
- !reference [.release_template, rules]
script:
- >
if [[ "${CI_COMMIT_TAG}" =~ ^irma6r1-.* ]]; then
yq -i '.".target_multi_confs".MULTI_CONF = ["sc573-gen6"]' .gitlab/build-ci-template.yml
yq -i '.".oci_multi_confs".MULTI_CONF = ["qemux86-64-r1"]' .gitlab/build-ci-template.yml
yq -i '.".all_multi_confs".MULTI_CONF = ["sc573-gen6", "qemux86-64-r1"]' .gitlab/build-ci-template.yml
elif [[ "${CI_COMMIT_TAG}" =~ ^irma6r2-.* ]]; then
yq -i '.".target_multi_confs".MULTI_CONF = ["imx8mp-irma6r2"]' .gitlab/build-ci-template.yml
yq -i '.".oci_multi_confs".MULTI_CONF = ["qemux86-64-r2"]' .gitlab/build-ci-template.yml
yq -i '.".all_multi_confs".MULTI_CONF = ["imx8mp-irma6r2", "qemux86-64-r2"]' .gitlab/build-ci-template.yml
else
echo "No valid multi-conf tag prefix was given"
exit 1
fi
- echo "Generated child pipeline:"
- cat .gitlab/build-ci-template.yml
develop-generate-pipeline:
extends: .generate-pipeline
rules:
- !reference [.develop_template, rules]
- when: on_success
script:
# if BUILD_TARGETS is defined then don't use default multi_confs
- >
if test -n "${BUILD_TARGETS}"; then
yq -i '.".target_multi_confs".MULTI_CONF = []' .gitlab/build-ci-template.yml
yq -i '.".oci_multi_confs".MULTI_CONF = []' .gitlab/build-ci-template.yml
yq -i '.".all_multi_confs".MULTI_CONF = []' .gitlab/build-ci-template.yml
fi
- >
case "${BUILD_TARGETS}" in
*irma6r1*)
yq -i '.".target_multi_confs".MULTI_CONF += ["sc573-gen6"]' .gitlab/build-ci-template.yml;
yq -i '.".oci_multi_confs".MULTI_CONF += ["qemux86-64-r1"]' .gitlab/build-ci-template.yml;
yq -i '.".all_multi_confs".MULTI_CONF += ["sc573-gen6", "qemux86-64-r1"]' .gitlab/build-ci-template.yml;
esac
- >
case "${BUILD_TARGETS}" in
*irma6r2*)
yq -i '.".target_multi_confs".MULTI_CONF += ["imx8mp-irma6r2"]' .gitlab/build-ci-template.yml;
yq -i '.".oci_multi_confs".MULTI_CONF += ["qemux86-64-r2"]' .gitlab/build-ci-template.yml;
yq -i '.".all_multi_confs".MULTI_CONF += ["imx8mp-irma6r2", "qemux86-64-r2"]' .gitlab/build-ci-template.yml;
esac
- >
case "${BUILD_TARGETS}" in
*matrix*)
yq -i '.".target_multi_confs".MULTI_CONF += ["imx93-evk"]' .gitlab/build-ci-template.yml;
yq -i '.".target_multi_confs".MULTI_CONF += ["imx93-matrixup"]' .gitlab/build-ci-template.yml;
yq -i '.".oci_multi_confs".MULTI_CONF += ["qemux86-64-matrix"]' .gitlab/build-ci-template.yml;
yq -i '.".all_multi_confs".MULTI_CONF += ["imx93-evk", "imx93-matrixup", "qemux86-64-matrix"]' .gitlab/build-ci-template.yml;
esac
- echo "Generated child pipeline:"
- cat .gitlab/build-ci-template.yml
########################################
### TRIGGER GENERATED PIPELINE STAGE ###
########################################
.trigger-generated-pipeline:
stage: trigger-generated-pipeline
trigger:
include:
- artifact: .gitlab/build-ci-template.yml
job: release-generate-pipeline
- artifact: .gitlab/build-ci-template.yml
job: develop-generate-pipeline
strategy: depend
release-trigger-generated-pipeline:
extends: .trigger-generated-pipeline
rules:
- !reference [.release_template, rules]
trigger:
include:
- artifact: .gitlab/build-ci-template.yml
job: release-generate-pipeline
strategy: depend
develop-trigger-generated-pipeline:
extends: .trigger-generated-pipeline
rules:
- !reference [.develop_template, rules]
- when: on_success
trigger:
include:
- artifact: .gitlab/build-ci-template.yml
job: develop-generate-pipeline
strategy: depend
forward:
pipeline_variables: true