util: use ck_assert_ptr_eq() instead of ck_assert_ptr_null()
[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 systemd-udev qemu-img qemu-system-x86-core qemu-system-aarch64-core jq python3-click python3-rich'
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-09-02.0'
92   DEBIAN_TAG:  '2022-09-02.0'
93   UBUNTU_TAG:  '2022-09-02.0'
94   ARCH_TAG:    '2022-09-02.0'
95   ALPINE_TAG:  '2022-09-02.0'
96   FREEBSD_TAG: '2022-09-02.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     - .default_artifacts
401   tags:
402     - kvm
403   variables:
404     MESON_BUILDDIR: build_dir
405     B2C_KERNEL: https://gitlab.freedesktop.org/api/v4/projects/libevdev%2Fhid-tools/packages/generic/kernel-x86_64/v5.19/bzImage
406     B2C_VERSION: v0.9.8
407     B2C_IMAGE: $FDO_DISTRIBUTION_IMAGE
408     B2C_COMMAND: .gitlab-ci/start-in-systemd.sh
409   script:
410     # first build in the host container
411     - .gitlab-ci/meson-build.sh --skip-test
412
413     # pull b2c
414     - curl -L -o /app/boot2container https://gitlab.freedesktop.org/mupuf/boot2container/-/raw/v0.9.8/vm2c.py
415     - chmod +x /app/boot2container
416
417     # runs the test suite only
418     - /app/boot2container
419
420 #
421 # Fedora
422 #
423
424 .check_tainted: &check_tainted |
425   # make sure the kernel is not tainted
426   if [[ "$(ssh localhost -p 5555 cat /proc/sys/kernel/tainted)" -gt 0 ]];
427   then
428     echo tainted kernel ;
429     exit 1 ;
430   fi
431
432 # Run meson and meson test in the qemu image
433 .build-in-qemu@template:
434   extends:
435     - .policy
436     - .fdo.distribution-image@fedora
437   tags:
438     - kvm
439   variables:
440     MESON_BUILDDIR: build_dir
441   script:
442     # start our vm, no args required
443     - /app/vmctl start || (echo "Error - Failed to start the VM." && exit 1)
444
445     - *check_tainted
446
447     - "scp -r $PWD vm:"
448     - echo "CI_JOB_ID=\"$CI_JOB_ID\"" > sshenv
449     - echo "CI_JOB_NAME=\"$CI_JOB_NAME\"" >> sshenv
450     - echo "MESON_ARGS=\"$MESON_ARGS\"" >> sshenv
451     - echo "MESON_BUILDDIR=\"$MESON_BUILDDIR\"" >> sshenv
452     - echo "MESON_TEST_ARGS=\"$MESON_TEST_ARGS\"" >> sshenv
453     - echo "NINJA_ARGS=\"$NINJA_ARGS\"" >> sshenv
454     - "scp sshenv vm:~/$CI_PROJECT_NAME/.meson_environment"
455     - /app/vmctl exec "cd $CI_PROJECT_NAME ; .gitlab-ci/meson-build.sh" && touch .success || true
456     # no matter the results of the tests, we want to fetch the logs
457     - scp -r vm:$CI_PROJECT_NAME/$MESON_BUILDDIR .
458
459     - *check_tainted
460
461     - /app/vmctl stop
462
463     - if [[ ! -e .success ]] ;
464       then
465         exit 1 ;
466       fi
467   artifacts:
468     name: "qemu-meson-logs-$CI_JOB_NAME"
469     when: always
470     expire_in: 1 week
471     paths:
472       - $MESON_BUILDDIR/meson-logs
473       - console.out
474     reports:
475       junit: $MESON_BUILDDIR/*junit*.xml
476
477
478 # Run in a test suite. Special variables:
479 # - SUITES: the meson test suites to run, or
480 # - SUITE_NAMES: all elements will be expanded to libinput-test-suite-$value
481 # Set one or the other, not both.
482 .test-suite-vm:
483   extends:
484     - .build-in-b2c@template
485   stage: test-suite
486   variables:
487     # remove the global --no-suite=hardware
488     MESON_TEST_ARGS: ''
489   before_script:
490     - if ! [[ -z $SUITE_NAMES ]]; then SUITES=$(echo $SUITE_NAMES | sed 's/\([^ ]*\)/libinput-test-suite-\1/g'); fi
491     - echo "Testing $SUITES"
492     - export MESON_TEST_ARGS="$MESON_TEST_ARGS $SUITES"
493     - export LITEST_JOBS="2"
494
495
496 .fedora:36@test-suite-vm:
497   extends:
498     - .fdo.distribution-image@fedora
499     - .test-suite-vm
500   variables:
501     FDO_DISTRIBUTION_VERSION: 36
502     FDO_DISTRIBUTION_TAG: $FEDORA_TAG
503   needs:
504     - "fedora:36@container-prep"
505
506
507 vm-touchpad:
508   extends:
509     - .fedora:36@test-suite-vm
510   variables:
511     SUITE_NAMES: 'touchpad'
512
513 vm-touchpad-no-libwacom:
514   extends:
515     - vm-touchpad
516   stage: test-suite-no-libwacom
517   variables:
518     MESON_ARGS: '-Dlibwacom=false'
519
520 vm-tap:
521   extends:
522     - .fedora:36@test-suite-vm
523   variables:
524     SUITE_NAMES: 'touchpad-tap'
525
526 vm-tap-no-libwacom:
527   extends:
528     - vm-tap
529   stage: test-suite-no-libwacom
530   variables:
531     MESON_ARGS: '-Dlibwacom=false'
532
533 vm-touchpad-buttons:
534   extends:
535     - .fedora:36@test-suite-vm
536   variables:
537     SUITE_NAMES: 'touchpad-buttons'
538
539 vm-touchpad-buttons-no-libwacom:
540   extends:
541     - vm-touchpad-buttons
542   stage: test-suite-no-libwacom
543   variables:
544     MESON_ARGS: '-Dlibwacom=false'
545
546 vm-tablet:
547   extends:
548     - .fedora:36@test-suite-vm
549   variables:
550     SUITE_NAMES: 'tablet'
551
552 vm-tablet-no-libwacom:
553   extends:
554     - vm-tablet
555   stage: test-suite-no-libwacom
556   variables:
557     MESON_ARGS: '-Dlibwacom=false'
558
559 vm-gestures-device:
560   extends:
561     - .fedora:36@test-suite-vm
562   variables:
563     SUITE_NAMES: 'gestures device'
564
565 vm-gestures-device-no-libwacom:
566   extends:
567     - vm-gestures-device
568   stage: test-suite-no-libwacom
569   variables:
570     MESON_ARGS: '-Dlibwacom=false'
571
572 vm-backends:
573   extends:
574     - .fedora:36@test-suite-vm
575   variables:
576     SUITE_NAMES: 'path udev'
577
578 vm-backends-no-libwacom:
579   extends:
580     - vm-backends
581   stage: test-suite-no-libwacom
582   variables:
583     MESON_ARGS: '-Dlibwacom=false'
584
585 vm-misc:
586   extends:
587     - .fedora:36@test-suite-vm
588   variables:
589     SUITE_NAMES: 'log misc quirks'
590
591 vm-misc-no-libwacom:
592   extends:
593     - vm-misc
594   stage: test-suite-no-libwacom
595   variables:
596     MESON_ARGS: '-Dlibwacom=false'
597
598 vm-other devices:
599   extends:
600     - .fedora:36@test-suite-vm
601   variables:
602     SUITE_NAMES: 'keyboard pad switch trackball trackpoint totem touch'
603
604 vm-other devices-no-libwacom:
605   extends:
606     - vm-other devices
607   stage: test-suite-no-libwacom
608   variables:
609     MESON_ARGS: '-Dlibwacom=false'
610
611 vm-pointer:
612   extends:
613     - .fedora:36@test-suite-vm
614   variables:
615     SUITE_NAMES: 'pointer'
616
617 vm-pointer-no-libwacom:
618   extends:
619     - vm-pointer
620   stage: test-suite-no-libwacom
621   variables:
622     MESON_ARGS: '-Dlibwacom=false'
623
624
625 vm-valgrind-touchpad:
626   stage: valgrind
627   extends:
628     - vm-touchpad
629   variables:
630     MESON_TEST_ARGS: '--setup=valgrind'
631     LITEST_JOBS: 4
632
633 vm-valgrind-tap:
634   stage: valgrind
635   extends:
636     - vm-tap
637   variables:
638     MESON_TEST_ARGS: '--setup=valgrind'
639     LITEST_JOBS: 4
640
641 vm-valgrind-touchpad-buttons:
642   stage: valgrind
643   extends:
644     - vm-touchpad-buttons
645   variables:
646     MESON_TEST_ARGS: '--setup=valgrind'
647     LITEST_JOBS: 4
648
649 vm-valgrind-tablet:
650   stage: valgrind
651   extends:
652     - vm-tablet
653   variables:
654     MESON_TEST_ARGS: '--setup=valgrind'
655     LITEST_JOBS: 4
656
657 vm-valgrind-gestures-device:
658   stage: valgrind
659   extends:
660     - vm-gestures-device
661   variables:
662     MESON_TEST_ARGS: '--setup=valgrind'
663     LITEST_JOBS: 4
664
665 vm-valgrind-backends:
666   stage: valgrind
667   extends:
668     - vm-backends
669   variables:
670     MESON_TEST_ARGS: '--setup=valgrind'
671     LITEST_JOBS: 4
672
673 vm-valgrind-misc:
674   stage: valgrind
675   extends:
676     - vm-misc
677   variables:
678     MESON_TEST_ARGS: '--setup=valgrind'
679     LITEST_JOBS: 4
680
681 vm-valgrind-other devices:
682   stage: valgrind
683   extends:
684     - vm-other devices
685   variables:
686     MESON_TEST_ARGS: '--setup=valgrind'
687     LITEST_JOBS: 4
688
689 vm-valgrind-pointer:
690   stage: valgrind
691   extends:
692     - vm-pointer
693   variables:
694     MESON_TEST_ARGS: '--setup=valgrind'
695     LITEST_JOBS: 4
696
697
698 .fedora-build@template:
699   extends:
700     - .fdo.distribution-image@fedora
701     - .build@template
702   variables:
703     FDO_DISTRIBUTION_VERSION: '36'
704     FDO_DISTRIBUTION_TAG: $FEDORA_TAG
705   needs:
706     - "fedora:36@container-prep"
707
708 default-build-release@fedora:36:
709   stage: distro
710   extends:
711     - .fedora-build@template
712   variables:
713     MESON_ARGS: "-Dbuildtype=release"
714     CFLAGS: "-Werror"
715
716 scan-build@fedora:36:
717   extends:
718     - .fedora-build@template
719   variables:
720     NINJA_ARGS: ''
721     MESON_TEST_ARGS: ''
722   before_script:
723     - dnf install -y clang-analyzer
724   script:
725     - .gitlab-ci/meson-build.sh
726     - export SCANBUILD="$PWD/.gitlab-ci/scanbuild-wrapper.sh"
727     - ninja -C "$MESON_BUILDDIR" scan-build
728   after_script:
729     - .gitlab-ci/scanbuild-plist-to-junit.py "$MESON_BUILDDIR"/meson-logs/scanbuild/ > "$MESON_BUILDDIR"/junit-scan-build.xml
730
731 # Below jobs are build option combinations. We only
732 # run them on one image, they shouldn't fail on one distro
733 # when they succeed on another.
734
735 build-no-libwacom@fedora:36:
736   extends:
737     - .fedora-build@template
738   variables:
739     MESON_ARGS: "-Dlibwacom=false"
740
741 build-no-libwacom-nodeps@fedora:36:
742   extends:
743     - .fedora-build@template
744   variables:
745     MESON_ARGS: "-Dlibwacom=false"
746   before_script:
747     - dnf remove -y libwacom libwacom-devel
748
749 build-docs@fedora:36:
750   extends:
751     - .fedora-build@template
752   variables:
753     MESON_ARGS: "-Ddocumentation=true"
754
755 build-no-docs-nodeps@fedora:36:
756   extends:
757     - .fedora-build@template
758   variables:
759     MESON_ARGS: "-Ddocumentation=false"
760   before_script:
761     - dnf remove -y doxygen graphviz
762
763 build-no-debuggui@fedora:36:
764   extends:
765     - .fedora-build@template
766   variables:
767     MESON_ARGS: "-Ddebug-gui=false"
768
769 build-no-debuggui-nodeps@fedora:36:
770   extends:
771     - .fedora-build@template
772   variables:
773     MESON_ARGS: "-Ddebug-gui=false"
774   before_script:
775     - dnf remove -y gtk3-devel gtk4-devel
776
777 build-no-tests@fedora:36:
778   extends:
779     - .fedora-build@template
780   variables:
781     MESON_ARGS: "-Dtests=false"
782
783 build-no-tests-nodeps@fedora:36:
784   extends:
785     - .fedora-build@template
786   variables:
787     MESON_ARGS: "-Dtests=false"
788   before_script:
789     - dnf remove -y check-devel
790
791 valgrind@fedora:36:
792   extends:
793     - .fedora-build@template
794   variables:
795     MESON_TEST_ARGS: '--suite=valgrind --no-suite=hardware --setup=valgrind'
796   before_script:
797     - dnf install -y valgrind
798
799 # Python checks, only run on Fedora
800
801 usr-bin-env-python@fedora:36:
802   extends:
803     - .fedora-build@template
804   script:
805     - |
806       if git grep -l '^#!/usr/bin/python'; then
807         echo "Use '/usr/bin/env python3' in the above files";
808         /bin/false
809       fi
810
811 python-format@fedora:36:
812   extends:
813     - .fedora-build@template
814   before_script:
815     - dnf install -y black
816   script:
817     - black $(git grep -l '^#!/usr/bin/env python3')
818     - git diff --exit-code || (echo "Please run Black against all Python files" && false)
819
820 # A job to check we're actually running all test suites in the CI
821 check-test-suites:
822   extends:
823     - .fedora-build@template
824   before_script:
825     - dnf install -y jq
826   script:
827     - meson builddir
828     - meson introspect builddir --test | jq -r '.[].name' | grep 'libinput-test-suite' | sort > meson-testsuites
829     - |
830       cat <<EOF > ci-testsuites ;
831         libinput-test-suite-touchpad
832         libinput-test-suite-touchpad-tap
833         libinput-test-suite-touchpad-buttons
834         libinput-test-suite-tablet
835         libinput-test-suite-gestures
836         libinput-test-suite-device
837         libinput-test-suite-path
838         libinput-test-suite-udev
839         libinput-test-suite-log
840         libinput-test-suite-misc
841         libinput-test-suite-quirks
842         libinput-test-suite-keyboard
843         libinput-test-suite-pad
844         libinput-test-suite-switch
845         libinput-test-suite-trackball
846         libinput-test-suite-trackpoint
847         libinput-test-suite-totem
848         libinput-test-suite-touch
849         libinput-test-suite-pointer
850       EOF
851     - sort -o ci-testsuites ci-testsuites
852     - diff -u8 -w ci-testsuites meson-testsuites || (echo "Some test suites are not run in the CI" && false)
853   only:
854     changes:
855       - "meson.build"
856       - ".gitlab-ci.yml"
857
858 #
859 # coverity run
860 #
861 # This requires the COVERITY_SCAN_TOKEN. Log into scan.coverity.com and get
862 # the token from the respective project settings page.
863 # Schedule a pipeline and set a variable COVERITY_SCAN_TOKEN with the token value.
864 # https://gitlab.freedesktop.org/$CI_PROJECT_PATH/-/pipeline_schedules
865 # Email from coverity will be sent to the GITLAB_USER_EMAIL that scheduled the
866 # job.
867 #
868 # Coverity ratelimits submissions and the coverity tools download is about
869 # 700M, do not run this too often.
870 #
871 coverity:
872   extends:
873     - .fdo.distribution-image@debian
874     - .policy
875   stage: build
876   variables:
877     FDO_DISTRIBUTION_VERSION: 'stable'
878     FDO_DISTRIBUTION_TAG: $DEBIAN_TAG
879     # so git-describe works, or should work
880     GIT_DEPTH: 200
881   only:
882     variables:
883       - $COVERITY_SCAN_TOKEN
884   script:
885     - curl https://scan.coverity.com/download/linux64
886         -o /tmp/cov-analysis-linux64.tgz
887         --form project=$CI_PROJECT_NAME
888         --form token=$COVERITY_SCAN_TOKEN
889     - tar xfz /tmp/cov-analysis-linux64.tgz
890     # coverity has special build options in meson, make sure we enable those
891     - meson coverity-build -Ddocumentation=false -Dcoverity=true
892     - cov-analysis-linux64-*/bin/cov-build --dir cov-int  ninja -C coverity-build
893     - tar cfz cov-int.tar.gz cov-int
894     - curl https://scan.coverity.com/builds?project=$CI_PROJECT_NAME
895         --form token=$COVERITY_SCAN_TOKEN --form email=$GITLAB_USER_EMAIL
896         --form file=@cov-int.tar.gz --form version="$(git describe --tags)"
897         --form description="$(git describe --tags) / $CI_COMMIT_TITLE / $CI_COMMIT_REF_NAME:$CI_PIPELINE_ID"
898   artifacts:
899     name: "coverity-submit-data"
900     when: always
901     expire_in: 1 week
902     paths:
903       - cov-int.tar.gz
904   needs:
905     - "debian:stable@container-prep"
906
907 #################################################################
908 #                                                               #
909 #                        distro stage                           #
910 #                                                               #
911 #################################################################
912
913 fedora:35@default-build:
914   stage: distro
915   extends:
916     - .build@template
917     - .fdo.distribution-image@fedora
918   variables:
919     FDO_DISTRIBUTION_VERSION: '35'
920     FDO_DISTRIBUTION_TAG: $FEDORA_TAG
921   needs:
922     - "fedora:35@container-prep"
923
924
925 fedora:36@default-build:
926   stage: distro
927   extends:
928     - .build@template
929     - .fdo.distribution-image@fedora
930   variables:
931     FDO_DISTRIBUTION_VERSION: '36'
932     FDO_DISTRIBUTION_TAG: $FEDORA_TAG
933   needs:
934     - "fedora:36@container-prep"
935
936
937 debian:stable@default-build:
938   stage: distro
939   extends:
940     - .build@template
941     - .fdo.distribution-image@debian
942   variables:
943     FDO_DISTRIBUTION_VERSION: 'stable'
944     FDO_DISTRIBUTION_TAG: $DEBIAN_TAG
945   needs:
946     - "debian:stable@container-prep"
947
948
949 ubuntu:22.04@default-build:
950   stage: distro
951   extends:
952     - .build@template
953     - .fdo.distribution-image@ubuntu
954   variables:
955     FDO_DISTRIBUTION_VERSION: '22.04'
956     FDO_DISTRIBUTION_TAG: $UBUNTU_TAG
957   needs:
958     - "ubuntu:22.04@container-prep"
959
960
961 arch:rolling@default-build:
962   stage: distro
963   extends:
964     - .build@template
965     - .fdo.distribution-image@arch
966   variables:
967     FDO_DISTRIBUTION_VERSION: 'rolling'
968     FDO_DISTRIBUTION_TAG: $ARCH_TAG
969   needs:
970     - "arch:rolling@container-prep"
971
972
973 alpine:latest@default-build:
974   stage: distro
975   extends:
976     - .build@template
977     - .fdo.distribution-image@alpine
978   variables:
979     FDO_DISTRIBUTION_VERSION: 'latest'
980     FDO_DISTRIBUTION_TAG: $ALPINE_TAG
981     MESON_ARGS: '-Ddocumentation=false' # alpine does not have python-recommonmark
982     MESON_TEST_ARGS: '' # litest-selftest fails on musl
983   needs:
984     - "alpine:latest@container-prep"
985
986
987 freebsd:13.0@default-build:
988   stage: distro
989   extends:
990     - .build-in-qemu@template
991     - .fdo.distribution-image@freebsd
992   variables:
993     FDO_DISTRIBUTION_VERSION: '13.0'
994     FDO_DISTRIBUTION_TAG: $FREEBSD_TAG
995     MESON_ARGS: '-Dtests=false -Ddocumentation=false' # doxygen drags down too many deps
996     MESON_TEST_ARGS: '' # test suite doesn't work on BSD yet
997   needs:
998     - "freebsd:13.0@container-prep"
999
1000
1001 #################################################################
1002 #                                                               #
1003 #                        deploy stage                           #
1004 #                                                               #
1005 #################################################################
1006
1007 #
1008 # Verify that the merge request has the allow-collaboration checkbox ticked
1009 #
1010
1011 check-merge-request:
1012   extends:
1013     - .fdo.ci-fairy
1014     - .policy
1015   stage: deploy
1016   script:
1017     - ci-fairy check-merge-request --require-allow-collaboration --junit-xml=results.xml
1018   artifacts:
1019     when: on_failure
1020     reports:
1021       junit: results.xml
1022   allow_failure: true
1023
1024 build rpm:
1025   extends:
1026     - .fdo.distribution-image@fedora
1027     - .policy
1028   stage: deploy
1029   variables:
1030     FDO_DISTRIBUTION_VERSION: '36'
1031     FDO_DISTRIBUTION_TAG: $FEDORA_TAG
1032   needs:
1033     - "fedora:36@container-prep"
1034   script:
1035     - dnf install -y rpmdevtools jq
1036     - meson "$MESON_BUILDDIR"
1037     - VERSION=$(meson introspect "$MESON_BUILDDIR" --projectinfo | jq -r .version)
1038     - sed -e "s/@PIPELINEID@/${CI_PIPELINE_ID}/"
1039           -e "s/@GITVERSION@/${CI_COMMIT_SHA}/"
1040           -e "s/@VERSION@/${VERSION}/" .gitlab-ci/libinput.spec.in > libinput.spec
1041     - git config --local user.name 'gitlab CI'
1042     - git config --local user.email 'noreply@nowhere'
1043     - git add libinput.spec && git commit -m 'Add libinput.spec for build testing' libinput.spec
1044     - cd "$MESON_BUILDDIR"
1045     - meson dist --no-test
1046     - rpmbuild -ta meson-dist/libinput*.tar.xz
1047
1048
1049 wayland-web:
1050   stage: deploy
1051   trigger: wayland/wayland.freedesktop.org
1052   except:
1053     refs:
1054       - schedules
1055   variables:
1056     MESON_ARGS: '-Ddocumentation=true -Ddebug-gui=false -Dlibwacom=false -Dtests=false'
1057     MESON_BUILDDIR: 'builddir'
1058   only:
1059     refs:
1060       - main
1061     variables:
1062       - $CI_PROJECT_PATH == "libinput/libinput"