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