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