Debian Codegraph @

.gitlab-ci/ci.template

raw
1 # vim: set expandtab shiftwidth=2 tabstop=8 textwidth=0 filetype=yaml:
2
3 {# You're looking at the template here, so you can ignore the below
4 warning. This is the right file to edit #}
5 #######################################
6 # #
7 # THIS FILE IS GENERATED, DO NOT EDIT #
8 # #
9 #######################################
10
11 # To change the gitlab CI, edit .gitlab-ci/ci.template and/or .gitlab-ci/config.yml
12 # and run ci-fairy generate-template. For details, see
13 # https://freedesktop.pages.freedesktop.org/ci-templates/ci-fairy.html#templating-gitlab-ci-yml
14
15 .templates_sha: &template_sha ef5e4669b7500834a17ffe9277e15fbb6d977fff
16
17 include:
18 {% for distro in distributions|sort(attribute="name")|unique(attribute="name") %}
19 # {{ distro.name.capitalize() }} container builder template
20 - project: 'freedesktop/ci-templates'
21 ref: *template_sha
22 file: '/templates/{{distro.name}}.yml'
23 {% endfor %}
24 - project: 'freedesktop/ci-templates'
25 ref: *template_sha
26 file: '/templates/ci-fairy.yml'
27 - local: '.gitlab-ci/other.yml'
28
29 stages:
30 - sanity check
31 - prep
32 - build
33 - test
34 - distro
35 - deploy
36 - container_clean
37
38 variables:
39 FDO_UPSTREAM_REPO: fontconfig/fontconfig
40 GIT_DEPTH: 1
41
42 # these tags should be updated each time the list of packages is updated
43 # changing these will force rebuilding the associated image
44 # Note: these tags have no meaning and are not tied to a particular
45 # fontconfig version
46 {% for distro in distributions|unique(attribute="name") %}
47 {{"%-15s"| format(distro.name.upper() + '_TAG:')}}'{{distro.tag}}-{{
48 (ci_fairy.hashfiles('.gitlab-ci/config.yml',
49 '.gitlab-ci/' + distro.name + '-install.sh',
50 'build-aux/fetch-testfonts.py'))[0:12]
51 }}'
52 {% endfor %}
53
54 {% for distro in distributions|unique(attribute="name") %}
55 {{"%-15s"| format(distro.name.upper() + '_EXEC:')}}'bash .gitlab-ci/{{distro.name}}-install.sh'
56 {% endfor %}
57
58 #######################################
59 # #
60 # sanity check #
61 # #
62 #######################################
63
64 fail-if-fork-is-not-public:
65 stage: sanity check
66 script:
67 - |
68 if [ $CI_PROJECT_VISIBILITY != "public" ]; then
69 echo "*************************************************************************************"
70 echo "Project visibility must be set to 'public'."
71 echo "Change this in $CI_PROJECT_URL/edit under 'Visibility, project features, permissions'"
72 echo "*************************************************************************************"
73 exit 1
74 fi
75 except:
76 - main@fontconfig/fontconfig
77
78 check-ci-script:
79 extends:
80 - .fdo.ci-fairy
81 stage: sanity check
82 script:
83 - ci-fairy generate-template --verify && exit 0 || true
84 - >
85 printf "%s\n" \
86 "Committed gitlab-ci.yml differs from generated gitlab-ci.yml." \
87 "To change the gitlab CI, edit .gitlab-ci/ci.template and/or .gitlab-ci/config.yml" \
88 " and run ci-fairy generate-template. For details, see " \
89 "https://freedesktop.pages.freedesktop.org/ci-templates/ci-fairy.html#templating-gitlab-ci-yml"
90 - exit 1
91
92 #######################################
93 # #
94 # containers stage #
95 # #
96 #######################################
97
98 # Build a container for each distribution + version. The ci-templates
99 # will re-use the containers if the tag doesn't change.
100 {% for distro in distributions|unique(attribute="name") %}
101 {% for version in distro.versions %}
102
103 {{distro.name}}:{{version}}@container-prep:
104 {% if distro.qemu_based %}
105 extends: .fdo.qemu-build@{{distro.name}}
106 {% else %}
107 extends: .fdo.container-build@{{distro.name}}
108 {% endif %}
109 {% if distro.qemu_based %}
110 tags:
111 - kvm
112 {% endif %}
113 stage: prep
114 variables:
115 GIT_STRATEGY: none
116 FDO_DISTRIBUTION_VERSION: '{{version}}'
117 FDO_DISTRIBUTION_PACKAGES: '{{' '.join(packages[distro.name].needed)}}'
118 FDO_DISTRIBUTION_TAG: ${{distro.name.upper()}}_TAG
119 FDO_DISTRIBUTION_EXEC: ${{distro.name.upper()}}_EXEC
120 {% endfor %}
121 {% endfor %}
122
123 #######################################
124 # #
125 # container clean stage #
126 # #
127 #######################################
128
129 #
130 # This stage will look for the container images e currently have in
131 # the registry and will remove any that are not tagged with the provided
132 # $container_image:$tag
133 #
134 # This job only runs for a scheduled pipeline.
135 #
136 # Go to your Profile, Settings, Access Tokens
137 # Create a personal token with `api' scope, copy the value.
138 # Go to CI/CD, Schedules, schedule a monthly job.
139 # Define a variable of type File named AUTHFILE. Content is that token
140 # value.
141 .container-clean:
142 stage: container_clean
143 image: golang:alpine
144 before_script:
145 - apk add python3 py-pip git
146 - pip3 install git+http://gitlab.freedesktop.org/freedesktop/ci-templates
147 script:
148 - ci-fairy -v --authfile $AUTHFILE delete-image
149 --repository $FDO_DISTRIBUTION_NAME/$FDO_DISTRIBUTION_VERSION
150 --exclude-tag $FDO_DISTRIBUTION_TAG
151 dependencies: []
152 allow_failure: true
153 only:
154 - schedules
155
156 {% for distro in distributions|unique(attribute="name") %}
157 {% for version in distro.versions %}
158 {{distro.name}}:{{version}}@container-clean:
159 extends:
160 - .container-clean
161 variables:
162 GIT_STRATEGY: none
163 CURRENT_CONTAINER_IMAGE: $CI_REGISTRY_IMAGE/{{distro.name}}/$FDO_DISTRIBUTION_VERSION:$FDO_DISTRIBUTION_TAG
164 FDO_DISTRIBUTION_VERSION: '{{version}}'
165 FDO_DISTRIBUTION_TAG: ${{distro.name.upper()}}_TAG
166
167 {% endfor %}
168 {% endfor %}
169
170 #######################################
171 # #
172 # build template #
173 # #
174 #######################################
175
176 .check_tainted: &check_tainted |
177 # make sure the kernel is not tainted
178 if [[ "$(ssh localhost -p 5555 cat /proc/sys/kernel/tainted)" -gt 0 ]];
179 then
180 echo tainted kernel ;
181 exit 1 ;
182 fi
183
184 .build-in-qemu@template:
185 tags:
186 - kvm
187 script:
188 - /app/vmctl start || (echo "Error - Failed to start the VM." && exit 1)
189
190 - *check_tainted
191
192 - export BUILD_ID="fontconfig-$CI_JOB_NAME_$CI_COMMIT_SHA-$CI_JOB_ID"
193 - export PREFIX="$(pwd)/prefix-$BUILD_ID"
194 - export BUILDDIR="$(pwd)/build-$BUILD_ID"
195 - export MAKEFLAGS="-j4"
196 - |
197 buildopt=()
198 for bo in $FC_BUILD_ENABLED; do
199 buildopt+=(-e $bo)
200 done
201 for bo in $FC_BUILD_DISABLED; do
202 buildopt+=(-d $bo)
203 done
204 [ -n "$FC_BUILD_ARCH" ] && buildopt+=(-a $FC_BUILD_ARCH)
205 [ $FC_BUILD_DISTCHECK -eq 1 ] && buildopt+=(-c)
206 [ $FC_BUILD_NO_INSTALL -eq 1 ] && buildopt+=(-I)
207 [ $FC_BUILD_NO_CHECK -eq 1 ] && buildopt+=(-C)
208 buildopt+=(-s $FC_BUILDSYS)
209 buildopt+=(-t $FC_BUILD_TYPE)
210 buildopt+=(-X $FC_XML_BACKEND)
211 export buildopt
212 - "scp -r $(pwd) vm:"
213 - echo "CI_JOB_ID=\"$CI_JOB_ID\"" > fcenv
214 - echo "CI_JOB_NAME=\"$CI_JOB_NAME\"" >> fcenv
215 - echo "BUILD_ID=\"$BUILD_ID\"" >> fcenv
216 - echo "MAKEFLAGS=\"$MAKEFLAGS\"" >> fcenv
217 - echo "MAKE=\"$MAKE\"" >> fcenv
218 - "scp fcenv vm:~/$CI_PROJECT_NAME/.gitlab-ci/fcenv"
219 - /app/vmctl exec "cd $CI_PROJECT_NAME ; bash .gitlab-ci/build.sh ${buildopt[@]}" && touch .success || true
220 - scp -r vm:$CI_PROJECT_NAME/build $BUILDDIR
221
222 - *check_tainted
223
224 - /app/vmctl stop
225 - if [[ ! -e .success ]];
226 then
227 exit 1 ;
228 fi
229 variables:
230 FC_BUILDSYS: autotools
231 FC_XML_BACKEND: expat
232 FC_BUILD_TYPE: both
233 FC_BUILD_DISTCHECK: 0
234 FC_BUILD_NO_INSTALL: 0
235 FC_BUILD_NO_CHECK: 0
236
237 .build@template:
238 script:
239 - export BUILD_ID="fontconfig-$CI_JOB_NAME_$CI_COMMIT_SHA-$CI_JOB_ID"
240 - export PREFIX="$(pwd)/prefix-$BUILD_ID"
241 - export BUILDDIR="$(pwd)/build-$BUILD_ID"
242 - export MAKEFLAGS="-j4"
243 - |
244 buildopt=()
245 for bo in $FC_BUILD_ENABLED; do
246 buildopt+=(-e $bo)
247 done
248 for bo in $FC_BUILD_DISABLED; do
249 buildopt+=(-d $bo)
250 done
251 [ -n "$FC_BUILD_ARCH" ] && buildopt+=(-a $FC_BUILD_ARCH)
252 [ $FC_BUILD_DISTCHECK -eq 1 ] && buildopt+=(-c)
253 [ $FC_BUILD_NO_INSTALL -eq 1 ] && buildopt+=(-I)
254 [ $FC_BUILD_NO_CHECK -eq 1 ] && buildopt+=(-C)
255 [ $FC_BUILD_SUBPROJECT -eq 1 ] && buildopt+=(-S)
256 buildopt+=(-s $FC_BUILDSYS)
257 buildopt+=(-t $FC_BUILD_TYPE)
258 buildopt+=(-X $FC_XML_BACKEND)
259 sh .gitlab-ci/build.sh ${buildopt[@]}
260 variables:
261 FC_BUILDSYS: autotools
262 FC_XML_BACKEND: expat
263 FC_BUILD_TYPE: both
264 FC_BUILD_DISTCHECK: 0
265 FC_BUILD_NO_INSTALL: 0
266 FC_BUILD_NO_CHECK: 0
267 FC_BUILD_SUBPROJECT: 0
268
269 .fc_artifacts:
270 artifacts:
271 name: fontconfig-$CI_COMMIT_SHA-$CI_JOB_ID
272 when: always
273 expire_in: 5 days
274 paths:
275 - build*/doc/fontconfig-user.html
276 - build*/doc/fontconfig-devel.html
277 - build*/fc-build.log
278 - build*/config.log
279 - build*/fontconfig-*.tar.*
280 - build*/test/*log
281 - build*/fontconfig*/_build
282 - build*/meson-logs/*
283 - build*/meson-dist/*
284 - prefix*
285
286 .upload:
287 rules:
288 - if: $CI_COMMIT_TAG
289 variables:
290 PACKAGE_REGISTRY_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/fontconfig/${CI_COMMIT_TAG}"
291 script:
292 - |
293 for f in $(pwd)/build-fontconfig-$CI_JOB_NAME_$CI_COMMIT_SHA-*/meson-dist/*; do
294 curl --location --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file $f ${PACKAGE_REGISTRY_URL}/$(basename $f)
295 done
296
297 #######################################
298 # #
299 # build stage #
300 # #
301 #######################################
302
303 {% for build in build_patterns %}
304 build-{{build.name}}:
305 stage: build
306 extends:
307 - .build@template
308 - .fdo.distribution-image@fedora
309 - .fc_artifacts
310 variables:
311 FC_DISTRO_NAME: fedora
312 FDO_DISTRIBUTION_VERSION: rawhide
313 FDO_DISTRIBUTION_TAG: $FEDORA_TAG
314 {# Where we have extra_variables defined, add them to the list #}
315 {% if build.variables is defined %}
316 {% for key, value in build.variables.items() %}
317 {{key}}: {{value}}
318 {% endfor %}
319 {% endif %}
320 needs:
321 - fedora:rawhide@container-prep
322 {% endfor %}
323
324 #######################################
325 # #
326 # test #
327 # #
328 #######################################
329
330 .test_hook@template:
331 script:
332 - export PREFIX="$(echo $(pwd)/prefix-*)"
333 - |
334 if [ -n "$FC_TEST_EXEC" -a -f ".gitlab-ci/test-${FC_TEST_EXEC}.sh" ]; then
335 sh ".gitlab-ci/test-${FC_TEST_EXEC}.sh"
336 else
337 echo "*** No test script found"
338 exit 1
339 fi
340 variables:
341 FC_TEST_EXEC: ""
342
343 clang-format:
344 stage: test
345 extends:
346 - .fdo.distribution-image@fedora
347 variables:
348 FDO_DISTRIBUTION_VERSION: 'rawhide'
349 FDO_DISTRIBUTION_TAG: $FEDORA_TAG
350 needs:
351 - 'fedora:rawhide@container-prep'
352 script:
353 - |
354 commit="${CI_MERGE_REQUEST_TARGET_BRANCH_SHA:-${CI_MERGE_REQUEST_DIFF_BASE_SHA:?}}" || exit
355 echo sh .gitlab-ci/check-style.sh "$commit"
356 sh .gitlab-ci/check-style.sh "$commit"
357 rules:
358 - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
359
360 {% for test in test_patterns %}
361 {{test.name}}:
362 stage: test
363 extends:
364 {% if 'parent' in test %}
365 - .test_hook@template
366 {% else %}
367 - .build@template
368 {% endif %}
369 - .fdo.distribution-image@fedora
370 - .fc_artifacts
371 variables:
372 FC_DISTRO_NAME: fedora
373 FDO_DISTRIBUTION_VERSION: rawhide
374 FDO_DISTRIBUTION_TAG: $FEDORA_TAG
375 FC_TEST_EXEC: {{test.name}}
376 {# Where we have extra_variables defined, add them to the list #}
377 {% if test.variables is defined %}
378 {% for key, value in test.variables.items() %}
379 {{key}}: {{value}}
380 {% endfor %}
381 {% endif %}
382 needs:
383 - fedora:rawhide@container-prep
384 {% if 'parent' in test %}
385 - build-{{test.parent}}
386 {% endif %}
387 {% endfor %}
388
389 #######################################
390 # #
391 # distro stage #
392 # #
393 #######################################
394
395 {% for distro in distributions %}
396 {% for version in distro.versions %}
397 {% for build in distro.builds %}
398
399 {% if not 'build_only' in build or build.build_only == version %}
400 t_{{distro.name}}:{{version}}:{{build.name}}:
401 stage: distro
402 extends:
403 {% if distro.qemu_based %}
404 - .build-in-qemu@template
405 {% else %}
406 - .build@template
407 {% endif %}
408 - .fdo.distribution-image@{{distro.name}}
409 - .fc_artifacts
410 variables:
411 FC_DISTRO_NAME: {{distro.name}}
412 FDO_DISTRIBUTION_VERSION: '{{version}}'
413 FDO_DISTRIBUTION_TAG: ${{distro.name.upper()}}_TAG
414 {# Where we have extra_variables defined, add them to the list #}
415 {% if build.variables is defined %}
416 {% for key, value in build.variables.items() %}
417 {{key}}: {{value}}
418 {% endfor %}
419 {% endif %}
420 needs:
421 - '{{distro.name}}:{{version}}@container-prep'
422 {% endif %}
423
424 {% endfor %}
425 {% endfor %}
426 {% endfor %}
427
428 #######################################
429 # #
430 # deploy stage #
431 # #
432 #######################################
433
434 check-merge-request:
435 extends:
436 - .fdo.ci-fairy
437 stage: deploy
438 script:
439 - ci-fairy check-merge-request --require-allow-collaboration --junit-xml=results.xml
440 artifacts:
441 when: on_failure
442 reports:
443 junit: results.xml
444 allow_failure: true
445 rules:
446 - if: $CI_PIPELINE_SOURCE == "merge_request_event"
447
448 {% for distro in distributions %}
449 {% for version in distro.versions %}
450 {% for build in distro.builds %}
451 {% if 'upload' in build and build.upload == version %}
452 upload_asset:
453 stage: deploy
454 needs:
455 - t_{{distro.name}}:{{version}}:{{build.name}}
456 extends:
457 - .fdo.distribution-image@{{distro.name}}
458 - .upload
459 variables:
460 FDO_DISTRIBUTION_VERSION: '{{version}}'
461 FDO_DISTRIBUTION_TAG: ${{distro.name.upper()}}_TAG
462 {% endif %}
463 {% if 'doc' in build and build.doc == version %}
464 pages:
465 stage: deploy
466 needs:
467 - t_{{distro.name}}:{{version}}:{{build.name}}
468 dependencies:
469 - t_{{distro.name}}:{{version}}:{{build.name}}
470 script:
471 - |
472 mkdir public || :
473 cp -a build*/doc/fontconfig-user.html build*/doc/fontconfig-devel.html public/
474 artifacts:
475 paths:
476 - public
477 rules:
478 - if: $CI_COMMIT_BRANCH == "main" && $CI_PIPELINE_SOURCE != "merge_request_event"
479 {% endif %}
480 {% endfor %}
481 {% endfor %}
482 {% endfor %}
483
484 make-release:
485 stage: deploy
486 image: registry.gitlab.com/gitlab-org/cli:latest
487 rules:
488 - if: $CI_COMMIT_TAG
489 variables:
490 PACKAGE_REGISTRY_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/fontconfig/${CI_COMMIT_TAG}"
491 script:
492 - glab auth login -h ${CI_SERVER_HOST} -j ${CI_JOB_TOKEN}
493 - |
494 glab changelog generate -v ${CI_COMMIT_TAG} > changelog-${CI_COMMIT_TAG}.md
495 glab release create ${CI_COMMIT_TAG} --name "Release ${CI_COMMIT_TAG}" -F changelog-${CI_COMMIT_TAG}.md -a "[{\"name\": \"fontconfig-${CI_COMMIT_TAG}.tar.xz\", \"url\": \"${PACKAGE_REGISTRY_URL}/fontconfig-${CI_COMMIT_TAG}.tar.xz\"}, {\"name\": \"fontconfig-${CI_COMMIT_TAG}.tar.xz (sha256sum)\", \"url\": \"${PACKAGE_REGISTRY_URL}/fontconfig-${CI_COMMIT_TAG}.tar.xz.sha256sum\"}]"
496
497 workflow:
498 rules:
499 - if: $CI_COMMIT_TAG
500 - if: $CI_PIPELINE_SOURCE == "merge_request_event"
501 - if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS
502 when: never
503 - if: $CI_COMMIT_BRANCH