1 # vim: set expandtab shiftwidth=2 tabstop=8 textwidth=0:
3 # This is a bit complicated for two reasons:
4 # - we really want to run dnf/apt/... only once, updating on the test runner for
5 # each job takes forever. So we create a container image for each distribution
6 # tested, then run the tests on this container image.
8 # Creating a container image is time-consuming, so we only do so for pushes to
9 # libinput directly (not merge requests) and if the current image is 'old'.
11 # - GitLab only allows one script: set per job but we have a bunch of commands
12 # we need to re-run for each build (meson && ninja && etc). YAML cannot merge
13 # arrays templates so we're screwed.
15 # So instead we use a default_build template and override everything with
16 # variables. The only two variables that matter:
17 # MESON_ARGS=-Denable-something=true
18 # NINJA_ARGS=dist ... to run 'ninja -C builddir dist'
19 # Note that you cannot use scripts: in any target if you expect default_build
23 # All jobs must follow the naming scheme of
24 # <distribution>:<version>@activity:
25 # e.g. fedora:29@build-default
28 # Arch container builder template
29 - project: 'wayland/ci-templates'
30 ref: c73dae8b84697ef18e2dbbf4fed7386d9652b0cd # see https://docs.gitlab.com/ee/ci/yaml/#includefile
31 file: '/templates/arch.yml'
32 # Fedora container builder template
33 - project: 'wayland/ci-templates'
34 ref: c73dae8b84697ef18e2dbbf4fed7386d9652b0cd # see https://docs.gitlab.com/ee/ci/yaml/#includefile
35 file: '/templates/fedora.yml'
36 # Ubuntu container builder template
37 - project: 'wayland/ci-templates'
38 ref: c73dae8b84697ef18e2dbbf4fed7386d9652b0cd # see https://docs.gitlab.com/ee/ci/yaml/#includefile
39 file: '/templates/ubuntu.yml'
42 - container_prep # rebuild the container images if there is a change
43 - build # for actually building things
44 - deploy # trigger wayland's website generation
45 - container_clean # clean up unused container images
48 ###############################################################################
49 # This is the list of packages required to build libinput with the default #
52 # Run dnf install/apt-get install/.. with the list of packages for your #
55 # See the documentation here: #
56 # https://wayland.freedesktop.org/libinput/doc/latest/building_libinput.html #
57 ###############################################################################
58 FEDORA_RPMS: 'git gcc gcc-c++ pkgconf-pkg-config meson check-devel libudev-devel libevdev-devel doxygen graphviz python3-sphinx python3-recommonmark libwacom-devel cairo-devel gtk3-devel glib2-devel mtdev-devel'
59 UBUNTU_CUSTOM_DEBS: 'git gcc g++ pkg-config meson check libudev-dev libevdev-dev doxygen graphviz python3-sphinx python3-recommonmark python3-sphinx-rtd-theme libwacom-dev libcairo2-dev libgtk-3-dev libglib2.0-dev libmtdev-dev'
60 ARCH_PKGS: 'git gcc pkgconfig meson check libsystemd libevdev doxygen graphviz python-sphinx python-recommonmark libwacom gtk3 mtdev diffutils'
61 FREEBSD_BUILD_PKGS: 'meson'
62 FREEBSD_PKGS: 'libepoll-shim libudev-devd libevdev libwacom gtk3 libmtdev '
63 ############################ end of package lists #############################
65 # these tags should be updated each time the list of packages is updated
66 # changing these will force rebuilding the associated image
67 # Note: these tags have no meaning and are not tied to a particular
69 FEDORA_TAG: '2019-03-15.0'
70 UBUNTU_TAG: '2019-03-15.0'
71 ARCH_TAG: '2019-03-15.0'
72 FREEBSD_TAG: '2019-03-15.0'
74 UBUNTU_EXEC: "bash .gitlab-ci/ubuntu_install.sh $UBUNTU_CUSTOM_DEBS"
76 UPSTREAM_REPO: libinput/libinput
77 BUILDAH_IMAGE: $CI_REGISTRY/wayland/ci-templates/buildah:latest
78 FEDORA_CONTAINER_IMAGE: $CI_REGISTRY_IMAGE/fedora/$FEDORA_VERSION:$FEDORA_TAG
79 UBUNTU_CONTAINER_IMAGE: $CI_REGISTRY_IMAGE/ubuntu/$UBUNTU_VERSION:$UBUNTU_TAG
80 ARCH_CONTAINER_IMAGE: $CI_REGISTRY_IMAGE/archlinux/rolling:$ARCH_TAG
81 FREEBSD_CONTAINER_IMAGE: $CI_REGISTRY_IMAGE/freebsd/11.2:$FREEBSD_TAG
83 MESON_BUILDDIR: "build dir"
87 # Until we have a VM with full access, we cannot run the test suite runner
88 SKIP_LIBINPUT_TEST_SUITE_RUNNER: 1
89 # udev isn't available/working properly in the containers
93 .default_artifacts: &default_artifacts
95 name: "meson-logs-$CI_JOB_NAME"
99 - $MESON_BUILDDIR/meson-logs
101 # The default build instructions
102 .default_build: &default_build
104 - rm -rf "$MESON_BUILDDIR"
105 - meson "$MESON_BUILDDIR" $MESON_ARGS
106 - meson configure "$MESON_BUILDDIR"
107 - ninja -C "$MESON_BUILDDIR" $NINJA_ARGS
109 #################################################################
111 # container prep stage #
113 #################################################################
116 # This stage will recreate the container images only if the image
117 # is too old or if it is missing some dependencies.
120 .check_if_older_than_a_week: &check_if_older_than_a_week
122 # log in to the registry
123 - podman login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
125 # get the full container image name (DISTRIB_VERSION still has indirections)
126 - IMAGE=$(eval echo "$DISTRIB_FLAVOR/$DISTRIB_VERSION:$TAG")
128 # check if our image is already in the current registry and get its date
129 - LOCAL_IMG_DATE=$(skopeo inspect docker://$CI_REGISTRY_IMAGE/$IMAGE | jq -r '.Created' | cut -dT -f1 ||
132 # get the date of the upstream image
133 - UPSTREAM_IMG_DATE=$(skopeo inspect docker://$CI_REGISTRY/$UPSTREAM_REPO/$IMAGE | jq -r '.Created' | cut -dT -f1 ||
136 - TODAY_SECS=$(date -u +%s)
137 - LOCAL_IMG_SECS=$(date -u --date="$LOCAL_IMG_DATE" +%s)
138 - UPSTREAM_IMG_SECS=$(date -u --date="$UPSTREAM_IMG_DATE" +%s)
139 - echo "today $TODAY_SECS, local image $LOCAL_IMG_SECS, upstream image $UPSTREAM_IMG_SECS"
140 - echo "image ages $(($TODAY_SECS - $LOCAL_IMG_SECS))s and $(($TODAY_SECS - $UPSTREAM_IMG_SECS))s"
142 # if the upstream image is more recent, use it
143 - if [[ $UPSTREAM_IMG_SECS -gt $LOCAL_IMG_SECS ]] ;
145 skopeo copy docker://$CI_REGISTRY/$UPSTREAM_REPO/$IMAGE
146 docker://$CI_REGISTRY_IMAGE/$IMAGE ;
147 LOCAL_IMG_SECS=UPSTREAM_IMG_SECS ;
150 # check if image is less than a week old
151 - test $(($LOCAL_IMG_SECS + 604800)) -gt $TODAY_SECS && exit 0
154 fedora:28@container-prep:
155 extends: .fedora@container-build
156 stage: container_prep
160 DISTRIB_FLAVOR: fedora
161 DISTRIB_VERSION: $FEDORA_VERSION
163 <<: *check_if_older_than_a_week
165 fedora:29@container-prep:
166 extends: .fedora@container-build
167 stage: container_prep
171 DISTRIB_FLAVOR: fedora
172 DISTRIB_VERSION: $FEDORA_VERSION
174 <<: *check_if_older_than_a_week
177 ubuntu:18.10@container-prep:
178 extends: .ubuntu@container-build
179 stage: container_prep
182 UBUNTU_VERSION: "18.10"
183 DISTRIB_FLAVOR: ubuntu
184 DISTRIB_VERSION: $UBUNTU_VERSION
186 <<: *check_if_older_than_a_week
188 ubuntu:18.04@container-prep:
189 extends: .ubuntu@container-build
190 stage: container_prep
193 UBUNTU_VERSION: "18.04"
194 DISTRIB_FLAVOR: ubuntu
195 DISTRIB_VERSION: $UBUNTU_VERSION
197 <<: *check_if_older_than_a_week
200 arch:rolling@container-prep:
201 extends: .arch@container-build
202 stage: container_prep
205 ARCH_VERSION: rolling
206 DISTRIB_FLAVOR: archlinux
207 DISTRIB_VERSION: $ARCH_VERSION
209 <<: *check_if_older_than_a_week
211 .freebsd@container-prep:
212 stage: container_prep
213 image: $BUILDAH_IMAGE
214 <<: *check_if_older_than_a_week
216 - buildcntr=$(buildah from --quiet myfreeweb/freebsd-cross:latest)
217 - buildah run $buildcntr apk add --no-cache $FREEBSD_BUILD_PKGS
218 - buildah run $buildcntr pkg -r /freebsd update -f
219 - buildah run $buildcntr pkg -r /freebsd install -y $FREEBSD_PKGS
220 - buildah config --workingdir /app $buildcntr
221 # tag the current container
222 - buildah commit --quiet $buildcntr $FREEBSD_CONTAINER_IMAGE
223 # clean up the working container
224 - buildah rm $buildcntr
226 # push the container image to the libinput registry
227 - podman push --quiet $FREEBSD_CONTAINER_IMAGE
228 - skopeo copy docker://$FREEBSD_CONTAINER_IMAGE docker://$CI_REGISTRY_IMAGE/freebsd/$FREEBSD_VERSION:$CI_JOB_ID
230 freebsd:11.2@container-prep:
231 extends: .freebsd@container-prep
234 FREEBSD_VERSION: "11.2"
235 DISTRIB_FLAVOR: freebsd
236 DISTRIB_VERSION: $FREEBSD_VERSION
240 #################################################################
242 # container clean stage #
243 # run during the clean stage #
245 #################################################################
248 # This stage will look for the container images we currently have in
249 # the registry and will remove any that are not tagged with the provided
250 # $container_image:$tag
253 stage: container_clean
254 image: $BUILDAH_IMAGE
256 # get the full container image name (CURRENT_CONTAINER_IMAGE still has indirections)
257 - CONTAINER_IMAGE=$(eval echo "$CURRENT_CONTAINER_IMAGE")
258 - GITLAB=$(echo $CI_PROJECT_URL | cut -f3 -d/)
259 - REPOSITORY=$(echo $CONTAINER_IMAGE | cut -f2- -d/ | cut -f1 -d:)
260 - IMAGE_PATH=$(echo $CONTAINER_IMAGE | cut -f1 -d:)
261 - LATEST_TAG=$(echo $CONTAINER_IMAGE | cut -f2 -d:)
263 # log in to the registry (read only)
264 - podman login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
266 # get the r/w token from the settings to access the registry
268 # each developer needs to register a secret variable that contains
269 # a personal token with api access in the form of:
270 # PERSONAL_TOKEN_$USER (for example PERSONAL_TOKEN_bentiss)
271 - tokenname="PERSONAL_TOKEN_$GITLAB_USER_LOGIN"
272 - token=$(eval echo "\$$tokenname")
274 # request a token for the registry API
275 - REGISTRY_TOKEN=$(curl https://$GITLAB/jwt/auth --get
276 --silent --show-error
278 -d offline_token=true
279 -d service=container_registry
280 -d "scope=repository:$REPOSITORY:pull,*"
282 --user $GITLAB_USER_LOGIN:$token
283 | sed -r 's/(\{"token":"|"\})//g')
285 # get the digest of the latest image
286 - LATEST_MANIFEST=$(skopeo inspect docker://$IMAGE_PATH:$LATEST_TAG | jq -r '.Digest')
288 # get the list of tags
289 - TAGS=$(skopeo inspect docker://$IMAGE_PATH:$LATEST_TAG | jq -r '.RepoTags[]')
290 # FIXME: is the above command working properly? If not, use below:
291 # - TAGS=$(curl -X GET -H "accept:application/vnd.docker.distribution.manifest.v2+json"
292 # -H "authorization:Bearer $REGISTRY_TOKEN"
293 # https://$CI_REGISTRY/v2/$REPOSITORY/tags/list | jq -r '.tags[]')
295 # iterate over the tags
298 MANIFEST=$(skopeo inspect docker://$IMAGE_PATH:$tag | jq -r '.Digest');
299 if test x"$MANIFEST" != x"$LATEST_MANIFEST";
301 echo removing $tag as $MANIFEST;
302 curl https://$CI_REGISTRY/v2/$REPOSITORY/manifests/$MANIFEST --silent
303 -H "accept:application/vnd.docker.distribution.manifest.v2+json"
304 -H "authorization:Bearer $REGISTRY_TOKEN"
305 --fail --show-error -X DELETE || true
311 fedora:28@container-clean:
312 extends: .container-clean
316 CURRENT_CONTAINER_IMAGE: $FEDORA_CONTAINER_IMAGE
318 fedora:29@container-clean:
319 extends: .container-clean
323 CURRENT_CONTAINER_IMAGE: $FEDORA_CONTAINER_IMAGE
325 ubuntu:18.10@container-clean:
326 extends: .container-clean
329 UBUNTU_VERSION: "18.10"
330 CURRENT_CONTAINER_IMAGE: $UBUNTU_CONTAINER_IMAGE
332 ubuntu:18.04@container-clean:
333 extends: .container-clean
336 UBUNTU_VERSION: "18.04"
337 CURRENT_CONTAINER_IMAGE: $UBUNTU_CONTAINER_IMAGE
339 arch:rolling@container-clean:
340 extends: .container-clean
343 CURRENT_CONTAINER_IMAGE: $ARCH_CONTAINER_IMAGE
345 freebsd:11.2@container-clean:
346 extends: .container-clean
349 CURRENT_CONTAINER_IMAGE: $FREEBSD_CONTAINER_IMAGE
351 #################################################################
355 #################################################################
359 <<: *default_artifacts
367 .fedora-build@template:
368 extends: .build@template
369 image: $FEDORA_CONTAINER_IMAGE
371 fedora:28@default-build:
372 extends: .fedora-build@template
376 fedora:29@default-build:
377 extends: .fedora-build@template
381 fedora:29@default-build-release:
382 extends: .fedora-build@template
385 MESON_ARGS: "-Dbuildtype=release"
388 fedora:29@scan-build:
389 extends: .fedora-build@template
392 NINJA_ARGS: scan-build
394 - dnf install -y clang-analyzer findutils
396 - test ! -d "$MESON_BUILDDIR"/meson-logs/scanbuild && exit 0
397 - test $(find "$MESON_BUILDDIR"/meson-logs/scanbuild -maxdepth 0 ! -empty -exec echo "not empty" \; | wc -l) -eq 0 && exit 0
398 - echo "Check scan-build results"
401 # Below jobs are build option combinations. We only
402 # run them on one image, they shouldn't fail on one distro
403 # when they succeed on another.
405 fedora:29@build-no-libwacom:
406 extends: .fedora-build@template
409 MESON_ARGS: "-Dlibwacom=false"
411 fedora:29@build-no-libwacom-nodeps:
412 extends: .fedora-build@template
415 MESON_ARGS: "-Dlibwacom=false"
417 - dnf remove -y libwacom libwacom-devel
419 fedora:29@build-no-docs:
420 extends: .fedora-build@template
423 MESON_ARGS: "-Ddocumentation=false"
425 fedora:29@build-no-docs-nodeps:
426 extends: .fedora-build@template
429 MESON_ARGS: "-Ddocumentation=false"
431 - dnf remove -y doxygen graphviz
433 fedora:29@build-no-debuggui:
434 extends: .fedora-build@template
437 MESON_ARGS: "-Ddebug-gui=false"
439 fedora:29@build-no-debuggui-nodeps:
440 extends: .fedora-build@template
443 MESON_ARGS: "-Ddebug-gui=false"
445 - dnf remove -y gtk3-devel
447 fedora:29@build-no-tests:
448 extends: .fedora-build@template
451 MESON_ARGS: "-Dtests=false"
453 fedora:29@build-no-tests-nodeps:
454 extends: .fedora-build@template
457 MESON_ARGS: "-Dtests=false"
459 - dnf remove -y check-devel
462 extends: .fedora-build@template
466 - dnf install -y valgrind
467 # note: we override the default_build here by providing a new script
469 - rm -rf "$MESON_BUILDDIR"
470 - meson "$MESON_BUILDDIR" $MESON_ARGS
471 - meson configure "$MESON_BUILDDIR"
472 - meson test -C "$MESON_BUILDDIR" --setup=valgrind
479 extends: .build@template
480 image: $UBUNTU_CONTAINER_IMAGE
482 ubuntu:18.10@default-build:
483 extends: .ubuntu@template
485 UBUNTU_VERSION: "18.10"
487 ubuntu:18.04@default-build:
488 extends: .ubuntu@template
490 UBUNTU_VERSION: "18.04"
496 extends: .build@template
497 image: $ARCH_CONTAINER_IMAGE
499 arch:rolling@default-build:
500 extends: .arch@template
506 extends: .build@template
507 image: $FREEBSD_CONTAINER_IMAGE
509 MESON_ARGS: '--cross-file freebsd -Ddocumentation=false -Dtests=false -Depoll-dir=/freebsd/usr/local/'
510 # Can't run FreeBSD tests on Linux machine, so NINJA_ARGS shouldn't be "test"
513 freebsd:11.2@default-build:
514 extends: .freebsd@template
521 image: $BUILDAH_IMAGE
524 - curl --request POST
525 --form "token=$WAYLAND_WEB_TOKEN"
527 https://gitlab.freedesktop.org/api/v4/projects/wayland${SLASH}wayland${DOT}freedesktop${DOT}org/trigger/pipeline
532 - $CI_PROJECT_PATH == "libinput/libinput"