Only use GCC pragma on GCC
[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   - container_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: &default_artifacts
77   artifacts:
78     paths:
79       - test/test-suite.log
80     expire_in: 1 week
81     when: on_failure
82
83 .default_build: &default_build
84   script:
85     - autoreconf -ivf
86     - ./configure --disable-silent-rules $CONFIGURE_FLAGS
87     - make
88     - make check
89     - if ! [[ -z "$MAKE_ARGS" ]]; then make $MAKE_ARGS; fi
90   <<: *default_artifacts
91
92 #################################################################
93 #                                                               #
94 #                    container prep stage                       #
95 #                                                               #
96 #################################################################
97
98 .pull_upstream_or_rebuild: &pull_upstream_or_rebuild
99   before_script:
100     # log in to the registry
101     - podman login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
102
103     # get the full container image name (DISTRIB_VERSION still has indirections)
104     - IMAGE=$(eval echo "$DISTRIB_FLAVOR/$DISTRIB_VERSION:$TAG")
105
106     - |
107       # force rebuild if schedule, reuse otherwise
108       if [[ $CI_PIPELINE_SOURCE != "schedule" ]] ;
109       then
110         # pull the latest upstream image if it exists
111         skopeo copy docker://$CI_REGISTRY/$UPSTREAM_REPO/$IMAGE \
112                     docker://$CI_REGISTRY_IMAGE/$IMAGE && exit 0 || true ;
113
114         # check if our image is already in the current registry
115         skopeo inspect docker://$CI_REGISTRY_IMAGE/$IMAGE > /dev/null && exit 0 || true ;
116       fi
117
118 fedora:30@container-prep:
119   extends: .fedora@container-build
120   stage: container_prep
121   variables:
122     GIT_STRATEGY: none
123     FEDORA_VERSION: 30
124     DISTRIB_FLAVOR: fedora
125     DISTRIB_VERSION: $FEDORA_VERSION
126     TAG: $FEDORA_TAG
127   <<: *pull_upstream_or_rebuild
128
129 fedora:31@container-prep:
130   extends: .fedora@container-build
131   stage: container_prep
132   variables:
133     GIT_STRATEGY: none
134     FEDORA_VERSION: 31
135     DISTRIB_FLAVOR: fedora
136     DISTRIB_VERSION: $FEDORA_VERSION
137     TAG: $FEDORA_TAG
138   <<: *pull_upstream_or_rebuild
139
140
141 ubuntu:19.10@container-prep:
142   extends: .ubuntu@container-build
143   stage: container_prep
144   variables:
145     GIT_STRATEGY: none
146     UBUNTU_VERSION: "19.10"
147     DISTRIB_FLAVOR: ubuntu
148     DISTRIB_VERSION: $UBUNTU_VERSION
149     TAG: $UBUNTU_TAG
150   <<: *pull_upstream_or_rebuild
151
152 ubuntu:19.04@container-prep:
153   extends: .ubuntu@container-build
154   stage: container_prep
155   variables:
156     GIT_STRATEGY: none
157     UBUNTU_VERSION: "19.04"
158     DISTRIB_FLAVOR: ubuntu
159     DISTRIB_VERSION: $UBUNTU_VERSION
160     TAG: $UBUNTU_TAG
161   <<: *pull_upstream_or_rebuild
162
163 debian:stable@container-prep:
164   extends: .debian@container-build
165   stage: container_prep
166   variables:
167     GIT_STRATEGY: none
168     DEBIAN_VERSION: stable
169     DISTRIB_FLAVOR: debian
170     DISTRIB_VERSION: $DEBIAN_VERSION
171     TAG: $DEBIAN_TAG
172   <<: *pull_upstream_or_rebuild
173
174 debian:sid@container-prep:
175   extends: .debian@container-build
176   stage: container_prep
177   variables:
178     GIT_STRATEGY: none
179     DEBIAN_VERSION: sid
180     DISTRIB_FLAVOR: debian
181     DISTRIB_VERSION: $DEBIAN_VERSION
182     TAG: $DEBIAN_TAG
183   <<: *pull_upstream_or_rebuild
184
185 .centos@container-prep:
186   extends: .centos@container-build
187   stage: container_prep
188   variables:
189     GIT_STRATEGY: none
190     CENTOS_VERSION: 7
191     DISTRIB_FLAVOR: centos
192     DISTRIB_VERSION: $CENTOS_VERSION
193     TAG: $CENTOS_TAG
194   <<: *pull_upstream_or_rebuild
195
196 centos:7@container-prep:
197   extends: .centos@container-prep
198   variables:
199     CENTOS_VERSION: 7
200
201 centos:8@container-prep:
202   extends: .centos@container-prep
203   variables:
204     CENTOS_VERSION: 8
205
206 arch:rolling@container-prep:
207   extends: .arch@container-build
208   stage: container_prep
209   variables:
210     GIT_STRATEGY: none
211     ARCH_VERSION: rolling
212     DISTRIB_FLAVOR: archlinux
213     DISTRIB_VERSION: $ARCH_VERSION
214     TAG: $ARCH_TAG
215   <<: *pull_upstream_or_rebuild
216
217 alpine:latest@container-prep:
218   extends: .alpine@container-build
219   stage: container_prep
220   variables:
221     GIT_STRATEGY: none
222     ALPINE_VERSION: latest
223     DISTRIB_FLAVOR: alpine
224     DISTRIB_VERSION: $ALPINE_VERSION
225     TAG: $ALPINE_TAG
226   <<: *pull_upstream_or_rebuild
227
228 #################################################################
229 #                                                               #
230 #                   container clean stage                       #
231 #                 run during the clean stage                    #
232 #                                                               #
233 #################################################################
234
235 #
236 # This stage will look for the container images we currently have in
237 # the registry and will remove any that are not tagged with the provided
238 # $container_image:$tag
239 #
240 .container-clean:
241   stage: container_clean
242   image: $BUILDAH_IMAGE
243   script:
244     # get the full container image name (CURRENT_CONTAINER_IMAGE still has indirections)
245     - CONTAINER_IMAGE=$(eval echo "$CURRENT_CONTAINER_IMAGE")
246     - GITLAB=$(echo $CI_PROJECT_URL | cut -f3 -d/)
247     - REPOSITORY=$(echo $CONTAINER_IMAGE | cut -f2- -d/ | cut -f1 -d:)
248     - IMAGE_PATH=$(echo $CONTAINER_IMAGE | cut -f1 -d:)
249     - LATEST_TAG=$(echo $CONTAINER_IMAGE | cut -f2 -d:)
250
251     # log in to the registry (read only)
252     - podman login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
253
254     # get the r/w token from the settings to access the registry
255     #
256     # each developer needs to register a secret variable that contains
257     # a personal token with api access. The token
258     # - must be named PERSONAL_TOKEN_$USER (for example PERSONAL_TOKEN_bentiss)
259     # - must be registered in the CI/CD Variables section as type file
260     # - value must be a netrc file as a single-line string:
261     #   default login <user> password <token value>
262     #   e.g. "default login bentiss password 1235abcde"
263     - tokenname="PERSONAL_TOKEN_$GITLAB_USER_LOGIN"
264     - netrcfile=$(eval echo "\$$tokenname")
265     - if [[ ! -f "$netrcfile" ]]; then
266          echo "No netrc file found or token is missing, skipping job" && false;
267       fi
268
269     # request a token for the registry API
270     - REGISTRY_TOKEN=$(curl https://$GITLAB/jwt/auth --get
271                              --silent --show-error
272                              -d client_id=docker
273                              -d offline_token=true
274                              -d service=container_registry
275                              -d "scope=repository:$REPOSITORY:pull,*"
276                              --fail
277                              --netrc-file "$netrcfile"
278                              | sed -r 's/(\{"token":"|"\})//g')
279
280     # get the digest of the latest image
281     - LATEST_MANIFEST=$(skopeo inspect docker://$IMAGE_PATH:$LATEST_TAG | jq -r '.Digest')
282
283     # get the list of tags
284     - TAGS=$(skopeo inspect docker://$IMAGE_PATH:$LATEST_TAG | jq -r '.RepoTags[]')
285     # FIXME: is the above command working properly? If not, use below:
286     # - TAGS=$(curl -X GET -H "accept:application/vnd.docker.distribution.manifest.v2+json"
287     #                      -H "authorization:Bearer $REGISTRY_TOKEN"
288     #                      https://$CI_REGISTRY/v2/$REPOSITORY/tags/list | jq -r '.tags[]')
289
290     # iterate over the tags
291     - for tag in $TAGS;
292       do
293         MANIFEST=$(skopeo inspect docker://$IMAGE_PATH:$tag | jq -r '.Digest');
294         if test x"$MANIFEST" != x"$LATEST_MANIFEST";
295           then
296             echo removing $tag as $MANIFEST;
297             curl https://$CI_REGISTRY/v2/$REPOSITORY/manifests/$MANIFEST --silent
298                  -H "accept:application/vnd.docker.distribution.manifest.v2+json"
299                  -H "authorization:Bearer $REGISTRY_TOKEN"
300                  --fail --show-error -X DELETE || true
301           ;fi
302       ;done
303   dependencies: []
304   allow_failure: true
305   only:
306     - schedules
307
308 fedora:30@container-clean:
309   extends: .container-clean
310   variables:
311     GIT_STRATEGY: none
312     FEDORA_VERSION: 30
313     CURRENT_CONTAINER_IMAGE: $FEDORA_CONTAINER_IMAGE
314
315 fedora:31@container-clean:
316   extends: .container-clean
317   variables:
318     GIT_STRATEGY: none
319     FEDORA_VERSION: 31
320     CURRENT_CONTAINER_IMAGE: $FEDORA_CONTAINER_IMAGE
321
322 ubuntu:19.10@container-clean:
323   extends: .container-clean
324   variables:
325     GIT_STRATEGY: none
326     UBUNTU_VERSION: "19.10"
327     CURRENT_CONTAINER_IMAGE: $UBUNTU_CONTAINER_IMAGE
328
329 ubuntu:19.04@container-clean:
330   extends: .container-clean
331   variables:
332     GIT_STRATEGY: none
333     UBUNTU_VERSION: "19.04"
334     CURRENT_CONTAINER_IMAGE: $UBUNTU_CONTAINER_IMAGE
335
336 debian:stable@container-clean:
337   extends: .container-clean
338   variables:
339     GIT_STRATEGY: none
340     DEBIAN_VERSION: stable
341     CURRENT_CONTAINER_IMAGE: $DEBIAN_CONTAINER_IMAGE
342
343 debian:sid@container-clean:
344   extends: .container-clean
345   variables:
346     GIT_STRATEGY: none
347     DEBIAN_VERSION: sid
348     CURRENT_CONTAINER_IMAGE: $DEBIAN_CONTAINER_IMAGE
349
350 .centos@container-clean:
351   extends: .container-clean
352   variables:
353     GIT_STRATEGY: none
354     CURRENT_CONTAINER_IMAGE: $CENTOS_CONTAINER_IMAGE
355
356 centos:7@container-clean:
357   extends: .centos@container-clean
358   variables:
359     CENTOS_VERSION: 7
360
361 centos:8@container-clean:
362   extends: .centos@container-clean
363   variables:
364     CENTOS_VERSION: 8
365
366 arch:rolling@container-clean:
367   extends: .container-clean
368   variables:
369     GIT_STRATEGY: none
370     CURRENT_CONTAINER_IMAGE: $ARCH_CONTAINER_IMAGE
371
372 alpine:latest@container-clean:
373   extends: .container-clean
374   variables:
375     GIT_STRATEGY: none
376     CURRENT_CONTAINER_IMAGE: $ALPINE_CONTAINER_IMAGE
377
378 #################################################################
379 #                                                               #
380 #                       build stage                             #
381 #                                                               #
382 #################################################################
383
384 .build@template:
385   stage: build
386   <<: *default_artifacts
387   <<: *default_build
388   dependencies: []
389   variables:
390     MAKE_ARGS: "distcheck"
391
392 .fedora-build@template:
393   stage: distro
394   extends: .build@template
395   image: $FEDORA_CONTAINER_IMAGE
396
397 fedora:31@default-build:
398   stage: distro
399   extends: .fedora-build@template
400   variables:
401     FEDORA_VERSION: 31
402   needs: ['fedora:31@container-prep']
403
404 fedora:30@default-build:
405   stage: distro
406   extends: .fedora-build@template
407   variables:
408     FEDORA_VERSION: 30
409   needs: ['fedora:30@container-prep']
410
411 .centos-build@template:
412   stage: distro
413   extends: .build@template
414   image: $CENTOS_CONTAINER_IMAGE
415
416 centos:7@default-build:
417   extends: .centos-build@template
418   variables:
419     CENTOS_VERSION: 7
420     MAKE_ARGS: ''  # disable distcheck, requires doxygen
421   needs: ['centos:7@container-prep']
422
423 centos:8@default-build:
424   extends: .centos-build@template
425   variables:
426     CENTOS_VERSION: 8
427     MAKE_ARGS: ''  # disable distcheck, requires doxygen
428   needs: ['centos:8@container-prep']
429
430 .ubuntu@template:
431   stage: distro
432   extends: .build@template
433   image: $UBUNTU_CONTAINER_IMAGE
434
435 ubuntu:19.10@default-build:
436   extends: .ubuntu@template
437   variables:
438     UBUNTU_VERSION: "19.10"
439   needs: ['ubuntu:19.10@container-prep']
440
441 ubuntu:19.04@default-build:
442   extends: .ubuntu@template
443   variables:
444     UBUNTU_VERSION: "19.04"
445   needs: ['ubuntu:19.04@container-prep']
446
447 .debian@template:
448   stage: distro
449   extends: .build@template
450   image: $DEBIAN_CONTAINER_IMAGE
451
452 debian:stable@default-build:
453   extends: .debian@template
454   variables:
455     DEBIAN_VERSION: stable
456   needs: ['debian:stable@container-prep']
457
458 debian:sid@default-build:
459   extends: .debian@template
460   variables:
461     DEBIAN_VERSION: sid
462   needs: ['debian:sid@container-prep']
463
464 .arch@template:
465   stage: distro
466   extends: .build@template
467   image: $ARCH_CONTAINER_IMAGE
468
469 arch:rolling@default-build:
470   extends: .arch@template
471   needs: ['arch:rolling@container-prep']
472
473 .alpine@template:
474   stage: distro
475   extends: .build@template
476   image: $ALPINE_CONTAINER_IMAGE
477
478 alpine:latest@default-build:
479   extends: .alpine@template
480   needs: ['alpine:latest@container-prep']
481
482 # Build argument tests
483 #
484 # We only run the build option combinations on one image
485 # because they're supposed to fail equally on all
486 .fedora-custom-build@template:
487   stage: build
488   extends: .fedora-build@template
489   variables:
490     FEDORA_VERSION: 31
491   needs: ['fedora:31@container-prep']
492
493 fedora:31@no-valgrind:
494   extends: .fedora-custom-build@template
495   before_script:
496     - dnf remove -y valgrind
497
498 fedora:31@no-check:
499   extends: .fedora-custom-build@template
500   before_script:
501     - dnf remove -y check check-devel
502
503 fedora:31@no-doxygen:
504   extends: .fedora-custom-build@template
505   before_script:
506     - dnf remove -y doxygen
507   <<: *default_build
508   variables:
509     MAKE_ARGS: ''  # disable distcheck, requires doxygen
510
511 # doxygen is required for distcheck
512 fedora:31@no-doxygen-check-valgrind:
513   extends: .fedora-custom-build@template
514   before_script:
515     - dnf remove -y doxygen valgrind check check-devel
516   <<: *default_build
517   variables:
518     MAKE_ARGS: ''  # disable distcheck, requires doxygen
519
520 fedora:31@no-nm:
521   extends: .fedora-custom-build@template
522   before_script:
523     - mv /usr/bin/nm /usr/bin/nm.moved
524
525 fedora:31@enable-gcov:
526   extends: .fedora-custom-build@template
527   <<: *default_artifacts
528   variables:
529     CONFIGURE_FLAGS: "--enable-gcov"