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