1# vim: set expandtab shiftwidth=2 tabstop=8 textwidth=0 filetype=yaml:
2
3########################################
4#                                      #
5# THIS FILE IS GENERATED, DO NOT EDIT  #
6#                                      #
7########################################
8
9# To change the gitlab CI, edit .gitlab-ci/ci.template and/or .gitlab-ci/config.yaml
10# and run ci-fairy generate-template. For details, see
11# https://freedesktop.pages.freedesktop.org/ci-templates/ci-fairy.html#templating-gitlab-ci-yml
12
13# This is a bit complicated for two reasons:
14# - we really want to run dnf/apt/... only once, updating on the test runner for
15#   each job takes forever. So we create a container image for each distribution
16#   tested, then run the tests on this container image.
17#
18#   This is handled by the ci-templates, ensuring containers are only rebuilt
19#   when the TAG changes.
20#
21# - GitLab only allows one script: set per job but we have a bunch of commands
22#   we need to re-run for each build (meson && ninja && etc). YAML cannot merge
23#   arrays so we're screwed.
24#
25#   So instead we use a default_build template and override everything with
26#   variables. The only two variables that matter:
27#     MESON_ARGS=-Denable-something=true
28#     NINJA_ARGS=dist ... to run 'ninja -C builddir dist'
29#   Note that you cannot use scripts: in any target if you expect default_build
30#   to work.
31#
32#
33# All jobs must follow the naming scheme of
34# <distribution>:<version>@activity:
35#  e.g. fedora:31@build-default
36
37.templates_sha: &template_sha dd90ac0d7a03b574eb4f18d7358083f0c97825f3
38
39include:
40  - project: 'freedesktop/ci-templates'
41    ref: *template_sha
42    file:
43      - '/templates/ci-fairy.yml'
44      # Alpine container builder template
45      - '/templates/alpine.yml'
46      # Arch container builder template
47      - '/templates/arch.yml'
48      # Debian container builder template
49      - '/templates/debian.yml'
50      # Fedora container builder template
51      - '/templates/fedora.yml'
52      # Freebsd container builder template
53      - '/templates/freebsd.yml'
54      # Ubuntu container builder template
55      - '/templates/ubuntu.yml'
56
57workflow:
58  rules:
59    - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
60    - if: $CI_PIPELINE_SOURCE == 'push'
61
62stages:
63  - sanity check     # CI/commit checks
64  - prep             # prep work like rebuilding the container images if there is a change
65  - build            # for actually building and testing things in a container
66  - test-suite       # for running the test suite in a VM
67  - test-suite-no-libwacom # for running the test suite in a VM (libwacom disabled)
68  - valgrind         # for running the test suite under valgrind in a VM
69  - distro           # distribs test
70  - deploy           # trigger wayland's website generation
71  - container_clean  # clean up unused container images (scheduled jobs only)
72
73variables:
74  ###############################################################################
75  # This is the list of packages required to build libinput with the default    #
76  # configuration.                                                              #
77  #                                                                             #
78  # Run dnf install/apt-get install/.. with the list of packages for your       #
79  # distribution                                                                #
80  #                                                                             #
81  # See the documentation here:                                                 #
82  # https://wayland.freedesktop.org/libinput/doc/latest/building_libinput.html  #
83  ###############################################################################
84  FEDORA_PACKAGES:  'git-core 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 gtk4-devel glib2-devel mtdev-devel diffutils wayland-protocols-devel black clang-analyzer jq rpmdevtools valgrind systemd-udev qemu-img qemu-system-x86-core qemu-system-aarch64-core jq python3-click python3-rich'
85  DEBIAN_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 curl'
86  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'
87  ARCH_PACKAGES:    'git gcc pkgconfig meson check libsystemd libevdev doxygen graphviz python-sphinx python-recommonmark python-sphinx_rtd_theme python-pytest-xdist libwacom gtk4 mtdev diffutils wayland-protocols'
88  ALPINE_PACKAGES:  'git gcc build-base pkgconfig meson check-dev eudev-dev libevdev-dev libwacom-dev cairo-dev gtk4.0-dev mtdev-dev bash'
89  FREEBSD_PACKAGES: 'git pkgconf meson libepoll-shim libudev-devd libevdev libwacom gtk3 libmtdev bash wayland'
90  ############################ end of package lists #############################
91
92  # these tags should be updated each time the list of packages is updated
93  # changing these will force rebuilding the associated image
94  # Note: these tags have no meaning and are not tied to a particular
95  # libinput version
96  FEDORA_TAG:  '2023-02-13.0'
97  DEBIAN_TAG:  '2023-02-13.0'
98  UBUNTU_TAG:  '2023-02-13.0'
99  ARCH_TAG:    '2023-02-13.0'
100  ALPINE_TAG:  '2023-02-13.0'
101  FREEBSD_TAG: '2023-02-13.0'
102
103  FDO_UPSTREAM_REPO: libinput/libinput
104
105  MESON_BUILDDIR: "build dir"
106  NINJA_ARGS: ''
107  MESON_ARGS: ''
108  MESON_TEST_ARGS: '--no-suite=hardware'
109
110  # udev isn't available/working properly in the containers
111  UDEV_NOT_AVAILABLE: 1
112  GIT_DEPTH: 1
113
114.policy:
115  retry:
116    max: 2
117    when:
118      - runner_system_failure
119      - stuck_or_timeout_failure
120  # cancel run when a newer version is pushed to the branch
121  interruptible: true
122  dependencies: []
123
124.default_artifacts:
125  artifacts:
126    name: "meson-logs-$CI_JOB_NAME"
127    when: always
128    expire_in: 1 week
129    paths:
130      - $MESON_BUILDDIR/meson-logs
131    reports:
132      junit: $MESON_BUILDDIR/*junit*.xml
133
134
135#################################################################
136#                                                               #
137#                     sanity check stage                        #
138#                                                               #
139#################################################################
140
141fail-if-fork-is-not-public:
142  stage: sanity check
143  script:
144    - |
145      if [ $CI_PROJECT_VISIBILITY != "public" ]; then
146           echo "*************************************************************************************"
147           echo "Project visibility must be set to 'public'"
148           echo "Change this in $CI_PROJECT_URL/edit under 'Visibility, project features, permissions'"
149           echo "*************************************************************************************"
150           exit 1
151      fi
152  except:
153    - main@libinput/libinput
154
155# Re-generate the CI script and make sure it's the one currently checked in
156# If this job fails, re-generate the gitlab-ci.yml script, see
157# $SRCDIR/.gitlab-ci/generate-gitlab-ci.py
158#
159check-ci-script:
160  extends:
161    - .fdo.ci-fairy
162  stage: sanity check
163  script:
164    - ci-fairy generate-template --verify && exit 0 || true
165    - >
166      printf "%s\n" \
167        "Committed gitlab-ci.yml differs from generated gitlab-ci.yml. Please verify" \
168        "https://wayland.freedesktop.org/libinput/doc/latest/contributing.html"
169    - exit 1
170
171#
172# Verify that commit messages are as expected, etc.
173#
174
175check-commit:
176  extends:
177    - .fdo.ci-fairy
178  stage: sanity check
179  script:
180    - ci-fairy -vv check-commits --junit-xml=results.xml && exit 0 || true
181    - >
182      printf "%s\n" \
183        "Error checking commit format. Please verify" \
184        "https://wayland.freedesktop.org/libinput/doc/latest/contributing.html"
185    - exit 1
186  except:
187    - main@libinput/libinput
188  variables:
189    GIT_DEPTH: 100
190  artifacts:
191    reports:
192      junit: results.xml
193
194
195#
196# Check for trailing whitespaces
197#
198
199check-whitespace:
200  extends:
201    - .fdo.ci-fairy
202  stage: sanity check
203  script:
204    # remove trailing whitespaces
205    - sed -i 's/ *$//' $(git ls-files)
206    - git diff --exit-code || (echo "ERROR - Trailing whitespaces in patchset, please fix" && false)
207    - sed -i 's/\t*$//' $(git ls-files)
208    - git diff --exit-code || (echo "ERROR - Trailing tabs in patchset, please fix" && false)
209    # search for tab after space
210    - sed -i 's/ \t//' $(git ls-files)
211    - git diff --exit-code || (echo "ERROR - Tab after space in patchset, please fix" && false)
212    # search for duplicated empty lines
213    - sed -i '/^$/N;/^\n$/D' $(git ls-files src/*.{h,c} tools/*.{h,c} udev/*.c)
214    - git diff --exit-code || (echo "ERROR - Duplicated empty lines, please fix" && false)
215
216
217#################################################################
218#                                                               #
219#                          prep stage                           #
220#                                                               #
221#################################################################
222
223fedora:37@container-prep:
224  extends:
225    - .fdo.container-build@fedora
226    - .policy
227  stage: prep
228  variables:
229    GIT_STRATEGY: none
230    FDO_DISTRIBUTION_VERSION: '37'
231    FDO_DISTRIBUTION_PACKAGES: $FEDORA_PACKAGES
232    FDO_DISTRIBUTION_TAG: $FEDORA_TAG
233
234fedora:38@container-prep:
235  extends:
236    - .fdo.container-build@fedora
237    - .policy
238  stage: prep
239  variables:
240    GIT_STRATEGY: none
241    FDO_DISTRIBUTION_VERSION: '38'
242    FDO_DISTRIBUTION_PACKAGES: $FEDORA_PACKAGES
243    FDO_DISTRIBUTION_TAG: $FEDORA_TAG
244
245debian:stable@container-prep:
246  extends:
247    - .fdo.container-build@debian
248    - .policy
249  stage: prep
250  variables:
251    GIT_STRATEGY: none
252    FDO_DISTRIBUTION_VERSION: 'stable'
253    FDO_DISTRIBUTION_PACKAGES: $DEBIAN_PACKAGES
254    FDO_DISTRIBUTION_TAG: $DEBIAN_TAG
255
256ubuntu:22.04@container-prep:
257  extends:
258    - .fdo.container-build@ubuntu
259    - .policy
260  stage: prep
261  variables:
262    GIT_STRATEGY: none
263    FDO_DISTRIBUTION_VERSION: '22.04'
264    FDO_DISTRIBUTION_PACKAGES: $UBUNTU_PACKAGES
265    FDO_DISTRIBUTION_TAG: $UBUNTU_TAG
266
267arch:rolling@container-prep:
268  extends:
269    - .fdo.container-build@arch
270    - .policy
271  stage: prep
272  variables:
273    GIT_STRATEGY: none
274    FDO_DISTRIBUTION_VERSION: 'rolling'
275    FDO_DISTRIBUTION_PACKAGES: $ARCH_PACKAGES
276    FDO_DISTRIBUTION_TAG: $ARCH_TAG
277
278alpine:latest@container-prep:
279  extends:
280    - .fdo.container-build@alpine
281    - .policy
282  stage: prep
283  variables:
284    GIT_STRATEGY: none
285    FDO_DISTRIBUTION_VERSION: 'latest'
286    FDO_DISTRIBUTION_PACKAGES: $ALPINE_PACKAGES
287    FDO_DISTRIBUTION_TAG: $ALPINE_TAG
288
289freebsd:13.1@container-prep:
290  extends:
291    - .fdo.qemu-build@freebsd
292    - .policy
293  tags:
294    - kvm
295  stage: prep
296  variables:
297    GIT_STRATEGY: none
298    FDO_DISTRIBUTION_VERSION: '13.1'
299    FDO_DISTRIBUTION_PACKAGES: $FREEBSD_PACKAGES
300    FDO_DISTRIBUTION_TAG: $FREEBSD_TAG
301
302
303
304#################################################################
305#                                                               #
306#                   container clean stage                       #
307#                 run during the clean stage                    #
308#                                                               #
309#################################################################
310
311#
312# This stage will look for the container images we currently have in
313# the registry and will remove any that are not tagged with the provided
314# $container_image:$tag
315#
316.container-clean:
317  extends:
318    - .policy
319    - .fdo.ci-fairy
320  stage: container_clean
321  script:
322    # Go to your Profile, Settings, Access Tokens
323    # Create a personal token with 'api' scope, copy the value.
324    # Go to CI/CD, Schedules, schedule a new monthly job (or edit the existing one)
325    # Define a variable of type File named AUTHFILE. Content is that token
326    # value.
327    - ci-fairy -v --authfile $AUTHFILE delete-image
328            --repository $FDO_DISTRIBUTION_NAME/$FDO_DISTRIBUTION_VERSION
329            --exclude-tag $FDO_DISTRIBUTION_TAG
330  allow_failure: true
331  only:
332    - schedules
333
334fedora:37@container-clean:
335  extends:
336    - .policy
337    - .container-clean
338  variables:
339    GIT_STRATEGY: none
340    CURRENT_CONTAINER_IMAGE: $CI_REGISTRY_IMAGE/fedora/$FDO_DISTRIBUTION_VERSION:$FDO_DISTRIBUTION_TAG
341    FDO_DISTRIBUTION_VERSION: '37'
342    FDO_DISTRIBUTION_TAG: $FEDORA_TAG
343
344fedora:38@container-clean:
345  extends:
346    - .policy
347    - .container-clean
348  variables:
349    GIT_STRATEGY: none
350    CURRENT_CONTAINER_IMAGE: $CI_REGISTRY_IMAGE/fedora/$FDO_DISTRIBUTION_VERSION:$FDO_DISTRIBUTION_TAG
351    FDO_DISTRIBUTION_VERSION: '38'
352    FDO_DISTRIBUTION_TAG: $FEDORA_TAG
353
354debian:stable@container-clean:
355  extends:
356    - .policy
357    - .container-clean
358  variables:
359    GIT_STRATEGY: none
360    CURRENT_CONTAINER_IMAGE: $CI_REGISTRY_IMAGE/debian/$FDO_DISTRIBUTION_VERSION:$FDO_DISTRIBUTION_TAG
361    FDO_DISTRIBUTION_VERSION: 'stable'
362    FDO_DISTRIBUTION_TAG: $DEBIAN_TAG
363
364ubuntu:22.04@container-clean:
365  extends:
366    - .policy
367    - .container-clean
368  variables:
369    GIT_STRATEGY: none
370    CURRENT_CONTAINER_IMAGE: $CI_REGISTRY_IMAGE/ubuntu/$FDO_DISTRIBUTION_VERSION:$FDO_DISTRIBUTION_TAG
371    FDO_DISTRIBUTION_VERSION: '22.04'
372    FDO_DISTRIBUTION_TAG: $UBUNTU_TAG
373
374arch:rolling@container-clean:
375  extends:
376    - .policy
377    - .container-clean
378  variables:
379    GIT_STRATEGY: none
380    CURRENT_CONTAINER_IMAGE: $CI_REGISTRY_IMAGE/arch/$FDO_DISTRIBUTION_VERSION:$FDO_DISTRIBUTION_TAG
381    FDO_DISTRIBUTION_VERSION: 'rolling'
382    FDO_DISTRIBUTION_TAG: $ARCH_TAG
383
384alpine:latest@container-clean:
385  extends:
386    - .policy
387    - .container-clean
388  variables:
389    GIT_STRATEGY: none
390    CURRENT_CONTAINER_IMAGE: $CI_REGISTRY_IMAGE/alpine/$FDO_DISTRIBUTION_VERSION:$FDO_DISTRIBUTION_TAG
391    FDO_DISTRIBUTION_VERSION: 'latest'
392    FDO_DISTRIBUTION_TAG: $ALPINE_TAG
393
394freebsd:13.1@container-clean:
395  extends:
396    - .policy
397    - .container-clean
398  variables:
399    GIT_STRATEGY: none
400    CURRENT_CONTAINER_IMAGE: $CI_REGISTRY_IMAGE/freebsd/$FDO_DISTRIBUTION_VERSION:$FDO_DISTRIBUTION_TAG
401    FDO_DISTRIBUTION_VERSION: '13.1'
402    FDO_DISTRIBUTION_TAG: $FREEBSD_TAG
403
404
405#################################################################
406#                                                               #
407#                       build stage                             #
408#                                                               #
409#################################################################
410
411.build@template:
412  extends:
413    - .policy
414    - .default_artifacts
415  stage: build
416  script:
417    - .gitlab-ci/meson-build.sh
418
419
420# Run meson and meson test in the container image through qemu
421.build-in-b2c@template:
422  extends:
423    - .policy
424    - .default_artifacts
425  tags:
426    - kvm
427  variables:
428    MESON_BUILDDIR: build_dir
429    B2C_KERNEL: https://gitlab.freedesktop.org/api/v4/projects/libevdev%2Fhid-tools/packages/generic/kernel-x86_64/v6.5/bzImage
430    B2C_IMAGE: $FDO_DISTRIBUTION_IMAGE
431    B2C_COMMAND: .gitlab-ci/start-in-systemd.sh
432  script:
433    # first build in the host container
434    - .gitlab-ci/meson-build.sh --skip-test
435
436    # pull b2c
437    - curl -L -o /app/boot2container https://gitlab.freedesktop.org/gfx-ci/boot2container/-/raw/2ff65156ba67fa8a0c309a4fc16c5df1a88a3844/vm2c.py
438    - chmod +x /app/boot2container
439
440    # runs the test suite only
441    - /app/boot2container
442
443#
444# Fedora
445#
446
447.check_tainted: &check_tainted |
448  # make sure the kernel is not tainted
449  if [[ "$(ssh localhost -p 5555 cat /proc/sys/kernel/tainted)" -gt 0 ]];
450  then
451    echo tainted kernel ;
452    exit 1 ;
453  fi
454
455# Run meson and meson test in the qemu image
456.build-in-qemu@template:
457  extends:
458    - .policy
459  tags:
460    - kvm
461  variables:
462    MESON_BUILDDIR: build_dir
463  script:
464    # start our vm, no args required
465    - /app/vmctl start || (echo "Error - Failed to start the VM." && exit 1)
466
467    - *check_tainted
468
469    - "scp -r $PWD vm:"
470    - echo "CI_JOB_ID=\"$CI_JOB_ID\"" > sshenv
471    - echo "CI_JOB_NAME=\"$CI_JOB_NAME\"" >> sshenv
472    - echo "MESON_ARGS=\"$MESON_ARGS\"" >> sshenv
473    - echo "MESON_BUILDDIR=\"$MESON_BUILDDIR\"" >> sshenv
474    - echo "MESON_TEST_ARGS=\"$MESON_TEST_ARGS\"" >> sshenv
475    - echo "NINJA_ARGS=\"$NINJA_ARGS\"" >> sshenv
476    - "scp sshenv vm:~/$CI_PROJECT_NAME/.meson_environment"
477    - /app/vmctl exec "cd $CI_PROJECT_NAME ; .gitlab-ci/meson-build.sh" && touch .success || true
478    # no matter the results of the tests, we want to fetch the logs
479    - scp -r vm:$CI_PROJECT_NAME/$MESON_BUILDDIR .
480
481    - *check_tainted
482
483    - /app/vmctl stop
484
485    - if [[ ! -e .success ]] ;
486      then
487        exit 1 ;
488      fi
489  artifacts:
490    name: "qemu-meson-logs-$CI_JOB_NAME"
491    when: always
492    expire_in: 1 week
493    paths:
494      - $MESON_BUILDDIR/meson-logs
495      - console.out
496    reports:
497      junit: $MESON_BUILDDIR/*junit*.xml
498
499
500# Run in a test suite. Special variables:
501# - SUITES: the meson test suites to run, or
502# - SUITE_NAMES: all elements will be expanded to libinput-test-suite-$value
503# Set one or the other, not both.
504.test-suite-vm:
505  extends:
506    - .build-in-b2c@template
507  stage: test-suite
508  variables:
509    # remove the global --no-suite=hardware
510    MESON_TEST_ARGS: ''
511  before_script:
512    - if ! [[ -z $SUITE_NAMES ]]; then SUITES=$(echo $SUITE_NAMES | sed 's/\([^ ]*\)/libinput-test-suite-\1/g'); fi
513    - echo "Testing $SUITES"
514    - export MESON_TEST_ARGS="$MESON_TEST_ARGS $SUITES"
515    - export LITEST_JOBS="2"
516
517
518.fedora:38@test-suite-vm:
519  extends:
520    - .fdo.distribution-image@fedora
521    - .test-suite-vm
522  variables:
523    FDO_DISTRIBUTION_VERSION: 38
524    FDO_DISTRIBUTION_TAG: $FEDORA_TAG
525  needs:
526    - "fedora:38@container-prep"
527
528
529vm-touchpad:
530  extends:
531    - .fedora:38@test-suite-vm
532  variables:
533    SUITE_NAMES: 'touchpad'
534
535vm-touchpad-no-libwacom:
536  extends:
537    - vm-touchpad
538  stage: test-suite-no-libwacom
539  variables:
540    MESON_ARGS: '-Dlibwacom=false'
541
542vm-tap:
543  extends:
544    - .fedora:38@test-suite-vm
545  variables:
546    SUITE_NAMES: 'touchpad-tap'
547
548vm-tap-no-libwacom:
549  extends:
550    - vm-tap
551  stage: test-suite-no-libwacom
552  variables:
553    MESON_ARGS: '-Dlibwacom=false'
554
555vm-touchpad-buttons:
556  extends:
557    - .fedora:38@test-suite-vm
558  variables:
559    SUITE_NAMES: 'touchpad-buttons'
560
561vm-touchpad-buttons-no-libwacom:
562  extends:
563    - vm-touchpad-buttons
564  stage: test-suite-no-libwacom
565  variables:
566    MESON_ARGS: '-Dlibwacom=false'
567
568vm-tablet:
569  extends:
570    - .fedora:38@test-suite-vm
571  variables:
572    SUITE_NAMES: 'tablet'
573
574vm-tablet-no-libwacom:
575  extends:
576    - vm-tablet
577  stage: test-suite-no-libwacom
578  variables:
579    MESON_ARGS: '-Dlibwacom=false'
580
581vm-gestures-device:
582  extends:
583    - .fedora:38@test-suite-vm
584  variables:
585    SUITE_NAMES: 'gestures device'
586
587vm-gestures-device-no-libwacom:
588  extends:
589    - vm-gestures-device
590  stage: test-suite-no-libwacom
591  variables:
592    MESON_ARGS: '-Dlibwacom=false'
593
594vm-backends:
595  extends:
596    - .fedora:38@test-suite-vm
597  variables:
598    SUITE_NAMES: 'path udev'
599
600vm-backends-no-libwacom:
601  extends:
602    - vm-backends
603  stage: test-suite-no-libwacom
604  variables:
605    MESON_ARGS: '-Dlibwacom=false'
606
607vm-misc:
608  extends:
609    - .fedora:38@test-suite-vm
610  variables:
611    SUITE_NAMES: 'log misc quirks'
612
613vm-misc-no-libwacom:
614  extends:
615    - vm-misc
616  stage: test-suite-no-libwacom
617  variables:
618    MESON_ARGS: '-Dlibwacom=false'
619
620vm-other devices:
621  extends:
622    - .fedora:38@test-suite-vm
623  variables:
624    SUITE_NAMES: 'keyboard pad switch trackball trackpoint totem touch'
625
626vm-other devices-no-libwacom:
627  extends:
628    - vm-other devices
629  stage: test-suite-no-libwacom
630  variables:
631    MESON_ARGS: '-Dlibwacom=false'
632
633vm-pointer:
634  extends:
635    - .fedora:38@test-suite-vm
636  variables:
637    SUITE_NAMES: 'pointer'
638
639vm-pointer-no-libwacom:
640  extends:
641    - vm-pointer
642  stage: test-suite-no-libwacom
643  variables:
644    MESON_ARGS: '-Dlibwacom=false'
645
646
647vm-valgrind-touchpad:
648  stage: valgrind
649  extends:
650    - vm-touchpad
651  variables:
652    MESON_TEST_ARGS: '--setup=valgrind'
653    LITEST_JOBS: 4
654
655vm-valgrind-tap:
656  stage: valgrind
657  extends:
658    - vm-tap
659  variables:
660    MESON_TEST_ARGS: '--setup=valgrind'
661    LITEST_JOBS: 4
662
663vm-valgrind-touchpad-buttons:
664  stage: valgrind
665  extends:
666    - vm-touchpad-buttons
667  variables:
668    MESON_TEST_ARGS: '--setup=valgrind'
669    LITEST_JOBS: 4
670
671vm-valgrind-tablet:
672  stage: valgrind
673  extends:
674    - vm-tablet
675  variables:
676    MESON_TEST_ARGS: '--setup=valgrind'
677    LITEST_JOBS: 4
678
679vm-valgrind-gestures-device:
680  stage: valgrind
681  extends:
682    - vm-gestures-device
683  variables:
684    MESON_TEST_ARGS: '--setup=valgrind'
685    LITEST_JOBS: 4
686
687vm-valgrind-backends:
688  stage: valgrind
689  extends:
690    - vm-backends
691  variables:
692    MESON_TEST_ARGS: '--setup=valgrind'
693    LITEST_JOBS: 4
694
695vm-valgrind-misc:
696  stage: valgrind
697  extends:
698    - vm-misc
699  variables:
700    MESON_TEST_ARGS: '--setup=valgrind'
701    LITEST_JOBS: 4
702
703vm-valgrind-other devices:
704  stage: valgrind
705  extends:
706    - vm-other devices
707  variables:
708    MESON_TEST_ARGS: '--setup=valgrind'
709    LITEST_JOBS: 4
710
711vm-valgrind-pointer:
712  stage: valgrind
713  extends:
714    - vm-pointer
715  variables:
716    MESON_TEST_ARGS: '--setup=valgrind'
717    LITEST_JOBS: 4
718
719
720.fedora-build@template:
721  extends:
722    - .fdo.distribution-image@fedora
723    - .build@template
724  variables:
725    FDO_DISTRIBUTION_VERSION: '38'
726    FDO_DISTRIBUTION_TAG: $FEDORA_TAG
727  needs:
728    - "fedora:38@container-prep"
729
730default-build-release@fedora:38:
731  stage: distro
732  extends:
733    - .fedora-build@template
734  variables:
735    MESON_ARGS: "-Dbuildtype=release"
736    CFLAGS: "-Werror"
737
738scan-build@fedora:38:
739  extends:
740    - .fedora-build@template
741  variables:
742    NINJA_ARGS: ''
743    MESON_TEST_ARGS: ''
744  script:
745    - .gitlab-ci/meson-build.sh
746    - export SCANBUILD="$PWD/.gitlab-ci/scanbuild-wrapper.sh"
747    - ninja -C "$MESON_BUILDDIR" scan-build
748  after_script:
749    - .gitlab-ci/scanbuild-plist-to-junit.py "$MESON_BUILDDIR"/meson-logs/scanbuild/ > "$MESON_BUILDDIR"/junit-scan-build.xml
750
751# Below jobs are build option combinations. We only
752# run them on one image, they shouldn't fail on one distro
753# when they succeed on another.
754
755build-no-libwacom@fedora:38:
756  extends:
757    - .fedora-build@template
758  variables:
759    MESON_ARGS: "-Dlibwacom=false"
760
761build-no-libwacom-nodeps@fedora:38:
762  extends:
763    - .fedora-build@template
764  variables:
765    MESON_ARGS: "-Dlibwacom=false"
766  before_script:
767    - dnf remove -y libwacom libwacom-devel
768
769build-docs@fedora:38:
770  extends:
771    - .fedora-build@template
772  variables:
773    MESON_ARGS: "-Ddocumentation=true"
774
775build-no-docs-nodeps@fedora:38:
776  extends:
777    - .fedora-build@template
778  variables:
779    MESON_ARGS: "-Ddocumentation=false"
780  before_script:
781    - dnf remove -y doxygen graphviz
782
783build-no-debuggui@fedora:38:
784  extends:
785    - .fedora-build@template
786  variables:
787    MESON_ARGS: "-Ddebug-gui=false"
788
789build-no-debuggui-nodeps@fedora:38:
790  extends:
791    - .fedora-build@template
792  variables:
793    MESON_ARGS: "-Ddebug-gui=false"
794  before_script:
795    - dnf remove -y gtk3-devel gtk4-devel
796
797build-no-tests@fedora:38:
798  extends:
799    - .fedora-build@template
800  variables:
801    MESON_ARGS: "-Dtests=false"
802
803build-no-tests-nodeps@fedora:38:
804  extends:
805    - .fedora-build@template
806  variables:
807    MESON_ARGS: "-Dtests=false"
808  before_script:
809    - dnf remove -y check-devel
810
811valgrind@fedora:38:
812  extends:
813    - .fedora-build@template
814  variables:
815    MESON_TEST_ARGS: '--suite=valgrind --no-suite=hardware --setup=valgrind'
816
817# Python checks, only run on Fedora
818
819usr-bin-env-python@fedora:38:
820  extends:
821    - .fedora-build@template
822  script:
823    - |
824      if git grep -l '^#!/usr/bin/python'; then
825        echo "Use '/usr/bin/env python3' in the above files";
826        /bin/false
827      fi
828
829python-format@fedora:38:
830  extends:
831    - .fedora-build@template
832  script:
833    - black $(git grep -l '^#!/usr/bin/env python3')
834    - git diff --exit-code || (echo "Please run Black against all Python files" && false)
835
836# A job to check we're actually running all test suites in the CI
837check-test-suites:
838  extends:
839    - .fedora-build@template
840  script:
841    - meson setup builddir
842    - meson introspect builddir --test | jq -r '.[].name' | grep 'libinput-test-suite' | sort > meson-testsuites
843    - |
844      cat <<EOF > ci-testsuites ;
845        libinput-test-suite-touchpad
846        libinput-test-suite-touchpad-tap
847        libinput-test-suite-touchpad-buttons
848        libinput-test-suite-tablet
849        libinput-test-suite-gestures
850        libinput-test-suite-device
851        libinput-test-suite-path
852        libinput-test-suite-udev
853        libinput-test-suite-log
854        libinput-test-suite-misc
855        libinput-test-suite-quirks
856        libinput-test-suite-keyboard
857        libinput-test-suite-pad
858        libinput-test-suite-switch
859        libinput-test-suite-trackball
860        libinput-test-suite-trackpoint
861        libinput-test-suite-totem
862        libinput-test-suite-touch
863        libinput-test-suite-pointer
864      EOF
865    - sort -o ci-testsuites ci-testsuites
866    - diff -u8 -w ci-testsuites meson-testsuites || (echo "Some test suites are not run in the CI" && false)
867  only:
868    changes:
869      - "meson.build"
870      - ".gitlab-ci.yml"
871
872#
873# coverity run
874#
875# This requires the COVERITY_SCAN_TOKEN. Log into scan.coverity.com and get
876# the token from the respective project settings page.
877# Schedule a pipeline and set a variable COVERITY_SCAN_TOKEN with the token value.
878# https://gitlab.freedesktop.org/$CI_PROJECT_PATH/-/pipeline_schedules
879# Email from coverity will be sent to the GITLAB_USER_EMAIL that scheduled the
880# job.
881#
882# Coverity ratelimits submissions and the coverity tools download is about
883# 700M, do not run this too often.
884#
885coverity:
886  extends:
887    - .fdo.distribution-image@debian
888    - .policy
889  stage: build
890  variables:
891    FDO_DISTRIBUTION_VERSION: 'stable'
892    FDO_DISTRIBUTION_TAG: $DEBIAN_TAG
893    # so git-describe works, or should work
894    GIT_DEPTH: 200
895  only:
896    variables:
897      - $COVERITY_SCAN_TOKEN
898  script:
899    - curl https://scan.coverity.com/download/linux64
900        -o /tmp/cov-analysis-linux64.tgz
901        --form project=$CI_PROJECT_NAME
902        --form token=$COVERITY_SCAN_TOKEN
903    - tar xfz /tmp/cov-analysis-linux64.tgz
904    # coverity has special build options in meson, make sure we enable those
905    - meson coverity-build -Ddocumentation=false -Dcoverity=true
906    - cov-analysis-linux64-*/bin/cov-build --dir cov-int  ninja -C coverity-build
907    - tar cfz cov-int.tar.gz cov-int
908    - curl https://scan.coverity.com/builds?project=$CI_PROJECT_NAME
909        --form token=$COVERITY_SCAN_TOKEN --form email=$GITLAB_USER_EMAIL
910        --form file=@cov-int.tar.gz --form version="$(git describe --tags)"
911        --form description="$(git describe --tags) / $CI_COMMIT_TITLE / $CI_COMMIT_REF_NAME:$CI_PIPELINE_ID"
912  artifacts:
913    name: "coverity-submit-data"
914    when: always
915    expire_in: 1 week
916    paths:
917      - cov-int.tar.gz
918  needs:
919    - "debian:stable@container-prep"
920
921#################################################################
922#                                                               #
923#                        distro stage                           #
924#                                                               #
925#################################################################
926
927fedora:37@default-build:
928  stage: distro
929  extends:
930    - .build@template
931    - .fdo.distribution-image@fedora
932  variables:
933    FDO_DISTRIBUTION_VERSION: '37'
934    FDO_DISTRIBUTION_TAG: $FEDORA_TAG
935  needs:
936    - "fedora:37@container-prep"
937
938
939fedora:38@default-build:
940  stage: distro
941  extends:
942    - .build@template
943    - .fdo.distribution-image@fedora
944  variables:
945    FDO_DISTRIBUTION_VERSION: '38'
946    FDO_DISTRIBUTION_TAG: $FEDORA_TAG
947  needs:
948    - "fedora:38@container-prep"
949
950
951debian:stable@default-build:
952  stage: distro
953  extends:
954    - .build@template
955    - .fdo.distribution-image@debian
956  variables:
957    FDO_DISTRIBUTION_VERSION: 'stable'
958    FDO_DISTRIBUTION_TAG: $DEBIAN_TAG
959  needs:
960    - "debian:stable@container-prep"
961
962
963ubuntu:22.04@default-build:
964  stage: distro
965  extends:
966    - .build@template
967    - .fdo.distribution-image@ubuntu
968  variables:
969    FDO_DISTRIBUTION_VERSION: '22.04'
970    FDO_DISTRIBUTION_TAG: $UBUNTU_TAG
971  needs:
972    - "ubuntu:22.04@container-prep"
973
974
975arch:rolling@default-build:
976  stage: distro
977  extends:
978    - .build@template
979    - .fdo.distribution-image@arch
980  variables:
981    FDO_DISTRIBUTION_VERSION: 'rolling'
982    FDO_DISTRIBUTION_TAG: $ARCH_TAG
983  needs:
984    - "arch:rolling@container-prep"
985
986
987alpine:latest@default-build:
988  stage: distro
989  extends:
990    - .build@template
991    - .fdo.distribution-image@alpine
992  variables:
993    FDO_DISTRIBUTION_VERSION: 'latest'
994    FDO_DISTRIBUTION_TAG: $ALPINE_TAG
995    MESON_ARGS: '-Ddocumentation=false' # alpine does not have python-recommonmark
996    MESON_TEST_ARGS: '' # litest-selftest fails on musl
997  needs:
998    - "alpine:latest@container-prep"
999
1000
1001freebsd:13.1@default-build:
1002  stage: distro
1003  extends:
1004    - .build-in-qemu@template
1005    - .fdo.distribution-image@freebsd
1006  variables:
1007    FDO_DISTRIBUTION_VERSION: '13.1'
1008    FDO_DISTRIBUTION_TAG: $FREEBSD_TAG
1009    MESON_ARGS: '-Dtests=false -Ddocumentation=false' # doxygen drags down too many deps
1010    MESON_TEST_ARGS: '' # test suite doesn't work on BSD yet
1011  needs:
1012    - "freebsd:13.1@container-prep"
1013
1014
1015#################################################################
1016#                                                               #
1017#                        deploy stage                           #
1018#                                                               #
1019#################################################################
1020
1021#
1022# Verify that the merge request has the allow-collaboration checkbox ticked
1023#
1024
1025check-merge-request:
1026  extends:
1027    - .fdo.ci-fairy
1028    - .policy
1029  stage: deploy
1030  script:
1031    - ci-fairy check-merge-request --require-allow-collaboration --junit-xml=results.xml
1032  artifacts:
1033    when: on_failure
1034    reports:
1035      junit: results.xml
1036  allow_failure: true
1037
1038build rpm:
1039  extends:
1040    - .fdo.distribution-image@fedora
1041    - .policy
1042  stage: deploy
1043  variables:
1044    FDO_DISTRIBUTION_VERSION: '38'
1045    FDO_DISTRIBUTION_TAG: $FEDORA_TAG
1046  needs:
1047    - "fedora:38@container-prep"
1048  script:
1049    - meson "$MESON_BUILDDIR"
1050    - VERSION=$(meson introspect "$MESON_BUILDDIR" --projectinfo | jq -r .version)
1051    - sed -e "s/@PIPELINEID@/${CI_PIPELINE_ID}/"
1052          -e "s/@GITVERSION@/${CI_COMMIT_SHA}/"
1053          -e "s/@VERSION@/${VERSION}/" .gitlab-ci/libinput.spec.in > libinput.spec
1054    - git config --local user.name 'gitlab CI'
1055    - git config --local user.email 'noreply@nowhere'
1056    - git add libinput.spec && git commit -m 'Add libinput.spec for build testing' libinput.spec
1057    - cd "$MESON_BUILDDIR"
1058    - meson dist --no-test
1059    - rpmbuild -ta meson-dist/libinput*.tar.xz
1060
1061
1062wayland-web:
1063  stage: deploy
1064  trigger: wayland/wayland.freedesktop.org
1065  except:
1066    refs:
1067      - schedules
1068  variables:
1069    MESON_ARGS: '-Ddocumentation=true -Ddebug-gui=false -Dlibwacom=false -Dtests=false'
1070    MESON_BUILDDIR: 'builddir'
1071  only:
1072    refs:
1073      - main
1074    variables:
1075      - $CI_PROJECT_PATH == "libinput/libinput"
1076