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