1 # vim: set expandtab shiftwidth=2 tabstop=8 textwidth=0 filetype=yaml:
3 # This is a bit complicated for two reasons:
4 # - we really want to run dnf/apt/... only once, updating on the test runner for
5 # each job takes forever. So we create a container image for each distribution
6 # tested, then run the tests on this container image.
8 # Creating a container image is time-consuming, so we only do so for pushes to
9 # libinput directly (not merge requests) and if the current image is 'old'.
11 # - GitLab only allows one script: set per job but we have a bunch of commands
12 # we need to re-run for each build (meson && ninja && etc). YAML cannot merge
13 # arrays templates so we're screwed.
15 # So instead we use a default_build template and override everything with
16 # variables. The only two variables that matter:
17 # MESON_ARGS=-Denable-something=true
18 # NINJA_ARGS=dist ... to run 'ninja -C builddir dist'
19 # Note that you cannot use scripts: in any target if you expect default_build
23 # All jobs must follow the naming scheme of
24 # <distribution>:<version>@activity:
25 # e.g. fedora:31@build-default
27 .templates_sha: &template_sha 395535ce90eb48e260c0dff12c35d9237e22c539 # see https://docs.gitlab.com/ee/ci/yaml/#includefile
30 # Alpine container builder template
31 - project: 'freedesktop/ci-templates'
33 file: '/templates/alpine.yml'
34 # Arch container builder template
35 - project: 'freedesktop/ci-templates'
37 file: '/templates/arch.yml'
38 # Fedora container builder template
39 - project: 'freedesktop/ci-templates'
41 file: '/templates/fedora.yml'
42 # Ubuntu container builder template
43 - project: 'freedesktop/ci-templates'
45 file: '/templates/ubuntu.yml'
48 - prep # prep work like rebuilding the container images if there is a change
49 - build # for actually building and testing things in a container
50 - VM # for running the test suite in a VM
51 - valgrind # for running the test suite under valgrind in a VM
52 - distro # distribs test
53 - deploy # trigger wayland's website generation
54 - container_clean # clean up unused container images
57 ###############################################################################
58 # This is the list of packages required to build libinput with the default #
61 # Run dnf install/apt-get install/.. with the list of packages for your #
64 # See the documentation here: #
65 # https://wayland.freedesktop.org/libinput/doc/latest/building_libinput.html #
66 ###############################################################################
67 FEDORA_PACKAGES: 'git gcc gcc-c++ pkgconf-pkg-config meson check-devel libudev-devel libevdev-devel doxygen graphviz python3-sphinx python3-recommonmark python3-sphinx_rtd_theme python3-pytest-xdist libwacom-devel cairo-devel gtk3-devel glib2-devel mtdev-devel diffutils'
68 FEDORA_QEMU_RPMS: 'git gcc gcc-c++ pkgconf-pkg-config meson check-devel libudev-devel libevdev-devel doxygen graphviz python3-sphinx python3-recommonmark python3-sphinx_rtd_theme python3-pytest-xdist libwacom-devel cairo-devel gtk3-devel glib2-devel mtdev-devel diffutils valgrind'
69 UBUNTU_PACKAGES: 'git gcc g++ pkg-config meson check libudev-dev libevdev-dev doxygen graphviz python3-sphinx python3-recommonmark python3-sphinx-rtd-theme python3-pytest-xdist libwacom-dev libcairo2-dev libgtk-3-dev libglib2.0-dev libmtdev-dev'
70 ARCH_PACKAGES: 'git gcc pkgconfig meson check libsystemd libevdev doxygen graphviz python-sphinx python-recommonmark python-sphinx_rtd_theme python-pytest-xdist libwacom gtk3 mtdev diffutils'
71 FREEBSD_BUILD_PKGS: 'meson'
72 FREEBSD_PKGS: 'libepoll-shim libudev-devd libevdev libwacom gtk3 libmtdev '
73 ALPINE_PACKAGES: 'git gcc build-base pkgconfig meson check-dev eudev-dev libevdev-dev libwacom-dev cairo-dev gtk+3.0-dev mtdev-dev bash'
74 ############################ end of package lists #############################
76 # these tags should be updated each time the list of packages is updated
77 # changing these will force rebuilding the associated image
78 # Note: these tags have no meaning and are not tied to a particular
80 FEDORA_TAG: '2020-03-17.0'
81 UBUNTU_TAG: '2020-03-17.0'
82 ARCH_TAG: '2020-03-17.0'
83 ALPINE_TAG: '2020-03-17.0'
84 FREEBSD_TAG: '2020-03-17.0'
85 QEMU_TAG: 'qemu-vm-2020-03-17.0'
87 UBUNTU_EXEC: "bash .gitlab-ci/ubuntu_install.sh $UBUNTU_CUSTOM_DEBS"
89 FREEBSD_CONTAINER_IMAGE: $CI_REGISTRY_IMAGE/freebsd/11.2:$FREEBSD_TAG
90 FDO_UPSTREAM_REPO: libinput/libinput
92 MESON_BUILDDIR: "build dir"
95 MESON_TEST_ARGS: '--no-suite=hardware'
97 # udev isn't available/working properly in the containers
105 - runner_system_failure
106 - stuck_or_timeout_failure
107 # cancel run when a newer version is pushed to the branch
112 name: "meson-logs-$CI_JOB_NAME"
116 - $MESON_BUILDDIR/meson-logs
118 junit: $MESON_BUILDDIR/junit-*.xml
120 #################################################################
124 #################################################################
126 # Re-generate the CI script and make sure it's the one currently checked in
127 # If this job fails, re-generate the gitlab-ci.yml script, see
128 # $SRCDIR/.gitlab-ci/generate-gitlab-ci.py
134 - apk add python3 git
135 - pip3 install --user jinja2
137 - python3 ./.gitlab-ci/generate-gitlab-ci.py
138 - git diff --exit-code && exit 0 || true
139 - echo "Committed gitlab-ci.yml differs from generated gitlab-ci.yml. Please verify"
143 # Verify that commit messages are as expected, signed-off, etc.
150 - apk add python3 git
152 - pip3 install GitPython
153 - pip3 install pytest
155 pytest --junitxml=results.xml \
158 ./.gitlab-ci/check-commit.py
160 - master@libinput/libinput
168 # This stage will recreate the container images only if the image
169 # is too old or if it is missing some dependencies.
172 .rebuild_for_schedule:
174 # force rebuild if schedule, reuse otherwise
175 - if [[ $CI_PIPELINE_SOURCE == "schedule" ]] ; then export FDO_FORCE_REBUILD=1; fi
179 - .fdo.qemu-build@fedora
181 - .rebuild_for_schedule
187 FDO_DISTRIBUTION_VERSION: 30
188 FDO_DISTRIBUTION_TAG: $QEMU_TAG
189 FDO_DISTRIBUTION_PACKAGES: $FEDORA_QEMU_RPMS
192 fedora:30@container-prep:
194 - .fdo.container-build@fedora
196 - .rebuild_for_schedule
200 FDO_DISTRIBUTION_VERSION: '30'
201 FDO_DISTRIBUTION_PACKAGES: $FEDORA_PACKAGES
202 FDO_DISTRIBUTION_TAG: $FEDORA_TAG
204 fedora:31@container-prep:
206 - .fdo.container-build@fedora
208 - .rebuild_for_schedule
212 FDO_DISTRIBUTION_VERSION: '31'
213 FDO_DISTRIBUTION_PACKAGES: $FEDORA_PACKAGES
214 FDO_DISTRIBUTION_TAG: $FEDORA_TAG
216 ubuntu:19.10@container-prep:
218 - .fdo.container-build@ubuntu
220 - .rebuild_for_schedule
224 FDO_DISTRIBUTION_VERSION: '19.10'
225 FDO_DISTRIBUTION_PACKAGES: $UBUNTU_PACKAGES
226 FDO_DISTRIBUTION_TAG: $UBUNTU_TAG
228 ubuntu:19.04@container-prep:
230 - .fdo.container-build@ubuntu
232 - .rebuild_for_schedule
236 FDO_DISTRIBUTION_VERSION: '19.04'
237 FDO_DISTRIBUTION_PACKAGES: $UBUNTU_PACKAGES
238 FDO_DISTRIBUTION_TAG: $UBUNTU_TAG
240 arch:rolling@container-prep:
242 - .fdo.container-build@arch
244 - .rebuild_for_schedule
248 FDO_DISTRIBUTION_VERSION: 'rolling'
249 FDO_DISTRIBUTION_PACKAGES: $ARCH_PACKAGES
250 FDO_DISTRIBUTION_TAG: $ARCH_TAG
252 alpine:latest@container-prep:
254 - .fdo.container-build@alpine
256 - .rebuild_for_schedule
260 FDO_DISTRIBUTION_VERSION: 'latest'
261 FDO_DISTRIBUTION_PACKAGES: $ALPINE_PACKAGES
262 FDO_DISTRIBUTION_TAG: $ALPINE_TAG
266 # Note that we want to use the latest buildah image, and for that
267 # we use one of the .fdo.container-build@distribution by replacing the
269 .freebsd@container-prep:
272 - .fdo.container-build@fedora
275 # log in to the registry
276 - podman login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
278 # get the full container image name
279 - export IMAGE=freebsd/$FREEBSD_VERSION:$FREEBSD_TAG
281 # force rebuild if schedule, reuse otherwise
282 - if [[ $CI_PIPELINE_SOURCE == "schedule" ]] ; then touch .scheduled; fi
284 # pull the latest upstream image if it exists
285 - test -e .scheduled || skopeo copy --dest-creds $CI_REGISTRY_USER:$CI_REGISTRY_PASSWORD
286 docker://$CI_REGISTRY/$FDO_UPSTREAM_REPO/$IMAGE
287 docker://$CI_REGISTRY_IMAGE/$IMAGE && exit 0 || true ;
289 # check if our image is already in the current registry
290 - test -e .scheduled || skopeo inspect docker://$CI_REGISTRY_IMAGE/$IMAGE > /dev/null && exit 0 || true ;
292 - export BUILDAH_RUN="buildah run --isolation chroot"
293 - export BUILDAH_COMMIT="buildah commit --format docker"
294 - buildcntr=$(buildah from --quiet myfreeweb/freebsd-cross:latest)
295 - $BUILDAH_RUN $buildcntr apk add --no-cache $FREEBSD_BUILD_PKGS
296 - $BUILDAH_RUN $buildcntr pkg -r /freebsd update -f
297 - $BUILDAH_RUN $buildcntr pkg -r /freebsd install -y $FREEBSD_PKGS
298 - buildah config --workingdir /app $buildcntr
299 # tag the current container
300 - $BUILDAH_COMMIT $buildcntr $FREEBSD_CONTAINER_IMAGE
301 # clean up the working container
302 - buildah rm $buildcntr
304 # push the container image to the libinput registry
305 - podman push --quiet $FREEBSD_CONTAINER_IMAGE
306 - skopeo copy --dest-creds $CI_REGISTRY_USER:$CI_REGISTRY_PASSWORD
307 docker://$FREEBSD_CONTAINER_IMAGE
308 docker://$CI_REGISTRY_IMAGE/freebsd/$FREEBSD_VERSION:$CI_JOB_ID
310 freebsd:11.2@container-prep:
312 - .freebsd@container-prep
315 FREEBSD_VERSION: "11.2"
318 #################################################################
320 # container clean stage #
321 # run during the clean stage #
323 #################################################################
326 # This stage will look for the container images we currently have in
327 # the registry and will remove any that are not tagged with the provided
328 # $container_image:$tag
331 stage: container_clean
336 - apk add python3 git
337 - pip3 install git+http://gitlab.freedesktop.org/freedesktop/ci-templates
339 # Go to your Profile, Settings, Access Tokens
340 # Create a personal token with 'api' scope, copy the value.
341 # Go to CI/CD, Schedules, schedule a new monthly job (or edit the existing one)
342 # Define a variable of type File named AUTHFILE. Content is that token
344 - ci-fairy -v --authfile $AUTHFILE delete-image
345 --repository $FDO_DISTRIBUTION_NAME/$FDO_DISTRIBUTION_VERSION
346 --exclude-tag $FDO_DISTRIBUTION_TAG
352 fedora:30@container-clean:
358 CURRENT_CONTAINER_IMAGE: $CI_REGISTRY_IMAGE/fedora/$FDO_DISTRIBUTION_VERSION:$FDO_DISTRIBUTION_TAG
359 FDO_DISTRIBUTION_VERSION: '30'
360 FDO_DISTRIBUTION_TAG: $FEDORA_TAG
362 fedora:31@container-clean:
368 CURRENT_CONTAINER_IMAGE: $CI_REGISTRY_IMAGE/fedora/$FDO_DISTRIBUTION_VERSION:$FDO_DISTRIBUTION_TAG
369 FDO_DISTRIBUTION_VERSION: '31'
370 FDO_DISTRIBUTION_TAG: $FEDORA_TAG
372 ubuntu:19.10@container-clean:
377 UBUNTU_VERSION: '19.10'
378 CURRENT_CONTAINER_IMAGE: $CI_REGISTRY_IMAGE/ubuntu/$FDO_DISTRIBUTION_VERSION:$FDO_DISTRIBUTION_TAG
379 FDO_DISTRIBUTION_VERSION: '19.10'
380 FDO_DISTRIBUTION_TAG: $UBUNTU_TAG
382 ubuntu:19.04@container-clean:
387 UBUNTU_VERSION: '19.04'
388 CURRENT_CONTAINER_IMAGE: $CI_REGISTRY_IMAGE/ubuntu/$FDO_DISTRIBUTION_VERSION:$FDO_DISTRIBUTION_TAG
389 FDO_DISTRIBUTION_VERSION: '19.04'
390 FDO_DISTRIBUTION_TAG: $UBUNTU_TAG
392 arch:rolling@container-clean:
397 ARCH_VERSION: 'rolling'
398 CURRENT_CONTAINER_IMAGE: $CI_REGISTRY_IMAGE/arch/$FDO_DISTRIBUTION_VERSION:$FDO_DISTRIBUTION_TAG
399 FDO_DISTRIBUTION_VERSION: 'rolling'
400 FDO_DISTRIBUTION_TAG: $ARCH_TAG
402 alpine:latest@container-clean:
407 ALPINE_VERSION: 'latest'
408 CURRENT_CONTAINER_IMAGE: $CI_REGISTRY_IMAGE/alpine/$FDO_DISTRIBUTION_VERSION:$FDO_DISTRIBUTION_TAG
409 FDO_DISTRIBUTION_VERSION: 'latest'
410 FDO_DISTRIBUTION_TAG: $ALPINE_TAG
413 freebsd:11.2@container-clean:
418 CURRENT_CONTAINER_IMAGE: $FREEBSD_CONTAINER_IMAGE
420 #################################################################
424 #################################################################
432 - .gitlab-ci/meson-build.sh
439 .check_tainted: &check_tainted |
440 # make sure the kernel is not tainted
441 if [[ "$(ssh localhost -p 5555 cat /proc/sys/kernel/tainted)" -gt 0 ]];
443 echo tainted kernel ;
447 # Run in a test suite. Special variables:
448 # - SUITES: the meson test suites to run, or
449 # - SUITE_NAMES: all elements will be expanded to libinput-test-suite-$value
450 # Set one or the other, not both.
454 - .fdo.distribution-image@fedora
459 MESON_BUILDDIR: build_dir
460 # remove the global --no-suite=hardware
463 - if ! [[ -z $SUITE_NAMES ]]; then SUITES=$(echo $SUITE_NAMES | sed 's/\([^ ]*\)/libinput-test-suite-\1/g'); fi
464 - echo "Testing $SUITES"
466 # start our vm, no args required
467 - /app/start_vm.sh || (echo "Error - Failed to start the VM." && exit 1)
471 - "scp -P 5555 -r $PWD localhost:"
472 - echo "CI_JOB_ID=\"$CI_JOB_ID\"" > sshenv
473 - echo "CI_JOB_NAME=\"$CI_JOB_NAME\"" >> sshenv
474 - echo "MESON_ARGS=\"$MESON_ARGS\"" >> sshenv
475 - echo "MESON_BUILDDIR=\"$MESON_BUILDDIR\"" >> sshenv
476 - echo "MESON_TEST_ARGS=\"$MESON_TEST_ARGS $SUITES\"" >> sshenv
477 - echo "NINJA_ARGS=\"$NINJA_ARGS\"" >> sshenv
478 - "scp -P 5555 sshenv localhost:~/$CI_PROJECT_NAME/.meson_environment"
479 - ssh localhost -p 5555 "cd $CI_PROJECT_NAME ; .gitlab-ci/meson-build.sh" && touch .success || true
480 # no matter the results of the tests, we want to fetch the logs
481 - scp -P 5555 -r localhost:$CI_PROJECT_NAME/$MESON_BUILDDIR .
485 - ssh localhost -p 5555 halt || true
489 - if [[ ! -e .success ]] ;
494 name: "qemu-meson-logs-$CI_JOB_NAME"
498 - $MESON_BUILDDIR/meson-logs
501 junit: $MESON_BUILDDIR/junit-*.xml
509 .fedora:30@test-suite-vm:
513 FDO_DISTRIBUTION_VERSION: 30
514 FDO_DISTRIBUTION_TAG: $QEMU_TAG
515 needs: ['fedora:30@qemu-prep']
520 - .fedora:30@test-suite-vm
522 SUITE_NAMES: 'touchpad'
524 vm-touchpad-no-libwacom:
528 MESON_ARGS: '-Dlibwacom=false'
532 - .fedora:30@test-suite-vm
540 MESON_ARGS: '-Dlibwacom=false'
544 - .fedora:30@test-suite-vm
546 SUITE_NAMES: 'tablet'
548 vm-tablet-no-libwacom:
552 MESON_ARGS: '-Dlibwacom=false'
556 - .fedora:30@test-suite-vm
558 SUITE_NAMES: 'gestures device'
560 vm-gestures-device-no-libwacom:
564 MESON_ARGS: '-Dlibwacom=false'
568 - .fedora:30@test-suite-vm
570 SUITE_NAMES: 'context config misc events totem udev lid log timer tablet-mode quirks trackball pad path keyboard switch touch trackpoint'
572 vm-others-no-libwacom:
576 MESON_ARGS: '-Dlibwacom=false'
580 - .fedora:30@test-suite-vm
582 SUITE_NAMES: 'pointer'
584 vm-pointer-no-libwacom:
588 MESON_ARGS: '-Dlibwacom=false'
591 vm-valgrind-touchpad:
596 MESON_TEST_ARGS: '--setup=valgrind'
603 MESON_TEST_ARGS: '--setup=valgrind'
610 MESON_TEST_ARGS: '--setup=valgrind'
612 vm-valgrind-gestures-device:
617 MESON_TEST_ARGS: '--setup=valgrind'
624 MESON_TEST_ARGS: '--setup=valgrind'
631 MESON_TEST_ARGS: '--setup=valgrind'
635 .fedora-build@template:
637 - .fdo.distribution-image@fedora
640 FDO_DISTRIBUTION_VERSION: '30'
641 FDO_DISTRIBUTION_TAG: $FEDORA_TAG
642 needs: ['fedora:30@container-prep']
644 default-build-release@fedora:30:
647 - .fedora-build@template
649 MESON_ARGS: "-Dbuildtype=release"
652 scan-build@fedora:30:
654 - .fedora-build@template
656 NINJA_ARGS: scan-build
659 - dnf install -y clang-analyzer findutils
661 - test ! -d "$MESON_BUILDDIR"/meson-logs/scanbuild && exit 0
662 - test $(find "$MESON_BUILDDIR"/meson-logs/scanbuild -maxdepth 0 ! -empty -exec echo "not empty" \; | wc -l) -eq 0 && exit 0
663 - echo "Check scan-build results"
666 # Below jobs are build option combinations. We only
667 # run them on one image, they shouldn't fail on one distro
668 # when they succeed on another.
670 build-no-libwacom@fedora:30:
672 - .fedora-build@template
674 MESON_ARGS: "-Dlibwacom=false"
676 build-no-libwacom-nodeps@fedora:30:
678 - .fedora-build@template
680 MESON_ARGS: "-Dlibwacom=false"
682 - dnf remove -y libwacom libwacom-devel
684 build-no-docs@fedora:30:
686 - .fedora-build@template
688 MESON_ARGS: "-Ddocumentation=false"
690 build-no-docs-nodeps@fedora:30:
692 - .fedora-build@template
694 MESON_ARGS: "-Ddocumentation=false"
696 - dnf remove -y doxygen graphviz
698 build-no-debuggui@fedora:30:
700 - .fedora-build@template
702 MESON_ARGS: "-Ddebug-gui=false"
704 build-no-debuggui-nodeps@fedora:30:
706 - .fedora-build@template
708 MESON_ARGS: "-Ddebug-gui=false"
710 - dnf remove -y gtk3-devel
712 build-no-tests@fedora:30:
714 - .fedora-build@template
716 MESON_ARGS: "-Dtests=false"
718 build-no-tests-nodeps@fedora:30:
720 - .fedora-build@template
722 MESON_ARGS: "-Dtests=false"
724 - dnf remove -y check-devel
728 - .fedora-build@template
730 MESON_TEST_ARGS: '--suite=valgrind --no-suite=hardware --setup=valgrind'
732 - dnf install -y valgrind
734 # Python checks, only run on Fedora
736 usr-bin-env-python@fedora:30:
738 - .fedora-build@template
741 if git grep -l '^#!/usr/bin/python'; then
742 echo "Use '/usr/bin/env python3' in the above files";
748 - .fedora-build@template
750 - dnf install -y python3-flake8
752 - flake8-3 --ignore=W501,E501,W504 $(git grep -l '^#!/usr/bin/env python3')
754 #################################################################
758 #################################################################
760 fedora:30@default-build:
764 - .fdo.distribution-image@fedora
766 FDO_DISTRIBUTION_VERSION: '30'
767 FDO_DISTRIBUTION_TAG: $FEDORA_TAG
768 needs: ['fedora:30@container-prep']
771 fedora:31@default-build:
775 - .fdo.distribution-image@fedora
777 FDO_DISTRIBUTION_VERSION: '31'
778 FDO_DISTRIBUTION_TAG: $FEDORA_TAG
779 needs: ['fedora:31@container-prep']
782 ubuntu:19.10@default-build:
786 - .fdo.distribution-image@ubuntu
788 FDO_DISTRIBUTION_VERSION: '19.10'
789 FDO_DISTRIBUTION_TAG: $UBUNTU_TAG
790 needs: ['ubuntu:19.10@container-prep']
793 ubuntu:19.04@default-build:
797 - .fdo.distribution-image@ubuntu
799 FDO_DISTRIBUTION_VERSION: '19.04'
800 FDO_DISTRIBUTION_TAG: $UBUNTU_TAG
801 needs: ['ubuntu:19.04@container-prep']
804 arch:rolling@default-build:
808 - .fdo.distribution-image@arch
810 FDO_DISTRIBUTION_VERSION: 'rolling'
811 FDO_DISTRIBUTION_TAG: $ARCH_TAG
812 needs: ['arch:rolling@container-prep']
815 alpine:latest@default-build:
819 - .fdo.distribution-image@alpine
821 FDO_DISTRIBUTION_VERSION: 'latest'
822 FDO_DISTRIBUTION_TAG: $ALPINE_TAG
823 MESON_ARGS: '-Ddocumentation=false' # alpine does not have python-recommonmark
824 MESON_TEST_ARGS: '' # litest-selftest fails on musl
825 needs: ['alpine:latest@container-prep']
836 image: $FREEBSD_CONTAINER_IMAGE
838 MESON_ARGS: '--cross-file freebsd -Ddocumentation=false -Dtests=false -Depoll-dir=/freebsd/usr/local/'
839 # Can't run FreeBSD tests on Linux machine, so MESON_TEST_ARGS shouldn't be "test"
842 freebsd:11.2@default-build:
845 needs: ['freebsd:11.2@container-prep']
857 # - variable WAYLAND_WEB_TOKEN defined as type File in libinput's CI/CD settings
858 # - content of that file is the token value, as generated by the Pipeline Triggers
859 # of the wayland.freedesktop.org project.
860 - curl --request POST
861 --form "token=<$WAYLAND_WEB_TOKEN"
863 https://gitlab.freedesktop.org/api/v4/projects/wayland${SLASH}wayland${DOT}freedesktop${DOT}org/trigger/pipeline
871 - $CI_PROJECT_PATH == "libinput/libinput"