gitlab CI: hook up junit test reports to the meson results
[platform/upstream/libevdev.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 .templates_sha: &template_sha b7030c2cd0d6ccc5f6d4f8299bafa4daa9240d71 # see https://docs.gitlab.com/ee/ci/yaml/#includefile
10
11 include:
12   # Alpine container builder template
13   - project: 'wayland/ci-templates'
14     ref: *template_sha
15     file: '/templates/alpine.yml'
16   # Arch container builder template
17   - project: 'wayland/ci-templates'
18     ref: *template_sha
19     file: '/templates/arch.yml'
20   # Centos container builder template
21   - project: 'wayland/ci-templates'
22     ref: *template_sha
23     file: '/templates/centos.yml'
24   # Debian container builder template
25   - project: 'wayland/ci-templates'
26     ref: *template_sha
27     file: '/templates/debian.yml'
28   # Fedora container builder template
29   - project: 'wayland/ci-templates'
30     ref: *template_sha
31     file: '/templates/fedora.yml'
32   # Ubuntu container builder template
33   - project: 'wayland/ci-templates'
34     ref: *template_sha
35     file: '/templates/ubuntu.yml'
36
37 stages:
38   - prep             # rebuild the container images if there is a change
39   - build            # for actually building and testing things in a container
40   - VM               # for running the test suite in a VM
41   - autotools        # distribution builds with autotools
42   - meson            # distribution builds with meson
43   - tarballs         # tarball builds
44   - container_clean  # clean up unused container images
45
46 variables:
47   ###############################################################################
48   # This is the list of packages required to build libevdev with the default    #
49   # configuration.                                                              #
50   #                                                                             #
51   # Run dnf install/apt-get install/.. with the list of packages for your       #
52   # distribution                                                                #
53   ###############################################################################
54   FEDORA_RPMS: 'git gcc gcc-c++ meson automake autoconf libtool make pkgconfig  python3 check-devel valgrind binutils doxygen xz clang-analyzer'
55   CENTOS_RPMS: 'git gcc gcc-c++       automake autoconf libtool make pkgconfig  python3 check-devel valgrind binutils xz'
56   UBUNTU_DEBS: 'git gcc g++     meson automake autoconf libtool make pkg-config python3 check       valgrind binutils doxygen xz-utils'
57   DEBIAN_DEBS: $UBUNTU_DEBS
58   ARCH_PKGS:   'git gcc         meson automake autoconf libtool make pkgconfig  python3 check       valgrind binutils doxygen'
59   ALPINE_PKGS: 'git gcc g++     meson automake autoconf libtool make pkgconfig  python3 check-dev   valgrind binutils doxygen xz linux-headers'
60   ############################ end of package lists #############################
61   # these tags should be updated each time the list of packages is updated
62   # changing these will force rebuilding the associated image
63   # Note: these tags have no meaning and are not tied to a particular
64   # libevdev version
65   FEDORA_TAG: '2020-02-24.0'
66   CENTOS_TAG: '2020-02-24.0'
67   DEBIAN_TAG: '2020-02-24.0'
68   UBUNTU_TAG: '2020-02-24.0'
69   ARCH_TAG:   '2020-02-24.0'
70   ALPINE_TAG: '2020-02-24.0'
71   QEMU_TAG:   'qemu-2020-02-24.0'
72
73   UPSTREAM_REPO: libevdev/libevdev
74   BUILDAH_IMAGE: $CI_REGISTRY/wayland/ci-templates/buildah:latest
75   FEDORA_CONTAINER_IMAGE: $CI_REGISTRY_IMAGE/fedora/$FEDORA_VERSION:$FEDORA_TAG
76   CENTOS_CONTAINER_IMAGE: $CI_REGISTRY_IMAGE/centos/$CENTOS_VERSION:$CENTOS_TAG
77   UBUNTU_CONTAINER_IMAGE: $CI_REGISTRY_IMAGE/ubuntu/$UBUNTU_VERSION:$UBUNTU_TAG
78   DEBIAN_CONTAINER_IMAGE: $CI_REGISTRY_IMAGE/debian/$DEBIAN_VERSION:$DEBIAN_TAG
79   ARCH_CONTAINER_IMAGE:   $CI_REGISTRY_IMAGE/archlinux/rolling:$ARCH_TAG
80   ALPINE_CONTAINER_IMAGE: $CI_REGISTRY_IMAGE/alpine/latest:$ALPINE_TAG
81   QEMU_CONTAINER_IMAGE:   $CI_REGISTRY_IMAGE/fedora/$FEDORA_VERSION:$QEMU_TAG
82
83   LIBEVDEV_SKIP_ROOT_TESTS: 1
84   GIT_DEPTH: 1
85   MESON_BUILDDIR: 'build dir'
86
87 .default_artifacts:
88   artifacts:
89     paths:
90       - _build/test/test-suite.log
91       - $MESON_BUILDDIR/meson-logs/
92     expire_in: 1 week
93     when: on_failure
94     reports:
95       junit: junit-*.xml
96
97 .autotools_build:
98   extends:
99     - .default_artifacts
100   script:
101     - mkdir _build
102     - pushd _build > /dev/null
103     - ../autogen.sh --disable-silent-rules $CONFIGURE_FLAGS
104     - make
105     - make check
106     - if ! [[ -z "$MAKE_ARGS" ]]; then make $MAKE_ARGS; fi
107     - popd > /dev/null
108
109 .meson_build:
110   extends:
111     - .default_artifacts
112   script:
113     - meson "$MESON_BUILDDIR" $MESON_ARGS
114     - ninja -C "$MESON_BUILDDIR" $NINJA_ARGS
115     - if ! [[ -z "$MESON_TEST_ARGS" ]]; then
116         meson test -C "$MESON_BUILDDIR" $MESON_TEST_ARGS;
117       fi
118
119 #################################################################
120 #                                                               #
121 #                          prep stage                           #
122 #                                                               #
123 #################################################################
124
125 # Re-generate the CI script and make sure it's the one currently checked in
126 # If this job fails, re-generate the gitlab-ci.yml script, see
127 # $SRCDIR/.gitlab-ci/generate-gitlab-ci.py
128 #
129 check-ci-script:
130   image: golang:alpine
131   stage: prep
132   before_script:
133     - apk add python3 git
134     - pip3 install --user jinja2 PyYAML
135   script:
136     - python3 ./.gitlab-ci/generate-gitlab-ci.py
137     - git diff --exit-code && exit 0 || true
138     - echo "Committed gitlab-ci.yml differs from generated gitlab-ci.yml. Please verify"
139     - exit 1
140
141 check-commit:
142   image: golang:alpine
143   stage: prep
144   before_script:
145     - apk add python3 git
146   script:
147     - pip3 install GitPython
148     - pip3 install pytest
149     - |
150       pytest --junitxml=results.xml \
151              --tb=line \
152              --assert=plain \
153              ./.gitlab-ci/check-commit.py
154   except:
155     - master@libevdev/libevdev
156   variables:
157     GIT_DEPTH: 100
158   artifacts:
159     reports:
160       junit: results.xml
161
162 .pull_upstream_or_rebuild:
163   before_script:
164     # log in to the registry
165     - podman login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
166
167     # get the full container image name (DISTRIB_VERSION still has indirections)
168     - IMAGE=$(eval echo "$DISTRIB_FLAVOR/$DISTRIB_VERSION:$TAG")
169
170     - |
171       # force rebuild if schedule, reuse otherwise
172       if [[ $CI_PIPELINE_SOURCE != "schedule" ]] ;
173       then
174         # pull the latest upstream image if it exists
175         skopeo copy docker://$CI_REGISTRY/$UPSTREAM_REPO/$IMAGE \
176                     docker://$CI_REGISTRY_IMAGE/$IMAGE && exit 0 || true ;
177
178         # check if our image is already in the current registry
179         skopeo inspect docker://$CI_REGISTRY_IMAGE/$IMAGE > /dev/null && exit 0 || true ;
180       fi
181
182 fedora:31@qemu-prep:
183   extends:
184     - .fedora@qemu-build
185     - .pull_upstream_or_rebuild
186   stage: prep
187   tags:
188     - kvm
189   variables:
190     GIT_STRATEGY: none
191     FEDORA_VERSION: 31
192     FEDORA_TAG: $QEMU_TAG
193     DISTRIB_FLAVOR: fedora
194     DISTRIB_VERSION: $FEDORA_VERSION
195     TAG: $QEMU_TAG
196   allow_failure: true
197
198
199 ### fedora 30
200 fedora:30@container-prep:
201   extends:
202     - .fedora@container-build
203     - .pull_upstream_or_rebuild
204   stage: prep
205   variables:
206     GIT_STRATEGY: none
207     FEDORA_VERSION: '30'
208     DISTRIB_FLAVOR: fedora
209     DISTRIB_VERSION: $FEDORA_VERSION
210     TAG: $FEDORA_TAG
211
212
213 ### fedora 31
214 fedora:31@container-prep:
215   extends:
216     - .fedora@container-build
217     - .pull_upstream_or_rebuild
218   stage: prep
219   variables:
220     GIT_STRATEGY: none
221     FEDORA_VERSION: '31'
222     DISTRIB_FLAVOR: fedora
223     DISTRIB_VERSION: $FEDORA_VERSION
224     TAG: $FEDORA_TAG
225
226
227 ### ubuntu 19.10
228 ubuntu:19.10@container-prep:
229   extends:
230     - .ubuntu@container-build
231     - .pull_upstream_or_rebuild
232   stage: prep
233   variables:
234     GIT_STRATEGY: none
235     UBUNTU_VERSION: '19.10'
236     DISTRIB_FLAVOR: ubuntu
237     DISTRIB_VERSION: $UBUNTU_VERSION
238     TAG: $UBUNTU_TAG
239
240
241 ### ubuntu 19.04
242 ubuntu:19.04@container-prep:
243   extends:
244     - .ubuntu@container-build
245     - .pull_upstream_or_rebuild
246   stage: prep
247   variables:
248     GIT_STRATEGY: none
249     UBUNTU_VERSION: '19.04'
250     DISTRIB_FLAVOR: ubuntu
251     DISTRIB_VERSION: $UBUNTU_VERSION
252     TAG: $UBUNTU_TAG
253
254
255 ### debian stable
256 debian:stable@container-prep:
257   extends:
258     - .debian@container-build
259     - .pull_upstream_or_rebuild
260   stage: prep
261   variables:
262     GIT_STRATEGY: none
263     DEBIAN_VERSION: 'stable'
264     DISTRIB_FLAVOR: debian
265     DISTRIB_VERSION: $DEBIAN_VERSION
266     TAG: $DEBIAN_TAG
267
268
269 ### debian sid
270 debian:sid@container-prep:
271   extends:
272     - .debian@container-build
273     - .pull_upstream_or_rebuild
274   stage: prep
275   variables:
276     GIT_STRATEGY: none
277     DEBIAN_VERSION: 'sid'
278     DISTRIB_FLAVOR: debian
279     DISTRIB_VERSION: $DEBIAN_VERSION
280     TAG: $DEBIAN_TAG
281
282
283 ### centos 7
284 centos:7@container-prep:
285   extends:
286     - .centos@container-build
287     - .pull_upstream_or_rebuild
288   stage: prep
289   variables:
290     GIT_STRATEGY: none
291     CENTOS_VERSION: '7'
292     DISTRIB_FLAVOR: centos
293     DISTRIB_VERSION: $CENTOS_VERSION
294     TAG: $CENTOS_TAG
295
296
297 ### centos 8
298 centos:8@container-prep:
299   extends:
300     - .centos@container-build
301     - .pull_upstream_or_rebuild
302   stage: prep
303   variables:
304     GIT_STRATEGY: none
305     CENTOS_VERSION: '8'
306     DISTRIB_FLAVOR: centos
307     DISTRIB_VERSION: $CENTOS_VERSION
308     TAG: $CENTOS_TAG
309
310
311 ### arch rolling
312 arch:rolling@container-prep:
313   extends:
314     - .arch@container-build
315     - .pull_upstream_or_rebuild
316   stage: prep
317   variables:
318     GIT_STRATEGY: none
319     ARCH_VERSION: 'rolling'
320     DISTRIB_FLAVOR: arch
321     DISTRIB_VERSION: $ARCH_VERSION
322     TAG: $ARCH_TAG
323
324
325 ### alpine latest
326 alpine:latest@container-prep:
327   extends:
328     - .alpine@container-build
329     - .pull_upstream_or_rebuild
330   stage: prep
331   variables:
332     GIT_STRATEGY: none
333     ALPINE_VERSION: 'latest'
334     DISTRIB_FLAVOR: alpine
335     DISTRIB_VERSION: $ALPINE_VERSION
336     TAG: $ALPINE_TAG
337
338
339 #################################################################
340 #                                                               #
341 #                   container clean stage                       #
342 #                 run during the clean stage                    #
343 #                                                               #
344 #################################################################
345
346 #
347 # This stage will look for the container images we currently have in
348 # the registry and will remove any that are not tagged with the provided
349 # $container_image:$tag
350 #
351 .container-clean:
352   stage: container_clean
353   image: $BUILDAH_IMAGE
354   script:
355     # get the full container image name (CURRENT_CONTAINER_IMAGE still has indirections)
356     - CONTAINER_IMAGE=$(eval echo "$CURRENT_CONTAINER_IMAGE")
357     - GITLAB=$(echo $CI_PROJECT_URL | cut -f3 -d/)
358     - REPOSITORY=$(echo $CONTAINER_IMAGE | cut -f2- -d/ | cut -f1 -d:)
359     - IMAGE_PATH=$(echo $CONTAINER_IMAGE | cut -f1 -d:)
360     - LATEST_TAG=$(echo $CONTAINER_IMAGE | cut -f2 -d:)
361
362     # log in to the registry (read only)
363     - podman login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
364
365     # get the r/w token from the settings to access the registry
366     #
367     # each developer needs to register a secret variable that contains
368     # a personal token with api access. The token
369     # - must be named PERSONAL_TOKEN_$USER (for example PERSONAL_TOKEN_bentiss)
370     # - must be registered in the CI/CD Variables section as type file
371     # - value must be a netrc file as a single-line string:
372     #   default login <user> password <token value>
373     #   e.g. "default login bentiss password 1235abcde"
374     - tokenname="PERSONAL_TOKEN_$GITLAB_USER_LOGIN"
375     - netrcfile=$(eval echo "\$$tokenname")
376     - if [[ ! -f "$netrcfile" ]]; then
377          echo "No netrc file found or token is missing, skipping job" && false;
378       fi
379
380     # request a token for the registry API
381     - REGISTRY_TOKEN=$(curl https://$GITLAB/jwt/auth --get
382                              --silent --show-error
383                              -d client_id=docker
384                              -d offline_token=true
385                              -d service=container_registry
386                              -d "scope=repository:$REPOSITORY:pull,*"
387                              --fail
388                              --netrc-file "$netrcfile"
389                              | sed -r 's/(\{"token":"|"\})//g')
390
391     # get the digest of the latest image
392     - LATEST_MANIFEST=$(skopeo inspect docker://$IMAGE_PATH:$LATEST_TAG | jq -r '.Digest')
393
394     # get the list of tags
395     - TAGS=$(skopeo inspect docker://$IMAGE_PATH:$LATEST_TAG | jq -r '.RepoTags[]')
396     # FIXME: is the above command working properly? If not, use below:
397     # - TAGS=$(curl -X GET -H "accept:application/vnd.docker.distribution.manifest.v2+json"
398     #                      -H "authorization:Bearer $REGISTRY_TOKEN"
399     #                      https://$CI_REGISTRY/v2/$REPOSITORY/tags/list | jq -r '.tags[]')
400
401     # iterate over the tags
402     - for tag in $TAGS;
403       do
404         MANIFEST=$(skopeo inspect docker://$IMAGE_PATH:$tag | jq -r '.Digest');
405         if test x"$MANIFEST" != x"$LATEST_MANIFEST";
406           then
407             echo removing $tag as $MANIFEST;
408             curl https://$CI_REGISTRY/v2/$REPOSITORY/manifests/$MANIFEST --silent
409                  -H "accept:application/vnd.docker.distribution.manifest.v2+json"
410                  -H "authorization:Bearer $REGISTRY_TOKEN"
411                  --fail --show-error -X DELETE || true
412           ;fi
413       ;done
414   dependencies: []
415   allow_failure: true
416   only:
417     - schedules
418
419
420 ### fedora 30
421 fedora:30@container-clean:
422   extends: .container-clean
423   variables:
424     GIT_STRATEGY: none
425     FEDORA_VERSION: '30'
426     CURRENT_CONTAINER_IMAGE: $FEDORA_CONTAINER_IMAGE
427
428
429 ### fedora 31
430 fedora:31@container-clean:
431   extends: .container-clean
432   variables:
433     GIT_STRATEGY: none
434     FEDORA_VERSION: '31'
435     CURRENT_CONTAINER_IMAGE: $FEDORA_CONTAINER_IMAGE
436
437
438 ### ubuntu 19.10
439 ubuntu:19.10@container-clean:
440   extends: .container-clean
441   variables:
442     GIT_STRATEGY: none
443     UBUNTU_VERSION: '19.10'
444     CURRENT_CONTAINER_IMAGE: $UBUNTU_CONTAINER_IMAGE
445
446
447 ### ubuntu 19.04
448 ubuntu:19.04@container-clean:
449   extends: .container-clean
450   variables:
451     GIT_STRATEGY: none
452     UBUNTU_VERSION: '19.04'
453     CURRENT_CONTAINER_IMAGE: $UBUNTU_CONTAINER_IMAGE
454
455
456 ### debian stable
457 debian:stable@container-clean:
458   extends: .container-clean
459   variables:
460     GIT_STRATEGY: none
461     DEBIAN_VERSION: 'stable'
462     CURRENT_CONTAINER_IMAGE: $DEBIAN_CONTAINER_IMAGE
463
464
465 ### debian sid
466 debian:sid@container-clean:
467   extends: .container-clean
468   variables:
469     GIT_STRATEGY: none
470     DEBIAN_VERSION: 'sid'
471     CURRENT_CONTAINER_IMAGE: $DEBIAN_CONTAINER_IMAGE
472
473
474 ### centos 7
475 centos:7@container-clean:
476   extends: .container-clean
477   variables:
478     GIT_STRATEGY: none
479     CENTOS_VERSION: '7'
480     CURRENT_CONTAINER_IMAGE: $CENTOS_CONTAINER_IMAGE
481
482
483 ### centos 8
484 centos:8@container-clean:
485   extends: .container-clean
486   variables:
487     GIT_STRATEGY: none
488     CENTOS_VERSION: '8'
489     CURRENT_CONTAINER_IMAGE: $CENTOS_CONTAINER_IMAGE
490
491
492 ### arch rolling
493 arch:rolling@container-clean:
494   extends: .container-clean
495   variables:
496     GIT_STRATEGY: none
497     ARCH_VERSION: 'rolling'
498     CURRENT_CONTAINER_IMAGE: $ARCH_CONTAINER_IMAGE
499
500
501 ### alpine latest
502 alpine:latest@container-clean:
503   extends: .container-clean
504   variables:
505     GIT_STRATEGY: none
506     ALPINE_VERSION: 'latest'
507     CURRENT_CONTAINER_IMAGE: $ALPINE_CONTAINER_IMAGE
508
509
510 #################################################################
511 #                                                               #
512 #                       build stage                             #
513 #                                                               #
514 #################################################################
515
516 .autotools-build@template:
517   extends:
518     - .autotools_build
519   stage: build
520   dependencies: []
521   variables:
522     MAKE_ARGS: "distcheck"
523
524 .meson-build@template:
525   extends:
526     - .meson_build
527   stage: build
528   dependencies: []
529   variables:
530     NINJA_ARGS: "dist"
531
532
533 fedora:30@autotools-build:
534   extends: .autotools-build@template
535   stage: autotools
536   image: $FEDORA_CONTAINER_IMAGE
537   variables:
538     FEDORA_VERSION: '30'
539   needs: ['fedora:30@container-prep']
540
541 fedora:30@meson-build:
542   extends: .meson-build@template
543   stage: meson
544   image: $FEDORA_CONTAINER_IMAGE
545   variables:
546     FEDORA_VERSION: '30'
547   needs: ['fedora:30@container-prep']
548
549
550 fedora:31@autotools-build:
551   extends: .autotools-build@template
552   stage: autotools
553   image: $FEDORA_CONTAINER_IMAGE
554   variables:
555     FEDORA_VERSION: '31'
556   needs: ['fedora:31@container-prep']
557
558 fedora:31@meson-build:
559   extends: .meson-build@template
560   stage: meson
561   image: $FEDORA_CONTAINER_IMAGE
562   variables:
563     FEDORA_VERSION: '31'
564   needs: ['fedora:31@container-prep']
565
566
567 ubuntu:19.10@autotools-build:
568   extends: .autotools-build@template
569   stage: autotools
570   image: $UBUNTU_CONTAINER_IMAGE
571   variables:
572     UBUNTU_VERSION: '19.10'
573   needs: ['ubuntu:19.10@container-prep']
574
575 ubuntu:19.10@meson-build:
576   extends: .meson-build@template
577   stage: meson
578   image: $UBUNTU_CONTAINER_IMAGE
579   variables:
580     UBUNTU_VERSION: '19.10'
581   needs: ['ubuntu:19.10@container-prep']
582
583
584 ubuntu:19.04@autotools-build:
585   extends: .autotools-build@template
586   stage: autotools
587   image: $UBUNTU_CONTAINER_IMAGE
588   variables:
589     UBUNTU_VERSION: '19.04'
590   needs: ['ubuntu:19.04@container-prep']
591
592 ubuntu:19.04@meson-build:
593   extends: .meson-build@template
594   stage: meson
595   image: $UBUNTU_CONTAINER_IMAGE
596   variables:
597     UBUNTU_VERSION: '19.04'
598   needs: ['ubuntu:19.04@container-prep']
599
600
601 debian:stable@autotools-build:
602   extends: .autotools-build@template
603   stage: autotools
604   image: $DEBIAN_CONTAINER_IMAGE
605   variables:
606     DEBIAN_VERSION: 'stable'
607   needs: ['debian:stable@container-prep']
608
609 debian:stable@meson-build:
610   extends: .meson-build@template
611   stage: meson
612   image: $DEBIAN_CONTAINER_IMAGE
613   variables:
614     DEBIAN_VERSION: 'stable'
615   needs: ['debian:stable@container-prep']
616
617
618 debian:sid@autotools-build:
619   extends: .autotools-build@template
620   stage: autotools
621   image: $DEBIAN_CONTAINER_IMAGE
622   variables:
623     DEBIAN_VERSION: 'sid'
624   needs: ['debian:sid@container-prep']
625
626 debian:sid@meson-build:
627   extends: .meson-build@template
628   stage: meson
629   image: $DEBIAN_CONTAINER_IMAGE
630   variables:
631     DEBIAN_VERSION: 'sid'
632   needs: ['debian:sid@container-prep']
633
634
635 centos:7@autotools-build:
636   extends: .autotools-build@template
637   stage: autotools
638   image: $CENTOS_CONTAINER_IMAGE
639   variables:
640     CENTOS_VERSION: '7'
641     MAKE_ARGS: ''  # disable distcheck, requires doxygen
642   needs: ['centos:7@container-prep']
643
644
645
646 centos:8@autotools-build:
647   extends: .autotools-build@template
648   stage: autotools
649   image: $CENTOS_CONTAINER_IMAGE
650   variables:
651     CENTOS_VERSION: '8'
652     MAKE_ARGS: ''  # disable distcheck, requires doxygen
653   needs: ['centos:8@container-prep']
654
655
656
657 arch:rolling@autotools-build:
658   extends: .autotools-build@template
659   stage: autotools
660   image: $ARCH_CONTAINER_IMAGE
661   variables:
662     ARCH_VERSION: 'rolling'
663   needs: ['arch:rolling@container-prep']
664
665 arch:rolling@meson-build:
666   extends: .meson-build@template
667   stage: meson
668   image: $ARCH_CONTAINER_IMAGE
669   variables:
670     ARCH_VERSION: 'rolling'
671   needs: ['arch:rolling@container-prep']
672
673
674 alpine:latest@autotools-build:
675   extends: .autotools-build@template
676   stage: autotools
677   image: $ALPINE_CONTAINER_IMAGE
678   variables:
679     ALPINE_VERSION: 'latest'
680   needs: ['alpine:latest@container-prep']
681
682 alpine:latest@meson-build:
683   extends: .meson-build@template
684   stage: meson
685   image: $ALPINE_CONTAINER_IMAGE
686   variables:
687     ALPINE_VERSION: 'latest'
688   needs: ['alpine:latest@container-prep']
689
690
691 # Build argument tests
692 #
693 # We only run the build option combinations on one image
694 # because they're supposed to fail equally on all
695 .fedora-custom-build@autotools-template:
696   extends: .autotools-build@template
697   stage: build
698   image: $FEDORA_CONTAINER_IMAGE
699   variables:
700     FEDORA_VERSION: 31
701   needs: ['fedora:31@container-prep']
702
703 no-valgrind:autotools:
704   extends: .fedora-custom-build@autotools-template
705   before_script:
706     - dnf remove -y valgrind
707
708 no-check:autotools:
709   extends: .fedora-custom-build@autotools-template
710   before_script:
711     - dnf remove -y check check-devel
712
713 no-doxygen:autotools:
714   extends: .fedora-custom-build@autotools-template
715   before_script:
716     - dnf remove -y doxygen
717   variables:
718     MAKE_ARGS: ''  # disable distcheck, requires doxygen
719
720 # doxygen is required for distcheck
721 no-doxygen-check-valgrind:autotools:
722   extends: .fedora-custom-build@autotools-template
723   before_script:
724     - dnf remove -y doxygen valgrind check check-devel
725   variables:
726     MAKE_ARGS: ''  # disable distcheck, requires doxygen
727
728 no-nm:autotools:
729   extends: .fedora-custom-build@autotools-template
730   before_script:
731     - mv /usr/bin/nm /usr/bin/nm.moved
732
733 enable-gcov:autotools:
734   extends: .fedora-custom-build@autotools-template
735   variables:
736     CONFIGURE_FLAGS: "--enable-gcov"
737
738 .fedora-custom-build@meson-template:
739   extends: .meson-build@template
740   stage: build
741   image: $FEDORA_CONTAINER_IMAGE
742   variables:
743     FEDORA_VERSION: 31
744   needs: ['fedora:31@container-prep']
745
746 no-valgrind:meson:
747   extends: .fedora-custom-build@meson-template
748   before_script:
749     - dnf remove -y valgrind
750
751 no-check:meson:
752   extends: .fedora-custom-build@meson-template
753   before_script:
754     - dnf remove -y check check-devel
755   variables:
756     MESON_ARGS: -Dtests=disabled
757
758 # doxygen is required for dist
759 no-doxygen:meson:
760   extends: .fedora-custom-build@meson-template
761   before_script:
762     - dnf remove -y doxygen
763   variables:
764     MESON_ARGS: -Ddocumentation=disabled
765     NINJA_ARGS: ''
766
767 # doxygen is required for dist
768 no-doxygen-check-valgrind:meson:
769   extends: .fedora-custom-build@meson-template
770   before_script:
771     - dnf remove -y doxygen valgrind check check-devel
772   variables:
773     MESON_ARGS: -Dtests=disabled -Ddocumentation=disabled
774     NINJA_ARGS: ''
775
776 enable-gcov:meson:
777   extends: .fedora-custom-build@meson-template
778   variables:
779     MESON_ARGS: '-Dcoverity=true'
780
781 scan-build:meson:
782   extends: .fedora-custom-build@meson-template
783   variables:
784     NINJA_ARGS: 'scan-build'
785
786 soname:
787   stage: build
788   image: $FEDORA_CONTAINER_IMAGE
789   script:
790   - ./autogen.sh --prefix=$PWD/prefix-autotools/
791   - make install
792   - ls -l $PWD/prefix-autotools/lib/libevdev.so.2.3.0
793   - meson "$MESON_BUILDDIR" --prefix=$PWD/prefix-meson/
794   - ninja -C "$MESON_BUILDDIR" install
795   - ls -l $PWD/prefix-meson/lib64/libevdev.so.2.3.0
796   variables:
797     FEDORA_VERSION: 31
798   needs: ['fedora:31@container-prep']
799
800 #################################################################
801 #                                                               #
802 #                          VM stage                             #
803 #                                                               #
804 #################################################################
805
806 .check_tainted: &check_tainted |
807   # make sure the kernel is not tainted
808   if [[ "$(ssh localhost -p 5555 cat /proc/sys/kernel/tainted)" -gt 0 ]];
809   then
810     echo tainted kernel ;
811     exit 1 ;
812   fi
813
814 .qemu@fedora:31:
815   stage: VM
816   image: $QEMU_CONTAINER_IMAGE
817   tags:
818     - kvm
819   variables:
820     FEDORA_VERSION: 31
821     MESON_BUILDDIR: build_dir
822   script:
823     # start our vm, no args required
824     - /app/start_vm.sh
825
826     - *check_tainted
827
828     - "scp -P 5555 -r $PWD localhost:"
829     - echo "CI_JOB_ID=\"$CI_JOB_ID\"" > sshenv
830     - echo "CI_JOB_NAME=\"$CI_JOB_NAME\"" >> sshenv
831     - echo "MESON_BUILDDIR=\"$MESON_BUILDDIR\"" >> sshenv
832     - echo "MESON_TEST_ARGS=\"$MESON_TEST_ARGS\"" >> sshenv
833     - echo "NINJA_ARGS=\"$NINJA_ARGS\"" >> sshenv
834     - "scp -P 5555 sshenv localhost:~/$CI_PROJECT_NAME/.meson_environment"
835     - ssh localhost -p 5555 "cd $CI_PROJECT_NAME ; .gitlab-ci/meson-build.sh" && touch .success || true
836     # no matter the results of the tests, we want to fetch the logs
837     - scp -P 5555 -r localhost:$CI_PROJECT_NAME/"$MESON_BUILDDIR" .
838
839     - *check_tainted
840
841     - ssh localhost -p 5555 halt || true
842     - sleep 2
843     - pkill qemu || true
844
845     - if [[ ! -e .success ]] ;
846       then
847         exit 1 ;
848       fi
849   artifacts:
850     name: "qemu-meson-logs-$CI_JOB_NAME"
851     when: always
852     expire_in: 1 week
853     paths:
854       - $MESON_BUILDDIR/meson-logs
855       - console.out
856     reports:
857       junit: $MESON_BUILDDIR/junit-*.xml
858
859   allow_failure: true
860   retry:
861     max: 2
862     when: script_failure
863   needs: ['fedora:31@qemu-prep']
864
865 qemu:meson:
866   extends: .qemu@fedora:31
867
868 qemu:meson:valgrind:
869   extends: .qemu@fedora:31
870   variables:
871     MESON_TEST_ARGS: '--setup=valgrind'
872
873 meson-from-tarball:
874   stage: tarballs
875   image: $FEDORA_CONTAINER_IMAGE
876   script:
877     - export INSTALLDIR="$PWD/_inst"
878     - mkdir _build
879     - pushd _build > /dev/null
880     - ../autogen.sh --disable-silent-rules $CONFIGURE_FLAGS
881     - make
882     - make distcheck
883     - popd > /dev/null
884     - mkdir -p _tarball_dir
885     - tar xf _build/libevdev-*.tar.xz -C _tarball_dir
886     - pushd _tarball_dir/libevdev-*/ > /dev/null
887     - meson "$MESON_BUILDDIR" --prefix="$INSTALLDIR"
888     - ninja -C "$MESON_BUILDDIR" test
889     - ninja -C "$MESON_BUILDDIR" install
890     - popd > /dev/null
891     - ls -lR $INSTALLDIR
892   variables:
893     FEDORA_VERSION: 31
894   needs: ['fedora:31@container-prep']
895
896 autotools-from-tarball:
897   stage: tarballs
898   image: $FEDORA_CONTAINER_IMAGE
899   script:
900     - export INSTALLDIR="$PWD/_inst"
901     - meson "$MESON_BUILDDIR"
902     - ninja -C "$MESON_BUILDDIR" dist
903     - mkdir -p _tarball_dir
904     - tar xf "$MESON_BUILDDIR"/meson-dist/libevdev-*.xz -C _tarball_dir
905     - pushd _tarball_dir/libevdev-*/ > /dev/null
906     - mkdir _build
907     - pushd _build > /dev/null
908     - ../autogen.sh --disable-silent-rules --prefix="$INSTALLDIR" $CONFIGURE_FLAGS
909     - make
910     - make install
911     - make distcheck
912     - popd > /dev/null
913     - popd > /dev/null
914     - ls -lR $INSTALLDIR
915   variables:
916     FEDORA_VERSION: 31
917   needs: ['fedora:31@container-prep']