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