# vim: set expandtab shiftwidth=2 tabstop=8 textwidth=0: # # This is a bit complicated for two reasons: # - we really want to run dnf/apt/... only once, updating on the test runner for # each job takes forever. So we create a docker image for each distribution # tested, then run the tests on this docker image. # # Creating a docker image is time-consuming, so we only do so for pushes to # libinput directly (not merge requests) and if the current image is 'old'. # # - GitLab only allows one script: set per job but we have a bunch of commands # we need to re-run for each build (meson && ninja && etc). YAML cannot merge # arrays templates so we're screwed. # # So instead we use a default_build template and override everything with # variables. The only two variables that matter: # MESON_ARGS=-Denable-something=true # NINJA_ARGS=dist ... to run 'ninja -C builddir dist' # Note that you cannot use scripts: in any target if you expect default_build # to work. # # # All jobs must follow the naming scheme of # :@activity: # e.g. fedora:29@build-default stages: - docker_check # check if the current docker images are up to date - docker_prep # rebuild the docker images if previous step failed - build # for actually building things - deploy # trigger wayland's website generation variables: ############################################################################### # This is the list of packages required to build libinput with the default # # configuration. # # # # Run dnf install/apt-get install/.. with the list of packages for your # # distribution # # # # See the documentation here: # # https://wayland.freedesktop.org/libinput/doc/latest/building_libinput.html # ############################################################################### FEDORA_RPMS: 'git gcc gcc-c++ pkgconf-pkg-config meson check-devel libudev-devel libevdev-devel doxygen graphviz python3-sphinx python3-recommonmark valgrind libwacom-devel cairo-devel gtk3-devel glib2-devel mtdev-devel' UBUNTU_DEBS: 'git gcc g++ pkg-config meson check libudev-dev libevdev-dev doxygen graphviz python3-sphinx python3-recommonmark python3-sphinx-rtd-theme valgrind libwacom-dev libcairo2-dev libgtk-3-dev libglib2.0-dev libmtdev-dev' ARCH_PKGS: 'git gcc pkgconfig meson check libsystemd libevdev doxygen graphviz python-sphinx python-recommonmark valgrind libwacom gtk3 mtdev ' FREEBSD_BUILD_PKGS: 'meson' FREEBSD_PKGS: 'libepoll-shim libudev-devd libevdev libwacom gtk3 libmtdev ' ############################ end of package lists ############################# MESON_BUILDDIR: "build dir" NINJA_ARGS: 'test' MESON_ARGS: '' FEDORA_DOCKER_IMAGE: $CI_REGISTRY/libinput/$CI_PROJECT_NAME/fedora/$FEDORA_VERSION UBUNTU_DOCKER_IMAGE: $CI_REGISTRY/libinput/$CI_PROJECT_NAME/ubuntu/$UBUNTU_VERSION ARCH_DOCKER_IMAGE: $CI_REGISTRY/libinput/$CI_PROJECT_NAME/arch/rolling FREEBSD_DOCKER_IMAGE: $CI_REGISTRY/libinput/$CI_PROJECT_NAME/freebsd/11.2 # Until we have a VM with full access, we cannot run the test suite runner SKIP_LIBINPUT_TEST_SUITE_RUNNER: 1 # When using docker-in-docker (dind), it's wise to use the overlayfs driver # for improved performance. DOCKER_DRIVER: overlay2 GIT_DEPTH: 1 .default_artifacts: &default_artifacts artifacts: name: "meson-logs-$CI_JOB_NAME" when: always expire_in: 1 week paths: - $MESON_BUILDDIR/meson-logs # The default build instructions .default_build: &default_build script: - rm -rf "$MESON_BUILDDIR" - meson "$MESON_BUILDDIR" $MESON_ARGS - meson configure "$MESON_BUILDDIR" - ninja -C "$MESON_BUILDDIR" $NINJA_ARGS # special rule to not expose the docker creation runners to other users # than those who have set up the CI to push on the registry. # Users who have write access to libinput/libinput will have write # access to the registry, so the libinput/libinput is a catch-all for # our core developers. # # we can add as many users as we want by adding a new line like: # - $GITLAB_USER_LOGIN == "someone" .restrict_docker_creation: &restrict_docker_creation only: variables: # Note: this is a set of logical OR, not AND - $CI_PROJECT_PATH == "libinput/libinput" ################################################################# # # # docker check stage # # # ################################################################# # we need a minimalist image capable of skopeo, curl, jq, date and # test. Instead of using a full fedora and install the dependencies, # we can build an alpine container through buildah with the following # script: # ----- # #!/bin/bash # # # build container # # buildcntr1=$(buildah from golang:alpine) # buildmnt1=$(buildah mount $buildcntr1) # # buildah run $buildcntr1 apk add --update \ # --no-cache \ # --repository http://dl-3.alpinelinux.org/alpine/edge/testing/ \ # --allow-untrusted \ # git make gcc musl-dev glib-dev ostree-dev \ # gpgme-dev linux-headers btrfs-progs-dev \ # libselinux-dev lvm2-dev # buildah run $buildcntr1 git clone https://github.com/projectatomic/skopeo.git /go/src/skopeo # buildah config --workingdir /go/src/skopeo $buildcntr1 # buildah run $buildcntr1 go get -d -v ./... # buildah run $buildcntr1 make binary-local # # # buildcntr2=$(buildah from alpine:latest) # buildmnt2=$(buildah mount $buildcntr2) # buildah run $buildcntr2 apk add --update \ # --no-cache \ # --repository http://dl-3.alpinelinux.org/alpine/edge/testing/ \ # --allow-untrusted \ # jq curl glib gpgme ostree lvm2 libselinux # cp $buildmnt1/go/src/skopeo/skopeo $buildmnt2/usr/bin/skopeo # # buildah unmount $buildcntr2 # buildah commit $buildcntr2 docker://registry.freedesktop.org/libinput/libinput/skopeo:latest # # #clean up build # # buildah rm $buildcntr1 $buildcntr2 # ----- .docker-check: &docker_check stage: docker_check image: registry.freedesktop.org/libinput/libinput/skopeo:latest script: # get the full docker image name (CURRENT_DOCKER_IMAGE still has indirections) - DOCKER_IMAGE=$(eval echo "$CURRENT_DOCKER_IMAGE") # get the date of the current image - IMG_DATE=$(skopeo inspect docker://$DOCKER_IMAGE | jq -r '.Created' | cut -dT -f1) - TODAY_SECS=$(date -u +%s) - IMG_SECS=$(date -u --date="$IMG_DATE" +%s) - echo "today $TODAY_SECS, image $IMG_SECS" - echo "image age $(($TODAY_SECS - $IMG_SECS))s" # check if image is less than a week old - test $(($IMG_SECS + 604800)) -gt $TODAY_SECS # export an artefact telling the next stage that the image is valid - touch .img_ready artifacts: name: image-$CURRENT_DOCKER_IMAGE-check expire_in: 6 hrs paths: - .img_ready allow_failure: true <<: *restrict_docker_creation # TODO: check that the RPMS/DEBS are all in the current images fedora:28@docker-check: variables: GIT_STRATEGY: none FEDORA_VERSION: 28 CURRENT_DOCKER_IMAGE: $FEDORA_DOCKER_IMAGE:latest <<: *docker_check fedora:29@docker-check: variables: GIT_STRATEGY: none FEDORA_VERSION: 29 CURRENT_DOCKER_IMAGE: $FEDORA_DOCKER_IMAGE:latest <<: *docker_check ubuntu:17.10@docker-check: variables: GIT_STRATEGY: none UBUNTU_VERSION: "17.10" CURRENT_DOCKER_IMAGE: $UBUNTU_DOCKER_IMAGE:latest <<: *docker_check ubuntu:18.04@docker-check: variables: GIT_STRATEGY: none UBUNTU_VERSION: "18.04" CURRENT_DOCKER_IMAGE: $UBUNTU_DOCKER_IMAGE:latest <<: *docker_check arch:rolling@docker-check: variables: GIT_STRATEGY: none CURRENT_DOCKER_IMAGE: $ARCH_DOCKER_IMAGE:latest <<: *docker_check freebsd:11.2@docker-check: variables: GIT_STRATEGY: none CURRENT_DOCKER_IMAGE: $FREEBSD_DOCKER_IMAGE:latest <<: *docker_check ################################################################# # # # docker prep stage # # # ################################################################# # # This stage will recreate the docker images only if the previous # stage had a build failure, i.e. the image is too old or if it is # missing some dependencies. # .fedora@docker-prep: &fedora_docker_prep stage: docker_prep image: docker:stable services: - docker:dind script: # if the check was successful, we just skip recreating the docker image - test -e .img_ready && exit 0 - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY # create a Dockerfile with our dependencies - echo "FROM fedora:$FEDORA_VERSION" > Dockerfile - echo "WORKDIR /app" >> Dockerfile - echo "RUN dnf upgrade -y ; dnf clean all" >> Dockerfile - echo "RUN dnf install -y $FEDORA_RPMS ; dnf clean all" >> Dockerfile # create the docker image - docker build --tag $FEDORA_DOCKER_IMAGE:latest --tag $FEDORA_DOCKER_IMAGE:$CI_JOB_ID . # push the docker image to the libinput registry - docker push $FEDORA_DOCKER_IMAGE:latest - docker push $FEDORA_DOCKER_IMAGE:$CI_JOB_ID <<: *restrict_docker_creation fedora:28@docker-prep: variables: GIT_STRATEGY: none FEDORA_VERSION: 28 <<: *fedora_docker_prep dependencies: # Note: we can not use $FEDORA_VERSION here - fedora:28@docker-check fedora:29@docker-prep: variables: GIT_STRATEGY: none FEDORA_VERSION: 29 <<: *fedora_docker_prep dependencies: # Note: we can not use $FEDORA_VERSION here - fedora:29@docker-check # FIXME: we should clean up the apt cache between each run .ubuntu@docker-prep: &ubuntu_docker_prep stage: docker_prep image: docker:stable services: - docker:dind script: # if the check was successful, we just skip recreating the docker image - test -e .img_ready && exit 0 - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY # create a Dockerfile with our dependencies - echo "FROM ubuntu:$UBUNTU_VERSION" > Dockerfile - echo "WORKDIR /app" >> Dockerfile - echo "RUN DEBIAN_FRONTEND=noninteractive apt-get update" >> Dockerfile - echo "RUN DEBIAN_FRONTEND=noninteractive apt-get install -y software-properties-common" >> Dockerfile - echo "RUN DEBIAN_FRONTEND=noninteractive add-apt-repository universe" >> Dockerfile - echo "RUN DEBIAN_FRONTEND=noninteractive apt-get update" >> Dockerfile - echo "RUN DEBIAN_FRONTEND=noninteractive apt-get install -y $UBUNTU_DEBS" >> Dockerfile # create the docker image - docker build --tag $UBUNTU_DOCKER_IMAGE:latest --tag $UBUNTU_DOCKER_IMAGE:$CI_JOB_ID . # push the docker image to the libinput registry - docker push $UBUNTU_DOCKER_IMAGE:latest - docker push $UBUNTU_DOCKER_IMAGE:$CI_JOB_ID <<: *restrict_docker_creation ubuntu:17.10@docker-prep: variables: GIT_STRATEGY: none UBUNTU_VERSION: "17.10" <<: *ubuntu_docker_prep dependencies: # Note: we can not use $UBUNTU_VERSION here - ubuntu:17.10@docker-check ubuntu:18.04@docker-prep: variables: GIT_STRATEGY: none UBUNTU_VERSION: "18.04" <<: *ubuntu_docker_prep dependencies: # Note: we can not use $UBUNTU_VERSION here - ubuntu:18.04@docker-check .arch@docker-prep: &arch_docker_prep stage: docker_prep image: docker:stable services: - docker:dind script: # if the check was successful, we just skip recreating the docker image - test -e .img_ready && exit 0 - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY # create a Dockerfile with our dependencies - echo "FROM base/archlinux" > Dockerfile - echo "WORKDIR /app" >> Dockerfile - echo "RUN pacman -S --refresh; pacman -S --sysupgrade --noconfirm; pacman -S --clean --noconfirm" >> Dockerfile - echo "RUN pacman -S --noconfirm $ARCH_PKGS; pacman -S --clean --noconfirm" >> Dockerfile # create the docker image - docker build --tag $ARCH_DOCKER_IMAGE:latest --tag $ARCH_DOCKER_IMAGE:$CI_JOB_ID . # push the docker image to the libinput registry - docker push $ARCH_DOCKER_IMAGE:latest - docker push $ARCH_DOCKER_IMAGE:$CI_JOB_ID <<: *restrict_docker_creation arch:rolling@docker-prep: variables: GIT_STRATEGY: none <<: *arch_docker_prep dependencies: - arch:rolling@docker-check .freebsd@docker-prep: &freebsd_docker_prep stage: docker_prep image: docker:stable services: - docker:dind script: # if the check was successful, we just skip recreating the docker image - test -e .img_ready && exit 0 - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY # create a Dockerfile with our dependencies - echo "FROM myfreeweb/freebsd-cross:latest" > Dockerfile - echo "WORKDIR /app" >> Dockerfile - echo "RUN apk add --no-cache $FREEBSD_BUILD_PKGS" >> Dockerfile - echo "RUN pkg -r /freebsd update -f" >> Dockerfile - echo "RUN pkg -r /freebsd install -y $FREEBSD_PKGS" >> Dockerfile # create the docker image - docker build --tag $FREEBSD_DOCKER_IMAGE:latest --tag $FREEBSD_DOCKER_IMAGE:$CI_JOB_ID . # push the docker image to the libinput registry - docker push $FREEBSD_DOCKER_IMAGE:latest - docker push $FREEBSD_DOCKER_IMAGE:$CI_JOB_ID <<: *restrict_docker_creation freebsd:11.2@docker-prep: variables: GIT_STRATEGY: none <<: *freebsd_docker_prep dependencies: # Note: we can not use $FREEBSD_VERSION here - freebsd:11.2@docker-check # Add some manual runners to be able to recreate the cache on a day # the list of the rpms changed fedora:28@force-docker-prep: variables: GIT_STRATEGY: none FEDORA_VERSION: 28 <<: *fedora_docker_prep when: manual dependencies: [] fedora:29@force-docker-prep: variables: GIT_STRATEGY: none FEDORA_VERSION: 29 <<: *fedora_docker_prep when: manual dependencies: [] ubuntu:17.10@force-docker-prep: variables: GIT_STRATEGY: none UBUNTU_VERSION: "17.10" <<: *ubuntu_docker_prep when: manual dependencies: [] ubuntu:18.04@force-docker-prep: variables: GIT_STRATEGY: none UBUNTU_VERSION: "18.04" <<: *ubuntu_docker_prep when: manual dependencies: [] arch:rolling@force-docker-prep: variables: GIT_STRATEGY: none <<: *arch_docker_prep when: manual dependencies: [] freebsd:11.2@force-docker-prep: variables: GIT_STRATEGY: none <<: *freebsd_docker_prep when: manual dependencies: [] ################################################################# # # # docker clean stage # # run during the check stage # # # ################################################################# # # This stage will look for the docker images we currently have in # the registry and will remove any that are not tagged as 'latest' # .docker-clean: &docker_clean stage: docker_check image: registry.freedesktop.org/libinput/libinput/skopeo:latest script: # get the full docker image name (CURRENT_DOCKER_IMAGE still has indirections) - DOCKER_IMAGE=$(eval echo "$CURRENT_DOCKER_IMAGE") - REPOSITORY=$(echo $DOCKER_IMAGE | cut -f2- -d/) - IMAGE_PATH=$(echo $DOCKER_IMAGE | cut -f1 -d:) # get the r/w token from the settings to access the registry # # each developer needs to register a secret variable that contains # a personal token with api access in the form of: # PERSONAL_TOKEN_$USER (for example PERSONAL_TOKEN_bentiss) - tokenname="PERSONAL_TOKEN_$GITLAB_USER_LOGIN" - token=$(eval echo "\$$tokenname") # request a token for the registry API - REGISTRY_TOKEN=$(curl https://gitlab.freedesktop.org/jwt/auth --get --silent --show-error -d client_id=docker -d offline_token=true -d service=container_registry -d "scope=repository:$REPOSITORY:pull,*" --fail --user $GITLAB_USER_LOGIN:$token | sed -r 's/(\{"token":"|"\})//g') # get the digest of the latest image - LATEST_MANIFEST=$(skopeo inspect docker://$IMAGE_PATH:latest | jq -r '.Digest') # get the list of tags - TAGS=$(skopeo inspect docker://$IMAGE_PATH | jq -r '.RepoTags[]') # iterate over the tags - for tag in $TAGS; do MANIFEST=$(skopeo inspect docker://$IMAGE_PATH:$tag | jq -r '.Digest'); if test x"$MANIFEST" != x"$LATEST_MANIFEST"; then echo removing $tag as $MANIFEST; curl https://$CI_REGISTRY/v2/$REPOSITORY/manifests/$MANIFEST --silent -H "accept:application/vnd.docker.distribution.manifest.v2+json" -H "authorization:Bearer $REGISTRY_TOKEN" --fail --show-error -X DELETE ;fi ;done dependencies: [] allow_failure: true <<: *restrict_docker_creation fedora:28@docker-clean: variables: GIT_STRATEGY: none FEDORA_VERSION: 28 CURRENT_DOCKER_IMAGE: $FEDORA_DOCKER_IMAGE <<: *docker_clean fedora:29@docker-clean: variables: GIT_STRATEGY: none FEDORA_VERSION: 29 CURRENT_DOCKER_IMAGE: $FEDORA_DOCKER_IMAGE <<: *docker_clean ubuntu:17.10@docker-clean: variables: GIT_STRATEGY: none UBUNTU_VERSION: "17.10" CURRENT_DOCKER_IMAGE: $UBUNTU_DOCKER_IMAGE <<: *docker_clean ubuntu:18.04@docker-clean: variables: GIT_STRATEGY: none UBUNTU_VERSION: "18.04" CURRENT_DOCKER_IMAGE: $UBUNTU_DOCKER_IMAGE <<: *docker_clean arch:rolling@docker-clean: variables: GIT_STRATEGY: none CURRENT_DOCKER_IMAGE: $ARCH_DOCKER_IMAGE <<: *docker_clean freebsd:11.2@docker-clean: variables: GIT_STRATEGY: none CURRENT_DOCKER_IMAGE: $FREEBSD_DOCKER_IMAGE <<: *docker_clean ################################################################# # # # build stage # # # ################################################################# # # Fedora # .fedora@template: &fedora_template stage: build image: $FEDORA_DOCKER_IMAGE:latest <<: *default_artifacts dependencies: [] fedora:28@default-build: variables: FEDORA_VERSION: 28 <<: *fedora_template <<: *default_build .fedora:29@template: &fedora_29_template variables: FEDORA_VERSION: 29 <<: *fedora_template fedora:29@default-build: <<: *fedora_29_template <<: *default_build fedora:29@default-build-release: <<: *fedora_29_template <<: *default_build variables: FEDORA_VERSION: 29 MESON_ARGS: "-Dbuildtype=release" CFLAGS: "-Werror" fedora:29@scan-build: <<: *fedora_29_template <<: *default_build variables: FEDORA_VERSION: 29 NINJA_ARGS: scan-build before_script: - dnf install -y clang-analyzer findutils after_script: - test ! -d "$MESON_BUILDDIR"/meson-logs/scanbuild && exit 0 - test $(find "$MESON_BUILDDIR"/meson-logs/scanbuild -maxdepth 0 ! -empty -exec echo "not empty" \; | wc -l) -eq 0 && exit 0 - echo "Check scan-build results" - /bin/false # Below jobs are build option combinations. We only # run them on one image, they shouldn't fail on one distro # when they succeed on another. fedora:29@build-no-libwacom: <<: *fedora_29_template <<: *default_build variables: FEDORA_VERSION: 29 MESON_ARGS: "-Dlibwacom=false" fedora:29@build-no-libwacom-nodeps: <<: *fedora_29_template <<: *default_build variables: FEDORA_VERSION: 29 MESON_ARGS: "-Dlibwacom=false" before_script: - dnf remove -y libwacom libwacom-devel fedora:29@build-no-docs: <<: *fedora_29_template <<: *default_build variables: FEDORA_VERSION: 29 MESON_ARGS: "-Ddocumentation=false" fedora:29@build-no-docs-nodeps: <<: *fedora_29_template <<: *default_build variables: FEDORA_VERSION: 29 MESON_ARGS: "-Ddocumentation=false" before_script: - dnf remove -y doxygen graphviz fedora:29@build-no-debuggui: <<: *fedora_29_template <<: *default_build variables: FEDORA_VERSION: 29 MESON_ARGS: "-Ddebug-gui=false" fedora:29@build-no-debuggui-nodeps: <<: *fedora_29_template <<: *default_build variables: FEDORA_VERSION: 29 MESON_ARGS: "-Ddebug-gui=false" before_script: - dnf remove -y gtk3-devel fedora:29@build-no-tests: <<: *fedora_29_template <<: *default_build variables: FEDORA_VERSION: 29 MESON_ARGS: "-Dtests=false" fedora:29@build-no-tests-nodeps: <<: *fedora_29_template <<: *default_build variables: FEDORA_VERSION: 29 MESON_ARGS: "-Dtests=false" before_script: - dnf remove -y check-devel fedora:29@valgrind: <<: *fedora_29_template variables: FEDORA_VERSION: 29 script: - rm -rf "$MESON_BUILDDIR" - meson "$MESON_BUILDDIR" $MESON_ARGS - meson configure "$MESON_BUILDDIR" - meson test -C "$MESON_BUILDDIR" --setup=valgrind # # Ubuntu # .ubuntu@template: &ubuntu_template stage: build image: $UBUNTU_DOCKER_IMAGE:latest <<: *default_artifacts dependencies: [] ubuntu:17.10@default-build: variables: UBUNTU_VERSION: "17.10" <<: *ubuntu_template <<: *default_build ubuntu:18.04@default-build: variables: UBUNTU_VERSION: "17.10" <<: *ubuntu_template <<: *default_build # # Arch # .arch@template: &arch_template stage: build image: $ARCH_DOCKER_IMAGE:latest <<: *default_artifacts dependencies: [] arch:rolling@default-build: <<: *arch_template <<: *default_build # # FreeBSD # .freebsd@template: &freebsd_template stage: build image: $FREEBSD_DOCKER_IMAGE:latest variables: MESON_ARGS: '--cross-file freebsd -Ddocumentation=false -Dtests=false -Depoll-dir=/freebsd/usr/local/' # Can't run FreeBSD tests on Linux machine, so NINJA_ARGS shouldn't be "test" NINJA_ARGS: '' <<: *default_artifacts dependencies: [] freebsd:11.2@default-build: <<: *freebsd_template <<: *default_build # # deploy # wayland-web: image: registry.freedesktop.org/libinput/libinput/jq:latest stage: deploy script: - curl --request POST --form "token=$WAYLAND_WEB_TOKEN" --form ref=master https://gitlab.freedesktop.org/api/v4/projects/wayland${SLASH}wayland${DOT}freedesktop${DOT}org/trigger/pipeline only: refs: - master variables: - $CI_PROJECT_PATH == "libinput/libinput" dependencies: [] variables: DOT: "%2E" SLASH: "%2F"