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