1 # vim: set expandtab shiftwidth=2 tabstop=8 textwidth=0 filetype=yaml:
3 {# You're looking at the template here, so you can ignore the below
4 warning. This is the right file to edit #}
5 ########################################
7 # THIS FILE IS GENERATED, DO NOT EDIT #
9 ########################################
11 # To change the gitlab CI, edit .gitlab-ci/ci.template and/or .gitlab-ci/config.yaml
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
15 # This is a bit complicated for two reasons:
16 # - we really want to run dnf/apt/... only once, updating on the test runner for
17 # each job takes forever. So we create a container image for each distribution
18 # tested, then run the tests on this container image.
20 # This is handled by the ci-templates, ensuring containers are only rebuilt
21 # when the TAG changes.
23 # - GitLab only allows one script: set per job but we have a bunch of commands
24 # we need to re-run for each build (meson && ninja && etc). YAML cannot merge
25 # arrays so we're screwed.
27 # So instead we use a default_build template and override everything with
28 # variables. The only two variables that matter:
29 # MESON_ARGS=-Denable-something=true
30 # NINJA_ARGS=dist ... to run 'ninja -C builddir dist'
31 # Note that you cannot use scripts: in any target if you expect default_build
35 # All jobs must follow the naming scheme of
36 # <distribution>:<version>@activity:
37 # e.g. fedora:31@build-default
39 .templates_sha: &template_sha 0c312d9c7255f46e741d43bcd1930f09cd12efe7
42 - project: 'freedesktop/ci-templates'
45 - '/templates/ci-fairy.yml'
46 {% for distro in distributions|sort(attribute="name") %}
47 # {{ distro.name.capitalize() }} container builder template
48 - '/templates/{{distro.name}}.yml'
52 - sanity check # CI/commit checks
53 - prep # prep work like rebuilding the container images if there is a change
54 - build # for actually building and testing things in a container
55 - test-suite # for running the test suite in a VM
56 - test-suite-no-libwacom # for running the test suite in a VM (libwacom disabled)
57 - valgrind # for running the test suite under valgrind in a VM
58 - distro # distribs test
59 - deploy # trigger wayland's website generation
60 - container_clean # clean up unused container images (scheduled jobs only)
63 ###############################################################################
64 # This is the list of packages required to build libinput with the default #
67 # Run dnf install/apt-get install/.. with the list of packages for your #
70 # See the documentation here: #
71 # https://wayland.freedesktop.org/libinput/doc/latest/building_libinput.html #
72 ###############################################################################
73 {% for distro in distributions %}
74 {{"%-17s" | format(distro.name.upper() + '_PACKAGES:')}} '{{ distro.packages|join(' ')}}'
76 ############################ end of package lists #############################
78 # these tags should be updated each time the list of packages is updated
79 # changing these will force rebuilding the associated image
80 # Note: these tags have no meaning and are not tied to a particular
82 {% for distro in distributions %}
83 {{"%-13s"| format(distro.name.upper() + '_TAG:')}}'{{distro.tag}}'
85 {% for distro in distributions %}
86 {% if distro.want_qemu %}
87 {{"%-20s"| format(distro.name.upper() + '_QEMU_TAG:')}} '{{distro.name}}-qemu-vm-{{distro.tag}}'
91 FDO_UPSTREAM_REPO: libinput/libinput
93 MESON_BUILDDIR: "build dir"
96 MESON_TEST_ARGS: '--no-suite=hardware'
98 # udev isn't available/working properly in the containers
106 - runner_system_failure
107 - stuck_or_timeout_failure
108 # cancel run when a newer version is pushed to the branch
114 name: "meson-logs-$CI_JOB_NAME"
118 - $MESON_BUILDDIR/meson-logs
120 junit: $MESON_BUILDDIR/*junit*.xml
123 #################################################################
125 # sanity check stage #
127 #################################################################
129 fail-if-fork-is-not-public:
133 if [ $CI_PROJECT_VISIBILITY != "public" ]; then
134 echo "*************************************************************************************"
135 echo "Project visibility must be set to 'public'"
136 echo "Change this in $CI_PROJECT_URL/edit under 'Visibility, project features, permissions'"
137 echo "*************************************************************************************"
141 - main@libinput/libinput
143 # Re-generate the CI script and make sure it's the one currently checked in
144 # If this job fails, re-generate the gitlab-ci.yml script, see
145 # $SRCDIR/.gitlab-ci/generate-gitlab-ci.py
152 - ci-fairy generate-template --verify && exit 0 || true
155 "Committed gitlab-ci.yml differs from generated gitlab-ci.yml. Please verify" \
156 "https://wayland.freedesktop.org/libinput/doc/latest/contributing.html"
160 # Verify that commit messages are as expected, signed-off, etc.
168 - ci-fairy check-commits --signed-off-by --junit-xml=results.xml && exit 0 || true
171 "Error checking commit format. Please verify" \
172 "https://wayland.freedesktop.org/libinput/doc/latest/contributing.html"
175 - main@libinput/libinput
182 #################################################################
186 #################################################################
189 # Note: images are rebuilt weekly with a scheduled pipeline with FDO_FORCE_REBUILD set
192 {# qemu builds are only done for the latest version of any distribution #}
193 {% for distro in distributions if distro.want_qemu %}
194 {% set version = "{}".format(distro.versions|last()) %}
195 {{distro.name}}:{{version}}@qemu-prep:
197 - .fdo.qemu-build@{{distro.name}}
204 FDO_DISTRIBUTION_VERSION: "{{version}}"
205 FDO_DISTRIBUTION_TAG: ${{distro.name.upper()}}_QEMU_TAG
206 FDO_DISTRIBUTION_PACKAGES: ${{distro.name.upper()}}_PACKAGES
210 {% for distro in distributions %}
211 {% for version in distro.versions %}
212 {{distro.name}}:{{version}}@container-prep:
214 {% if distro.qemu_based %}
215 - .fdo.qemu-build@{{distro.name}}
217 - .fdo.container-build@{{distro.name}}
220 {% if distro.qemu_based %}
227 FDO_DISTRIBUTION_VERSION: '{{version}}'
228 FDO_DISTRIBUTION_PACKAGES: ${{distro.name.upper()}}_PACKAGES
229 FDO_DISTRIBUTION_TAG: ${{distro.name.upper()}}_TAG
235 #################################################################
237 # container clean stage #
238 # run during the clean stage #
240 #################################################################
243 # This stage will look for the container images we currently have in
244 # the registry and will remove any that are not tagged with the provided
245 # $container_image:$tag
251 stage: container_clean
253 # Go to your Profile, Settings, Access Tokens
254 # Create a personal token with 'api' scope, copy the value.
255 # Go to CI/CD, Schedules, schedule a new monthly job (or edit the existing one)
256 # Define a variable of type File named AUTHFILE. Content is that token
258 - ci-fairy -v --authfile $AUTHFILE delete-image
259 --repository $FDO_DISTRIBUTION_NAME/$FDO_DISTRIBUTION_VERSION
260 --exclude-tag $FDO_DISTRIBUTION_TAG
265 {% for distro in distributions %}
266 {% for version in distro.versions %}
267 {{distro.name}}:{{version}}@container-clean:
273 CURRENT_CONTAINER_IMAGE: $CI_REGISTRY_IMAGE/{{distro.name}}/$FDO_DISTRIBUTION_VERSION:$FDO_DISTRIBUTION_TAG
274 FDO_DISTRIBUTION_VERSION: '{{version}}'
275 FDO_DISTRIBUTION_TAG: ${{distro.name.upper()}}_TAG
280 #################################################################
284 #################################################################
292 - .gitlab-ci/meson-build.sh
298 .check_tainted: &check_tainted |
299 # make sure the kernel is not tainted
300 if [[ "$(ssh localhost -p 5555 cat /proc/sys/kernel/tainted)" -gt 0 ]];
302 echo tainted kernel ;
306 # Run meson and meson test in the qemu image
307 .build-in-qemu@template:
310 - .fdo.distribution-image@fedora
314 MESON_BUILDDIR: build_dir
316 # start our vm, no args required
317 - /app/vmctl start || (echo "Error - Failed to start the VM." && exit 1)
322 - echo "CI_JOB_ID=\"$CI_JOB_ID\"" > sshenv
323 - echo "CI_JOB_NAME=\"$CI_JOB_NAME\"" >> sshenv
324 - echo "MESON_ARGS=\"$MESON_ARGS\"" >> sshenv
325 - echo "MESON_BUILDDIR=\"$MESON_BUILDDIR\"" >> sshenv
326 - echo "MESON_TEST_ARGS=\"$MESON_TEST_ARGS\"" >> sshenv
327 - echo "NINJA_ARGS=\"$NINJA_ARGS\"" >> sshenv
328 - "scp sshenv vm:~/$CI_PROJECT_NAME/.meson_environment"
329 - /app/vmctl exec "cd $CI_PROJECT_NAME ; .gitlab-ci/meson-build.sh" && touch .success || true
330 # no matter the results of the tests, we want to fetch the logs
331 - scp -r vm:$CI_PROJECT_NAME/$MESON_BUILDDIR .
337 - if [[ ! -e .success ]] ;
342 name: "qemu-meson-logs-$CI_JOB_NAME"
346 - $MESON_BUILDDIR/meson-logs
349 junit: $MESON_BUILDDIR/*junit*.xml
352 # Run in a test suite. Special variables:
353 # - SUITES: the meson test suites to run, or
354 # - SUITE_NAMES: all elements will be expanded to libinput-test-suite-$value
355 # Set one or the other, not both.
358 - .build-in-qemu@template
361 # remove the global --no-suite=hardware
364 - if ! [[ -z $SUITE_NAMES ]]; then SUITES=$(echo $SUITE_NAMES | sed 's/\([^ ]*\)/libinput-test-suite-\1/g'); fi
365 - echo "Testing $SUITES"
366 - export MESON_TEST_ARGS="$MESON_TEST_ARGS $SUITES"
369 {# qemu tests are only done for the latest version of any distribution #}
370 {% for distro in distributions if distro.use_for_qemu_tests %}
371 {% set version = "{}".format(distro.versions|last()) %}
372 .{{distro.name}}:{{version}}@test-suite-vm:
376 FDO_DISTRIBUTION_VERSION: {{version}}
377 FDO_DISTRIBUTION_TAG: ${{distro.name.upper()}}_QEMU_TAG
379 - "{{distro.name}}:{{version}}@qemu-prep"
382 {% for suite in test_suites %}
385 - .{{distro.name}}:{{version}}@test-suite-vm
387 SUITE_NAMES: '{{suite.suites|join(' ')}}'
389 vm-{{suite.name}}-no-libwacom:
392 stage: test-suite-no-libwacom
394 MESON_ARGS: '-Dlibwacom=false'
398 {% for suite in test_suites %}
399 vm-valgrind-{{suite.name}}:
404 MESON_TEST_ARGS: '--setup=valgrind'
407 {% endfor %}{# for if distro.use_for_qemu_tests #}
409 {% for distro in distributions if distro.use_for_custom_build_tests %}
410 {% set version = "{}".format(distro.versions|last()) %}
411 .{{distro.name}}-build@template:
413 - .fdo.distribution-image@{{distro.name}}
416 FDO_DISTRIBUTION_VERSION: '{{version}}'
417 FDO_DISTRIBUTION_TAG: ${{distro.name.upper()}}_TAG
419 - "{{distro.name}}:{{version}}@container-prep"
421 default-build-release@{{distro.name}}:{{version}}:
424 - .{{distro.name}}-build@template
426 MESON_ARGS: "-Dbuildtype=release"
429 scan-build@{{distro.name}}:{{version}}:
431 - .{{distro.name}}-build@template
436 - dnf install -y clang-analyzer
438 - .gitlab-ci/meson-build.sh
439 - export SCANBUILD="$PWD/.gitlab-ci/scanbuild-wrapper.sh"
440 - ninja -C "$MESON_BUILDDIR" scan-build
442 - .gitlab-ci/scanbuild-plist-to-junit.py "$MESON_BUILDDIR"/meson-logs/scanbuild/ > "$MESON_BUILDDIR"/junit-scan-build.xml
444 # Below jobs are build option combinations. We only
445 # run them on one image, they shouldn't fail on one distro
446 # when they succeed on another.
448 build-no-libwacom@{{distro.name}}:{{version}}:
450 - .{{distro.name}}-build@template
452 MESON_ARGS: "-Dlibwacom=false"
454 build-no-libwacom-nodeps@{{distro.name}}:{{version}}:
456 - .{{distro.name}}-build@template
458 MESON_ARGS: "-Dlibwacom=false"
460 - dnf remove -y libwacom libwacom-devel
462 build-docs@{{distro.name}}:{{version}}:
464 - .{{distro.name}}-build@template
466 MESON_ARGS: "-Ddocumentation=true"
468 build-no-docs-nodeps@{{distro.name}}:{{version}}:
470 - .{{distro.name}}-build@template
472 MESON_ARGS: "-Ddocumentation=false"
474 - dnf remove -y doxygen graphviz
476 build-no-debuggui@{{distro.name}}:{{version}}:
478 - .{{distro.name}}-build@template
480 MESON_ARGS: "-Ddebug-gui=false"
482 build-no-debuggui-nodeps@{{distro.name}}:{{version}}:
484 - .{{distro.name}}-build@template
486 MESON_ARGS: "-Ddebug-gui=false"
488 - dnf remove -y gtk3-devel gtk4-devel
490 build-no-tests@{{distro.name}}:{{version}}:
492 - .{{distro.name}}-build@template
494 MESON_ARGS: "-Dtests=false"
496 build-no-tests-nodeps@{{distro.name}}:{{version}}:
498 - .{{distro.name}}-build@template
500 MESON_ARGS: "-Dtests=false"
502 - dnf remove -y check-devel
504 valgrind@{{distro.name}}:{{version}}:
506 - .{{distro.name}}-build@template
508 MESON_TEST_ARGS: '--suite=valgrind --no-suite=hardware --setup=valgrind'
510 - dnf install -y valgrind
512 # Python checks, only run on Fedora
514 usr-bin-env-python@{{distro.name}}:{{version}}:
516 - .{{distro.name}}-build@template
519 if git grep -l '^#!/usr/bin/python'; then
520 echo "Use '/usr/bin/env python3' in the above files";
524 python-format@{{distro.name}}:{{version}}:
526 - .{{distro.name}}-build@template
528 - dnf install -y black
530 - black $(git grep -l '^#!/usr/bin/env python3')
531 - git diff --exit-code || (echo "Please run Black against all Python files" && false)
533 # A job to check we're actually running all test suites in the CI
536 - .{{distro.name}}-build@template
541 - meson introspect builddir --test | jq -r '.[].name' | grep 'libinput-test-suite' | sort > meson-testsuites
543 cat <<EOF > ci-testsuites ;
544 {% for suite in test_suites %}
545 {% for name in suite.suites %}
546 libinput-test-suite-{{name}}
550 - sort -o ci-testsuites ci-testsuites
551 - diff -u8 -w ci-testsuites meson-testsuites || (echo "Some test suites are not run in the CI" && false)
561 # This requires the COVERITY_SCAN_TOKEN. Log into scan.coverity.com and get
562 # the token from the respective project settings page.
563 # Schedule a pipeline and set a variable COVERITY_SCAN_TOKEN with the token value.
564 # https://gitlab.freedesktop.org/$CI_PROJECT_PATH/-/pipeline_schedules
565 # Email from coverity will be sent to the GITLAB_USER_EMAIL that scheduled the
568 # Coverity ratelimits submissions and the coverity tools download is about
569 # 700M, do not run this too often.
573 - .fdo.distribution-image@debian
577 FDO_DISTRIBUTION_VERSION: 'stable'
578 FDO_DISTRIBUTION_TAG: $DEBIAN_TAG
579 # so git-describe works, or should work
583 - $COVERITY_SCAN_TOKEN
585 - curl https://scan.coverity.com/download/linux64
586 -o /tmp/cov-analysis-linux64.tgz
587 --form project=$CI_PROJECT_NAME
588 --form token=$COVERITY_SCAN_TOKEN
589 - tar xfz /tmp/cov-analysis-linux64.tgz
590 # coverity has special build options in meson, make sure we enable those
591 - meson coverity-build -Ddocumentation=false -Dcoverity=true
592 - cov-analysis-linux64-*/bin/cov-build --dir cov-int ninja -C coverity-build
593 - tar cfz cov-int.tar.gz cov-int
594 - curl https://scan.coverity.com/builds?project=$CI_PROJECT_NAME
595 --form token=$COVERITY_SCAN_TOKEN --form email=$GITLAB_USER_EMAIL
596 --form file=@cov-int.tar.gz --form version="$(git describe --tags)"
597 --form description="$(git describe --tags) / $CI_COMMIT_TITLE / $CI_COMMIT_REF_NAME:$CI_PIPELINE_ID"
599 name: "coverity-submit-data"
605 - "debian:stable@container-prep"
607 #################################################################
611 #################################################################
613 {% for distro in distributions %}
614 {% if not distro.qemu_based %}
615 {% for version in distro.versions %}
616 {{distro.name}}:{{version}}@default-build:
620 - .fdo.distribution-image@{{distro.name}}
622 FDO_DISTRIBUTION_VERSION: '{{version}}'
623 FDO_DISTRIBUTION_TAG: ${{distro.name.upper()}}_TAG
624 {# Where we have extra_variables defined, add them to the list #}
625 {% if distro.build is defined and distro.build.extra_variables is defined %}
626 {% for var in distro.build.extra_variables %}
631 - "{{distro.name}}:{{version}}@container-prep"
636 {% set version = "{}".format(distro.versions|last()) %}
637 {{distro.name}}:{{version}}@default-build:
640 - .build-in-qemu@template
641 - .fdo.distribution-image@{{distro.name}}
643 FDO_DISTRIBUTION_VERSION: '{{version}}'
644 FDO_DISTRIBUTION_TAG: ${{distro.name.upper()}}_TAG
645 {# Where we have extra_variables defined, add them to the list #}
646 {% if distro.build is defined and distro.build.extra_variables is defined %}
647 {% for var in distro.build.extra_variables %}
652 - "{{distro.name}}:{{version}}@container-prep"
657 #################################################################
661 #################################################################
664 # Verify that the merge request has the allow-collaboration checkbox ticked
673 - ci-fairy check-merge-request --require-allow-collaboration --junit-xml=results.xml
680 {% for distro in distributions if distro.name == "fedora" %}
681 {% set version = "{}".format(distro.versions|last()) %}
684 - .fdo.distribution-image@fedora
688 FDO_DISTRIBUTION_VERSION: '36'
689 FDO_DISTRIBUTION_TAG: $FEDORA_TAG
691 - "fedora:36@container-prep"
693 - dnf install -y rpmdevtools jq
694 - meson "$MESON_BUILDDIR"
695 - VERSION=$(meson introspect "$MESON_BUILDDIR" --projectinfo | jq -r .version)
696 - sed -e "s/@PIPELINEID@/${CI_PIPELINE_ID}/"
697 -e "s/@GITVERSION@/${CI_COMMIT_SHA}/"
698 -e "s/@VERSION@/${VERSION}/" .gitlab-ci/libinput.spec.in > libinput.spec
699 - git config --local user.name 'gitlab CI'
700 - git config --local user.email 'noreply@nowhere'
701 - git add libinput.spec && git commit -m 'Add libinput.spec for build testing' libinput.spec
702 - cd "$MESON_BUILDDIR"
703 - meson dist --no-test
704 - rpmbuild -ta meson-dist/libinput*.tar.xz
710 trigger: wayland/wayland.freedesktop.org
715 MESON_ARGS: '-Ddocumentation=true -Ddebug-gui=false -Dlibwacom=false -Dtests=false'
716 MESON_BUILDDIR: 'builddir'
721 - $CI_PROJECT_PATH == "libinput/libinput"