libevdev/.gitlab-ci/gitlab-ci.tmpl
Peter Hutterer edb5b92f89 gitlab CI: keep the results of the check-commit job as artifact
Due to how pytest is used, we don't get the actual errors printed in the
commandline log if this job fails. This doesn't matter in merge requests where
the results are displayed nicely but where there's no merge request we can't
get this info out at all. So let's simply store the xml file for an easy
check.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-03-02 14:11:43 +10:00

573 lines
19 KiB
Cheetah

{# You're looking at the template here, so you can ignore the below
warning. This is the right file to edit #}
########################################
# #
# THIS FILE IS GENERATED, DO NOT EDIT #
# #
########################################
.templates_sha: &template_sha 8410d3382c4ba5e83da76a027cb332169f2a95ad # see https://docs.gitlab.com/ee/ci/yaml/#includefile
include:
{% for distribution in distributions|map(attribute='name')|unique()|sort() %}
# {{ distribution.capitalize() }} container builder template
- project: 'wayland/ci-templates'
ref: *template_sha
file: '/templates/{{distribution}}.yml'
{% endfor %}
stages:
- prep # rebuild the container images if there is a change
- build # for actually building and testing things in a container
- VM # for running the test suite in a VM
- autotools # distribution builds with autotools
- meson # distribution builds with meson
- tarballs # tarball builds
- container_clean # clean up unused container images
variables:
###############################################################################
# This is the list of packages required to build libevdev with the default #
# configuration. #
# #
# Run dnf install/apt-get install/.. with the list of packages for your #
# distribution #
###############################################################################
FEDORA_RPMS: 'git gcc gcc-c++ meson automake autoconf libtool make pkgconfig python3 check-devel valgrind binutils doxygen xz clang-analyzer'
CENTOS_RPMS: 'git gcc gcc-c++ automake autoconf libtool make pkgconfig python3 check-devel valgrind binutils xz'
UBUNTU_DEBS: 'git gcc g++ meson automake autoconf libtool make pkg-config python3 check valgrind binutils doxygen xz-utils'
DEBIAN_DEBS: $UBUNTU_DEBS
ARCH_PKGS: 'git gcc meson automake autoconf libtool make pkgconfig python3 check valgrind binutils doxygen'
ALPINE_PKGS: 'git gcc g++ meson automake autoconf libtool make pkgconfig python3 check-dev valgrind binutils doxygen xz linux-headers'
############################ end of package lists #############################
# these tags should be updated each time the list of packages is updated
# changing these will force rebuilding the associated image
# Note: these tags have no meaning and are not tied to a particular
# libevdev version
FEDORA_TAG: '2020-02-26.4'
CENTOS_TAG: '2020-02-26.4'
DEBIAN_TAG: '2020-02-26.4'
UBUNTU_TAG: '2020-02-26.4'
ARCH_TAG: '2020-02-26.4'
ALPINE_TAG: '2020-02-26.4'
QEMU_TAG: 'qemu-2020-02-26.4'
UPSTREAM_REPO: libevdev/libevdev
BUILDAH_IMAGE: $CI_REGISTRY/wayland/ci-templates/buildah:latest
FEDORA_CONTAINER_IMAGE: $CI_REGISTRY_IMAGE/fedora/$FEDORA_VERSION:$FEDORA_TAG
CENTOS_CONTAINER_IMAGE: $CI_REGISTRY_IMAGE/centos/$CENTOS_VERSION:$CENTOS_TAG
UBUNTU_CONTAINER_IMAGE: $CI_REGISTRY_IMAGE/ubuntu/$UBUNTU_VERSION:$UBUNTU_TAG
DEBIAN_CONTAINER_IMAGE: $CI_REGISTRY_IMAGE/debian/$DEBIAN_VERSION:$DEBIAN_TAG
ARCH_CONTAINER_IMAGE: $CI_REGISTRY_IMAGE/arch/rolling:$ARCH_TAG
ALPINE_CONTAINER_IMAGE: $CI_REGISTRY_IMAGE/alpine/latest:$ALPINE_TAG
QEMU_CONTAINER_IMAGE: $CI_REGISTRY_IMAGE/fedora/$FEDORA_VERSION:$QEMU_TAG
LIBEVDEV_SKIP_ROOT_TESTS: 1
GIT_DEPTH: 1
MESON_BUILDDIR: 'build dir'
.default_artifacts:
artifacts:
paths:
- _build/test/test-suite.log
- $MESON_BUILDDIR/meson-logs/
expire_in: 1 week
when: on_failure
reports:
junit: $MESON_BUILDDIR/junit-*.xml
.autotools_build:
extends:
- .default_artifacts
script:
- mkdir _build
- pushd _build > /dev/null
- ../autogen.sh --disable-silent-rules $CONFIGURE_FLAGS
- make
- make check
- if ! [[ -z "$MAKE_ARGS" ]]; then make $MAKE_ARGS; fi
- popd > /dev/null
.meson_build:
extends:
- .default_artifacts
script:
- .gitlab-ci/meson-build.sh
#################################################################
# #
# prep stage #
# #
#################################################################
# Re-generate the CI script and make sure it's the one currently checked in
# If this job fails, re-generate the gitlab-ci.yml script, see
# $SRCDIR/.gitlab-ci/generate-gitlab-ci.py
#
check-ci-script:
image: golang:alpine
stage: prep
before_script:
- apk add python3 git
- pip3 install --user jinja2 PyYAML
script:
- python3 ./.gitlab-ci/generate-gitlab-ci.py
- git diff --exit-code && exit 0 || true
- echo "Committed gitlab-ci.yml differs from generated gitlab-ci.yml. Please verify"
- exit 1
check-commit:
image: golang:alpine
stage: prep
before_script:
- apk add python3 git
script:
- pip3 install GitPython
- pip3 install pytest
- |
pytest --junitxml=results.xml \
--tb=line \
--assert=plain \
./.gitlab-ci/check-commit.py
except:
- master@libevdev/libevdev
variables:
GIT_DEPTH: 100
artifacts:
when: on_failure
paths:
- results.xml
reports:
junit: results.xml
.pull_upstream_or_rebuild:
before_script:
# log in to the registry
- podman login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
# get the full container image name (DISTRIB_VERSION still has indirections)
- IMAGE=$(eval echo "$DISTRIB_NAME/$DISTRIB_VERSION:$TAG")
- |
# force rebuild if schedule, reuse otherwise
if [[ $CI_PIPELINE_SOURCE != "schedule" ]] ;
then
# pull the latest upstream image if it exists
skopeo copy docker://$CI_REGISTRY/$UPSTREAM_REPO/$IMAGE \
docker://$CI_REGISTRY_IMAGE/$IMAGE && exit 0 || true ;
# check if our image is already in the current registry
skopeo inspect docker://$CI_REGISTRY_IMAGE/$IMAGE > /dev/null && exit 0 || true ;
fi
fedora:31@qemu-prep:
extends:
- .fedora@qemu-build
- .pull_upstream_or_rebuild
stage: prep
tags:
- kvm
variables:
GIT_STRATEGY: none
FEDORA_VERSION: 31
FEDORA_TAG: $QEMU_TAG
DISTRIB_NAME: fedora
DISTRIB_VERSION: $FEDORA_VERSION
TAG: $QEMU_TAG
allow_failure: true
{% for distro in distributions %}
### {{ distro.name }} {{ distro.version }}
{{ distro.name }}:{{ distro.version }}@container-prep:
extends:
- .{{ distro.name }}@container-build
- .pull_upstream_or_rebuild
stage: prep
variables:
GIT_STRATEGY: none
{{ distro.name.upper() }}_VERSION: '{{ distro.version }}'
DISTRIB_NAME: {{ distro.name }}
DISTRIB_VERSION: ${{ distro.name.upper() }}_VERSION
TAG: ${{ distro.name.upper() }}_TAG
{% endfor %}
#################################################################
# #
# container clean stage #
# run during the clean stage #
# #
#################################################################
#
# This stage will look for the container images we currently have in
# the registry and will remove any that are not tagged with the provided
# $container_image:$tag
#
.container-clean:
stage: container_clean
image: $BUILDAH_IMAGE
script:
# get the full container image name (CURRENT_CONTAINER_IMAGE still has indirections)
- CONTAINER_IMAGE=$(eval echo "$CURRENT_CONTAINER_IMAGE")
- GITLAB=$(echo $CI_PROJECT_URL | cut -f3 -d/)
- REPOSITORY=$(echo $CONTAINER_IMAGE | cut -f2- -d/ | cut -f1 -d:)
- IMAGE_PATH=$(echo $CONTAINER_IMAGE | cut -f1 -d:)
- LATEST_TAG=$(echo $CONTAINER_IMAGE | cut -f2 -d:)
# log in to the registry (read only)
- podman login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
# 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. The token
# - must be named PERSONAL_TOKEN_$USER (for example PERSONAL_TOKEN_bentiss)
# - must be registered in the CI/CD Variables section as type file
# - value must be a netrc file as a single-line string:
# default login <user> password <token value>
# e.g. "default login bentiss password 1235abcde"
- tokenname="PERSONAL_TOKEN_$GITLAB_USER_LOGIN"
- netrcfile=$(eval echo "\$$tokenname")
- if [[ ! -f "$netrcfile" ]]; then
echo "No netrc file found or token is missing, skipping job" && false;
fi
# request a token for the registry API
- REGISTRY_TOKEN=$(curl https://$GITLAB/jwt/auth --get
--silent --show-error
-d client_id=docker
-d offline_token=true
-d service=container_registry
-d "scope=repository:$REPOSITORY:pull,*"
--fail
--netrc-file "$netrcfile"
| sed -r 's/(\{"token":"|"\})//g')
# get the digest of the latest image
- LATEST_MANIFEST=$(skopeo inspect docker://$IMAGE_PATH:$LATEST_TAG | jq -r '.Digest')
# get the list of tags
- TAGS=$(skopeo inspect docker://$IMAGE_PATH:$LATEST_TAG | jq -r '.RepoTags[]')
# FIXME: is the above command working properly? If not, use below:
# - TAGS=$(curl -X GET -H "accept:application/vnd.docker.distribution.manifest.v2+json"
# -H "authorization:Bearer $REGISTRY_TOKEN"
# https://$CI_REGISTRY/v2/$REPOSITORY/tags/list | jq -r '.tags[]')
# 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 || true
;fi
;done
dependencies: []
allow_failure: true
only:
- schedules
variables:
GIT_STRATEGY: none
{% for distro in distributions %}
### {{ distro.name }} {{ distro.version }}
{{ distro.name }}:{{ distro.version }}@container-clean:
extends: .container-clean
variables:
{{ distro.name.upper() }}_VERSION: '{{ distro.version }}'
CURRENT_CONTAINER_IMAGE: ${{ distro.name.upper() }}_CONTAINER_IMAGE
{% endfor %}
#################################################################
# #
# build stage #
# #
#################################################################
.autotools-build@template:
extends:
- .autotools_build
stage: build
dependencies: []
variables:
MAKE_ARGS: "distcheck"
.meson-build@template:
extends:
- .meson_build
stage: build
dependencies: []
variables:
NINJA_ARGS: "dist"
{% for distro in distributions %}
{{ distro.name }}:{{ distro.version }}@autotools-build:
extends: .autotools-build@template
stage: autotools
image: ${{ distro.name.upper() }}_CONTAINER_IMAGE
variables:
{{ distro.name.upper() }}_VERSION: '{{ distro.version }}'
{# Where we have extra_variables defined, add them to the list #}
{% if distro.build is defined and distro.build.extra_variables is defined %}
{% for key, value in distro.build.extra_variables.items() %}
{{ key }}: {{ value }}
{% endfor %}
{% endif %}
needs: ['{{ distro.name }}:{{ distro.version }}@container-prep']
{% if not distro.build is defined or distro.build.meson|default(True) %}
{{ distro.name }}:{{ distro.version }}@meson-build:
extends: .meson-build@template
stage: meson
image: ${{ distro.name.upper() }}_CONTAINER_IMAGE
variables:
{{ distro.name.upper() }}_VERSION: '{{ distro.version }}'
{# Where we have extra_variables defined, add them to the list #}
{% if distro.build is defined and distro.build.extra_variables is defined %}
{% for key, value in distro.build.extra_variables.items() %}
{{ key }}: {{ value }}
{% endfor %}
{% endif %}
needs: ['{{ distro.name }}:{{ distro.version }}@container-prep']
{% endif %}
{% endfor %}
# Build argument tests
#
# We only run the build option combinations on one image
# because they're supposed to fail equally on all
.fedora-custom-build@autotools-template:
extends: .autotools-build@template
stage: build
image: $FEDORA_CONTAINER_IMAGE
variables:
FEDORA_VERSION: 31
needs: ['fedora:31@container-prep']
no-valgrind:autotools:
extends: .fedora-custom-build@autotools-template
before_script:
- dnf remove -y valgrind
no-check:autotools:
extends: .fedora-custom-build@autotools-template
before_script:
- dnf remove -y check check-devel
no-doxygen:autotools:
extends: .fedora-custom-build@autotools-template
before_script:
- dnf remove -y doxygen
variables:
MAKE_ARGS: '' # disable distcheck, requires doxygen
# doxygen is required for distcheck
no-doxygen-check-valgrind:autotools:
extends: .fedora-custom-build@autotools-template
before_script:
- dnf remove -y doxygen valgrind check check-devel
variables:
MAKE_ARGS: '' # disable distcheck, requires doxygen
no-nm:autotools:
extends: .fedora-custom-build@autotools-template
before_script:
- mv /usr/bin/nm /usr/bin/nm.moved
enable-gcov:autotools:
extends: .fedora-custom-build@autotools-template
variables:
CONFIGURE_FLAGS: "--enable-gcov"
.fedora-custom-build@meson-template:
extends: .meson-build@template
stage: build
image: $FEDORA_CONTAINER_IMAGE
variables:
FEDORA_VERSION: 31
needs: ['fedora:31@container-prep']
no-valgrind:meson:
extends: .fedora-custom-build@meson-template
before_script:
- dnf remove -y valgrind
no-check:meson:
extends: .fedora-custom-build@meson-template
before_script:
- dnf remove -y check check-devel
variables:
MESON_ARGS: -Dtests=disabled
SKIP_MESON_TEST: 1
# doxygen is required for dist
no-doxygen:meson:
extends: .fedora-custom-build@meson-template
before_script:
- dnf remove -y doxygen
variables:
MESON_ARGS: -Ddocumentation=disabled
NINJA_ARGS: ''
# doxygen is required for dist
no-doxygen-check-valgrind:meson:
extends: .fedora-custom-build@meson-template
before_script:
- dnf remove -y doxygen valgrind check check-devel
variables:
MESON_ARGS: -Dtests=disabled -Ddocumentation=disabled
NINJA_ARGS: ''
SKIP_MESON_TEST: 1
enable-gcov:meson:
extends: .fedora-custom-build@meson-template
variables:
MESON_ARGS: '-Dcoverity=true'
scan-build:meson:
extends: .fedora-custom-build@meson-template
variables:
NINJA_ARGS: 'scan-build'
SKIP_MESON_TEST: 1
soname:
stage: build
image: $FEDORA_CONTAINER_IMAGE
script:
- ./autogen.sh --prefix=$PWD/prefix-autotools/
- make install
- ls -l $PWD/prefix-autotools/lib/libevdev.so.2.3.0
- meson "$MESON_BUILDDIR" --prefix=$PWD/prefix-meson/
- ninja -C "$MESON_BUILDDIR" install
- ls -l $PWD/prefix-meson/lib64/libevdev.so.2.3.0
variables:
FEDORA_VERSION: 31
needs: ['fedora:31@container-prep']
#################################################################
# #
# VM stage #
# #
#################################################################
.check_tainted: &check_tainted |
# make sure the kernel is not tainted
if [[ "$(ssh localhost -p 5555 cat /proc/sys/kernel/tainted)" -gt 0 ]];
then
echo tainted kernel ;
exit 1 ;
fi
.qemu@fedora:31:
stage: VM
image: $QEMU_CONTAINER_IMAGE
tags:
- kvm
variables:
FEDORA_VERSION: 31
MESON_BUILDDIR: build_dir
script:
# start our vm, no args required
- /app/start_vm.sh
- *check_tainted
- "scp -P 5555 -r $PWD localhost:"
- echo "CI_JOB_ID=\"$CI_JOB_ID\"" > sshenv
- echo "CI_JOB_NAME=\"$CI_JOB_NAME\"" >> sshenv
- echo "MESON_BUILDDIR=\"$MESON_BUILDDIR\"" >> sshenv
- echo "MESON_TEST_ARGS=\"$MESON_TEST_ARGS\"" >> sshenv
- echo "NINJA_ARGS=\"$NINJA_ARGS\"" >> sshenv
- "scp -P 5555 sshenv localhost:~/$CI_PROJECT_NAME/.meson_environment"
- ssh localhost -p 5555 "cd $CI_PROJECT_NAME ; .gitlab-ci/meson-build.sh" && touch .success || true
# no matter the results of the tests, we want to fetch the logs
- scp -P 5555 -r localhost:$CI_PROJECT_NAME/"$MESON_BUILDDIR" .
- *check_tainted
- ssh localhost -p 5555 halt || true
- sleep 2
- pkill qemu || true
- if [[ ! -e .success ]] ;
then
exit 1 ;
fi
artifacts:
name: "qemu-meson-logs-$CI_JOB_NAME"
when: always
expire_in: 1 week
paths:
- $MESON_BUILDDIR/meson-logs
- console.out
reports:
junit: $MESON_BUILDDIR/junit-*.xml
retry:
max: 2
when: script_failure
needs: ['fedora:31@qemu-prep']
qemu:meson:
extends: .qemu@fedora:31
qemu:meson:valgrind:
extends: .qemu@fedora:31
variables:
MESON_TEST_ARGS: '--setup=valgrind'
meson-from-tarball:
stage: tarballs
image: $FEDORA_CONTAINER_IMAGE
script:
- export INSTALLDIR="$PWD/_inst"
- mkdir _build
- pushd _build > /dev/null
- ../autogen.sh --disable-silent-rules $CONFIGURE_FLAGS
- make
- make distcheck
- popd > /dev/null
- mkdir -p _tarball_dir
- tar xf _build/libevdev-*.tar.xz -C _tarball_dir
- pushd _tarball_dir/libevdev-*/ > /dev/null
- meson "$MESON_BUILDDIR" --prefix="$INSTALLDIR"
- ninja -C "$MESON_BUILDDIR" test
- ninja -C "$MESON_BUILDDIR" install
- popd > /dev/null
- ls -lR $INSTALLDIR
variables:
FEDORA_VERSION: 31
needs: ['fedora:31@container-prep']
autotools-from-tarball:
stage: tarballs
image: $FEDORA_CONTAINER_IMAGE
script:
- export INSTALLDIR="$PWD/_inst"
- meson "$MESON_BUILDDIR"
- ninja -C "$MESON_BUILDDIR" dist
- mkdir -p _tarball_dir
- tar xf "$MESON_BUILDDIR"/meson-dist/libevdev-*.xz -C _tarball_dir
- pushd _tarball_dir/libevdev-*/ > /dev/null
- mkdir _build
- pushd _build > /dev/null
- ../autogen.sh --disable-silent-rules --prefix="$INSTALLDIR" $CONFIGURE_FLAGS
- make
- make install
- make distcheck
- popd > /dev/null
- popd > /dev/null
- ls -lR $INSTALLDIR
variables:
FEDORA_VERSION: 31
needs: ['fedora:31@container-prep']