gitlab CI: rename the default_build to autotools_build
[platform/upstream/libevdev.git] / .gitlab-ci.yml
1 # vim: set expandtab shiftwidth=2 tabstop=8 textwidth=0:
2
3 .templates_sha: &template_sha 01f2a6a8ab5cd31000c1c14a1acfff68ea98b59e # see https://docs.gitlab.com/ee/ci/yaml/#includefile
4
5 include:
6   # Alpine container builder template
7   - project: 'wayland/ci-templates'
8     file: '/templates/alpine.yml'
9   # Arch container builder template
10   - project: 'wayland/ci-templates'
11     ref: *template_sha
12     file: '/templates/arch.yml'
13   # Fedora container builder template
14   - project: 'wayland/ci-templates'
15     ref: *template_sha
16     file: '/templates/fedora.yml'
17   # Ubuntu container builder template
18   - project: 'wayland/ci-templates'
19     ref: *template_sha
20     file: '/templates/ubuntu.yml'
21   # Debian container builder template
22   - project: 'wayland/ci-templates'
23     ref: *template_sha
24     file: '/templates/debian.yml'
25   # CentOS container builder template
26   - project: 'wayland/ci-templates'
27     ref: *template_sha
28     file: '/templates/centos.yml'
29
30 stages:
31   - prep             # rebuild the container images if there is a change
32   - build            # for actually building and testing things in a container
33   - VM               # for running the test suite in a VM
34   - distro           # distribs test
35   - deploy           # trigger wayland's website generation
36   - container_clean  # clean up unused container images
37
38 variables:
39   ###############################################################################
40   # This is the list of packages required to build libevdev with the default    #
41   # configuration.                                                              #
42   #                                                                             #
43   # Run dnf install/apt-get install/.. with the list of packages for your       #
44   # distribution                                                                #
45   ###############################################################################
46   FEDORA_RPMS: 'git gcc gcc-c++ automake autoconf libtool make pkgconfig  python3 check-devel valgrind binutils doxygen xz'
47   CENTOS_RPMS: 'git gcc gcc-c++ automake autoconf libtool make pkgconfig  python3 check-devel valgrind binutils xz'
48   UBUNTU_DEBS: 'git gcc g++     automake autoconf libtool make pkg-config python3 check       valgrind binutils doxygen xz-utils'
49   DEBIAN_DEBS: $UBUNTU_DEBS
50   ARCH_PKGS:   'git gcc         automake autoconf libtool make pkgconfig  python3 check       valgrind binutils doxygen'
51   ALPINE_PKGS: 'git gcc g++     automake autoconf libtool make pkgconfig  python3 check-dev   valgrind binutils doxygen xz linux-headers'
52   ############################ end of package lists #############################
53   # these tags should be updated each time the list of packages is updated
54   # changing these will force rebuilding the associated image
55   # Note: these tags have no meaning and are not tied to a particular
56   # libevdev version
57   FEDORA_TAG: '2020-02-03.0'
58   CENTOS_TAG: '2020-02-03.0'
59   DEBIAN_TAG: '2020-02-03.0'
60   UBUNTU_TAG: '2020-02-03.0'
61   ARCH_TAG: '2020-02-03.0'
62   ALPINE_TAG: '2020-02-03.0'
63
64   UPSTREAM_REPO: libevdev/libevdev
65   BUILDAH_IMAGE: $CI_REGISTRY/wayland/ci-templates/buildah:latest
66   FEDORA_CONTAINER_IMAGE: $CI_REGISTRY_IMAGE/fedora/$FEDORA_VERSION:$FEDORA_TAG
67   CENTOS_CONTAINER_IMAGE: $CI_REGISTRY_IMAGE/centos/$CENTOS_VERSION:$CENTOS_TAG
68   UBUNTU_CONTAINER_IMAGE: $CI_REGISTRY_IMAGE/ubuntu/$UBUNTU_VERSION:$UBUNTU_TAG
69   DEBIAN_CONTAINER_IMAGE: $CI_REGISTRY_IMAGE/debian/$DEBIAN_VERSION:$DEBIAN_TAG
70   ARCH_CONTAINER_IMAGE: $CI_REGISTRY_IMAGE/archlinux/rolling:$ARCH_TAG
71   ALPINE_CONTAINER_IMAGE: $CI_REGISTRY_IMAGE/alpine/latest:$ALPINE_TAG
72
73   LIBEVDEV_SKIP_ROOT_TESTS: 1
74   GIT_DEPTH: 1
75
76 .default_artifacts:
77   artifacts:
78     paths:
79       - _build/test/test-suite.log
80     expire_in: 1 week
81     when: on_failure
82     reports:
83       junit: junit-*.xml
84
85 .autotools_build:
86   extends:
87     - .default_artifacts
88   script:
89     - mkdir _build
90     - pushd _build > /dev/null
91     - ../autogen.sh --disable-silent-rules $CONFIGURE_FLAGS
92     - make
93     - make check
94     - if ! [[ -z "$MAKE_ARGS" ]]; then make $MAKE_ARGS; fi
95     - popd > /dev/null
96
97 #################################################################
98 #                                                               #
99 #                          prep stage                           #
100 #                                                               #
101 #################################################################
102
103 check-commit:
104   image: golang:alpine
105   stage: prep
106   before_script:
107     - apk add python3 git
108   script:
109     - pip3 install GitPython
110     - pip3 install pytest
111     - |
112       pytest --junitxml=results.xml \
113              --tb=line \
114              --assert=plain \
115              ./.gitlab-ci/check-commit.py
116   except:
117     - master@libevdev/libevdev
118   variables:
119     GIT_DEPTH: 100
120   artifacts:
121     reports:
122       junit: results.xml
123
124 .pull_upstream_or_rebuild:
125   before_script:
126     # log in to the registry
127     - podman login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
128
129     # get the full container image name (DISTRIB_VERSION still has indirections)
130     - IMAGE=$(eval echo "$DISTRIB_FLAVOR/$DISTRIB_VERSION:$TAG")
131
132     - |
133       # force rebuild if schedule, reuse otherwise
134       if [[ $CI_PIPELINE_SOURCE != "schedule" ]] ;
135       then
136         # pull the latest upstream image if it exists
137         skopeo copy docker://$CI_REGISTRY/$UPSTREAM_REPO/$IMAGE \
138                     docker://$CI_REGISTRY_IMAGE/$IMAGE && exit 0 || true ;
139
140         # check if our image is already in the current registry
141         skopeo inspect docker://$CI_REGISTRY_IMAGE/$IMAGE > /dev/null && exit 0 || true ;
142       fi
143
144 fedora:30@container-prep:
145   extends:
146     - .fedora@container-build
147     - .pull_upstream_or_rebuild
148   stage: prep
149   variables:
150     GIT_STRATEGY: none
151     FEDORA_VERSION: 30
152     DISTRIB_FLAVOR: fedora
153     DISTRIB_VERSION: $FEDORA_VERSION
154     TAG: $FEDORA_TAG
155
156 fedora:31@container-prep:
157   extends:
158     - .fedora@container-build
159     - .pull_upstream_or_rebuild
160   stage: prep
161   variables:
162     GIT_STRATEGY: none
163     FEDORA_VERSION: 31
164     DISTRIB_FLAVOR: fedora
165     DISTRIB_VERSION: $FEDORA_VERSION
166     TAG: $FEDORA_TAG
167
168 ubuntu:19.10@container-prep:
169   extends:
170     - .ubuntu@container-build
171     - .pull_upstream_or_rebuild
172   stage: prep
173   variables:
174     GIT_STRATEGY: none
175     UBUNTU_VERSION: "19.10"
176     DISTRIB_FLAVOR: ubuntu
177     DISTRIB_VERSION: $UBUNTU_VERSION
178     TAG: $UBUNTU_TAG
179
180 ubuntu:19.04@container-prep:
181   extends:
182     - .ubuntu@container-build
183     - .pull_upstream_or_rebuild
184   stage: prep
185   variables:
186     GIT_STRATEGY: none
187     UBUNTU_VERSION: "19.04"
188     DISTRIB_FLAVOR: ubuntu
189     DISTRIB_VERSION: $UBUNTU_VERSION
190     TAG: $UBUNTU_TAG
191
192 debian:stable@container-prep:
193   extends:
194     - .debian@container-build
195     - .pull_upstream_or_rebuild
196   stage: prep
197   variables:
198     GIT_STRATEGY: none
199     DEBIAN_VERSION: stable
200     DISTRIB_FLAVOR: debian
201     DISTRIB_VERSION: $DEBIAN_VERSION
202     TAG: $DEBIAN_TAG
203
204 debian:sid@container-prep:
205   extends:
206     - .debian@container-build
207     - .pull_upstream_or_rebuild
208   stage: prep
209   variables:
210     GIT_STRATEGY: none
211     DEBIAN_VERSION: sid
212     DISTRIB_FLAVOR: debian
213     DISTRIB_VERSION: $DEBIAN_VERSION
214     TAG: $DEBIAN_TAG
215
216 .centos@container-prep:
217   extends:
218     - .centos@container-build
219     - .pull_upstream_or_rebuild
220   stage: prep
221   variables:
222     GIT_STRATEGY: none
223     CENTOS_VERSION: 7
224     DISTRIB_FLAVOR: centos
225     DISTRIB_VERSION: $CENTOS_VERSION
226     TAG: $CENTOS_TAG
227
228 centos:7@container-prep:
229   extends: .centos@container-prep
230   variables:
231     CENTOS_VERSION: 7
232
233 centos:8@container-prep:
234   extends: .centos@container-prep
235   variables:
236     CENTOS_VERSION: 8
237
238 arch:rolling@container-prep:
239   extends:
240     - .arch@container-build
241     - .pull_upstream_or_rebuild
242   stage: prep
243   variables:
244     GIT_STRATEGY: none
245     ARCH_VERSION: rolling
246     DISTRIB_FLAVOR: archlinux
247     DISTRIB_VERSION: $ARCH_VERSION
248     TAG: $ARCH_TAG
249
250 alpine:latest@container-prep:
251   extends:
252     - .alpine@container-build
253     - .pull_upstream_or_rebuild
254   stage: prep
255   variables:
256     GIT_STRATEGY: none
257     ALPINE_VERSION: latest
258     DISTRIB_FLAVOR: alpine
259     DISTRIB_VERSION: $ALPINE_VERSION
260     TAG: $ALPINE_TAG
261
262 #################################################################
263 #                                                               #
264 #                   container clean stage                       #
265 #                 run during the clean stage                    #
266 #                                                               #
267 #################################################################
268
269 #
270 # This stage will look for the container images we currently have in
271 # the registry and will remove any that are not tagged with the provided
272 # $container_image:$tag
273 #
274 .container-clean:
275   stage: container_clean
276   image: $BUILDAH_IMAGE
277   script:
278     # get the full container image name (CURRENT_CONTAINER_IMAGE still has indirections)
279     - CONTAINER_IMAGE=$(eval echo "$CURRENT_CONTAINER_IMAGE")
280     - GITLAB=$(echo $CI_PROJECT_URL | cut -f3 -d/)
281     - REPOSITORY=$(echo $CONTAINER_IMAGE | cut -f2- -d/ | cut -f1 -d:)
282     - IMAGE_PATH=$(echo $CONTAINER_IMAGE | cut -f1 -d:)
283     - LATEST_TAG=$(echo $CONTAINER_IMAGE | cut -f2 -d:)
284
285     # log in to the registry (read only)
286     - podman login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
287
288     # get the r/w token from the settings to access the registry
289     #
290     # each developer needs to register a secret variable that contains
291     # a personal token with api access. The token
292     # - must be named PERSONAL_TOKEN_$USER (for example PERSONAL_TOKEN_bentiss)
293     # - must be registered in the CI/CD Variables section as type file
294     # - value must be a netrc file as a single-line string:
295     #   default login <user> password <token value>
296     #   e.g. "default login bentiss password 1235abcde"
297     - tokenname="PERSONAL_TOKEN_$GITLAB_USER_LOGIN"
298     - netrcfile=$(eval echo "\$$tokenname")
299     - if [[ ! -f "$netrcfile" ]]; then
300          echo "No netrc file found or token is missing, skipping job" && false;
301       fi
302
303     # request a token for the registry API
304     - REGISTRY_TOKEN=$(curl https://$GITLAB/jwt/auth --get
305                              --silent --show-error
306                              -d client_id=docker
307                              -d offline_token=true
308                              -d service=container_registry
309                              -d "scope=repository:$REPOSITORY:pull,*"
310                              --fail
311                              --netrc-file "$netrcfile"
312                              | sed -r 's/(\{"token":"|"\})//g')
313
314     # get the digest of the latest image
315     - LATEST_MANIFEST=$(skopeo inspect docker://$IMAGE_PATH:$LATEST_TAG | jq -r '.Digest')
316
317     # get the list of tags
318     - TAGS=$(skopeo inspect docker://$IMAGE_PATH:$LATEST_TAG | jq -r '.RepoTags[]')
319     # FIXME: is the above command working properly? If not, use below:
320     # - TAGS=$(curl -X GET -H "accept:application/vnd.docker.distribution.manifest.v2+json"
321     #                      -H "authorization:Bearer $REGISTRY_TOKEN"
322     #                      https://$CI_REGISTRY/v2/$REPOSITORY/tags/list | jq -r '.tags[]')
323
324     # iterate over the tags
325     - for tag in $TAGS;
326       do
327         MANIFEST=$(skopeo inspect docker://$IMAGE_PATH:$tag | jq -r '.Digest');
328         if test x"$MANIFEST" != x"$LATEST_MANIFEST";
329           then
330             echo removing $tag as $MANIFEST;
331             curl https://$CI_REGISTRY/v2/$REPOSITORY/manifests/$MANIFEST --silent
332                  -H "accept:application/vnd.docker.distribution.manifest.v2+json"
333                  -H "authorization:Bearer $REGISTRY_TOKEN"
334                  --fail --show-error -X DELETE || true
335           ;fi
336       ;done
337   dependencies: []
338   allow_failure: true
339   only:
340     - schedules
341
342 fedora:30@container-clean:
343   extends: .container-clean
344   variables:
345     GIT_STRATEGY: none
346     FEDORA_VERSION: 30
347     CURRENT_CONTAINER_IMAGE: $FEDORA_CONTAINER_IMAGE
348
349 fedora:31@container-clean:
350   extends: .container-clean
351   variables:
352     GIT_STRATEGY: none
353     FEDORA_VERSION: 31
354     CURRENT_CONTAINER_IMAGE: $FEDORA_CONTAINER_IMAGE
355
356 ubuntu:19.10@container-clean:
357   extends: .container-clean
358   variables:
359     GIT_STRATEGY: none
360     UBUNTU_VERSION: "19.10"
361     CURRENT_CONTAINER_IMAGE: $UBUNTU_CONTAINER_IMAGE
362
363 ubuntu:19.04@container-clean:
364   extends: .container-clean
365   variables:
366     GIT_STRATEGY: none
367     UBUNTU_VERSION: "19.04"
368     CURRENT_CONTAINER_IMAGE: $UBUNTU_CONTAINER_IMAGE
369
370 debian:stable@container-clean:
371   extends: .container-clean
372   variables:
373     GIT_STRATEGY: none
374     DEBIAN_VERSION: stable
375     CURRENT_CONTAINER_IMAGE: $DEBIAN_CONTAINER_IMAGE
376
377 debian:sid@container-clean:
378   extends: .container-clean
379   variables:
380     GIT_STRATEGY: none
381     DEBIAN_VERSION: sid
382     CURRENT_CONTAINER_IMAGE: $DEBIAN_CONTAINER_IMAGE
383
384 .centos@container-clean:
385   extends: .container-clean
386   variables:
387     GIT_STRATEGY: none
388     CURRENT_CONTAINER_IMAGE: $CENTOS_CONTAINER_IMAGE
389
390 centos:7@container-clean:
391   extends: .centos@container-clean
392   variables:
393     CENTOS_VERSION: 7
394
395 centos:8@container-clean:
396   extends: .centos@container-clean
397   variables:
398     CENTOS_VERSION: 8
399
400 arch:rolling@container-clean:
401   extends: .container-clean
402   variables:
403     GIT_STRATEGY: none
404     CURRENT_CONTAINER_IMAGE: $ARCH_CONTAINER_IMAGE
405
406 alpine:latest@container-clean:
407   extends: .container-clean
408   variables:
409     GIT_STRATEGY: none
410     CURRENT_CONTAINER_IMAGE: $ALPINE_CONTAINER_IMAGE
411
412 #################################################################
413 #                                                               #
414 #                       build stage                             #
415 #                                                               #
416 #################################################################
417
418 .build@template:
419   extends:
420     - .autotools_build
421   stage: build
422   dependencies: []
423   variables:
424     MAKE_ARGS: "distcheck"
425
426 .fedora-build@template:
427   stage: distro
428   extends: .build@template
429   image: $FEDORA_CONTAINER_IMAGE
430
431 fedora:31@default-build:
432   stage: distro
433   extends: .fedora-build@template
434   variables:
435     FEDORA_VERSION: 31
436   needs: ['fedora:31@container-prep']
437
438 fedora:30@default-build:
439   stage: distro
440   extends: .fedora-build@template
441   variables:
442     FEDORA_VERSION: 30
443   needs: ['fedora:30@container-prep']
444
445 .centos-build@template:
446   stage: distro
447   extends: .build@template
448   image: $CENTOS_CONTAINER_IMAGE
449
450 centos:7@default-build:
451   extends: .centos-build@template
452   variables:
453     CENTOS_VERSION: 7
454     MAKE_ARGS: ''  # disable distcheck, requires doxygen
455   needs: ['centos:7@container-prep']
456
457 centos:8@default-build:
458   extends: .centos-build@template
459   variables:
460     CENTOS_VERSION: 8
461     MAKE_ARGS: ''  # disable distcheck, requires doxygen
462   needs: ['centos:8@container-prep']
463
464 .ubuntu@template:
465   stage: distro
466   extends: .build@template
467   image: $UBUNTU_CONTAINER_IMAGE
468
469 ubuntu:19.10@default-build:
470   extends: .ubuntu@template
471   variables:
472     UBUNTU_VERSION: "19.10"
473   needs: ['ubuntu:19.10@container-prep']
474
475 ubuntu:19.04@default-build:
476   extends: .ubuntu@template
477   variables:
478     UBUNTU_VERSION: "19.04"
479   needs: ['ubuntu:19.04@container-prep']
480
481 .debian@template:
482   stage: distro
483   extends: .build@template
484   image: $DEBIAN_CONTAINER_IMAGE
485
486 debian:stable@default-build:
487   extends: .debian@template
488   variables:
489     DEBIAN_VERSION: stable
490   needs: ['debian:stable@container-prep']
491
492 debian:sid@default-build:
493   extends: .debian@template
494   variables:
495     DEBIAN_VERSION: sid
496   needs: ['debian:sid@container-prep']
497
498 .arch@template:
499   stage: distro
500   extends: .build@template
501   image: $ARCH_CONTAINER_IMAGE
502
503 arch:rolling@default-build:
504   extends: .arch@template
505   needs: ['arch:rolling@container-prep']
506
507 .alpine@template:
508   stage: distro
509   extends: .build@template
510   image: $ALPINE_CONTAINER_IMAGE
511
512 alpine:latest@default-build:
513   extends: .alpine@template
514   needs: ['alpine:latest@container-prep']
515
516 # Build argument tests
517 #
518 # We only run the build option combinations on one image
519 # because they're supposed to fail equally on all
520 .fedora-custom-build@template:
521   stage: build
522   extends: .fedora-build@template
523   variables:
524     FEDORA_VERSION: 31
525   needs: ['fedora:31@container-prep']
526
527 fedora:31@no-valgrind:
528   extends: .fedora-custom-build@template
529   before_script:
530     - dnf remove -y valgrind
531
532 fedora:31@no-check:
533   extends: .fedora-custom-build@template
534   before_script:
535     - dnf remove -y check check-devel
536
537 fedora:31@no-doxygen:
538   extends: .fedora-custom-build@template
539   before_script:
540     - dnf remove -y doxygen
541   variables:
542     MAKE_ARGS: ''  # disable distcheck, requires doxygen
543
544 # doxygen is required for distcheck
545 fedora:31@no-doxygen-check-valgrind:
546   extends: .fedora-custom-build@template
547   before_script:
548     - dnf remove -y doxygen valgrind check check-devel
549   variables:
550     MAKE_ARGS: ''  # disable distcheck, requires doxygen
551
552 fedora:31@no-nm:
553   extends: .fedora-custom-build@template
554   before_script:
555     - mv /usr/bin/nm /usr/bin/nm.moved
556
557 fedora:31@enable-gcov:
558   extends: .fedora-custom-build@template
559   variables:
560     CONFIGURE_FLAGS: "--enable-gcov"