weston/.gitlab-ci.yml
Pekka Paalanen e72119f1ee CI: add test coverage results
This runs the coverage tools to produce HTML pages listing the code lines /
functions / branches hit/totalled by the test suite.

Nowadays Gitlab has some Cobertura support itself:
https://docs.gitlab.com/ee/user/project/merge_requests/test_coverage_visualization.html

lcov is needed for the HTML report, gcovr is needed for the Cobertura
report. 'ninja clean' must be removed, otherwise it deletes the coverage
files before they are analysed.

Seeing the test suite code coverage is really interesting. It can guide
designing tests. If Gitlab MRs show the coverage in diff view, it shows
if new code actually gets executed in CI.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-03-08 15:55:14 +02:00

161 lines
3.7 KiB
YAML

# vim: set expandtab shiftwidth=2 tabstop=8 textwidth=0:
variables:
FDO_UPSTREAM_REPO: wayland/weston
include:
- project: 'freedesktop/ci-templates'
ref: 59de540b620c45739871d1a073d76d5521989d11
file: '/templates/debian.yml'
stages:
- container_prep
- build
- pages
.debian:
variables:
FDO_DISTRIBUTION_VERSION: buster
FDO_DISTRIBUTION_EXEC: 'bash .gitlab-ci/debian-install.sh'
FDO_DISTRIBUTION_TAG: '2021-03-04.1'
container_prep:
extends:
- .debian
- .fdo.container-build@debian
stage: container_prep
.build-native:
extends:
- .debian
- .fdo.distribution-image@debian
stage: build
before_script:
- git clone --depth=1 https://gitlab.freedesktop.org/wayland/wayland-protocols
- export WAYLAND_PROTOCOLS_DIR="$(pwd)/prefix-wayland-protocols"
- export PKG_CONFIG_PATH="$WAYLAND_PROTOCOLS_DIR/share/pkgconfig:$PKG_CONFIG_PATH"
- export MAKEFLAGS="-j4"
- cd wayland-protocols
- git show -s HEAD
- mkdir build
- cd build
- ../autogen.sh --prefix="$WAYLAND_PROTOCOLS_DIR"
- make install
- cd ../../
- export XDG_RUNTIME_DIR="$(mktemp -p $(pwd) -d xdg-runtime-XXXXXX)"
- export BUILD_ID="weston-$CI_JOB_NAME"
- export PREFIX="$(pwd)/prefix-$BUILD_ID"
- export BUILDDIR="$(pwd)/build-$BUILD_ID"
- export TESTS_RES_PATH="$BUILDDIR/tests-res.txt"
- mkdir "$BUILDDIR" "$PREFIX"
.build-native-meson:
extends: .build-native
tags:
- kvm
script:
- export PATH=~/.local/bin:$PATH
- cd "$BUILDDIR"
- meson --prefix="$PREFIX" ${MESON_OPTIONS} ..
- ninja -k0
- ninja install
- virtme-run --rw --pwd --kimg /weston-virtme/bzImage --script-dir ../.gitlab-ci/virtme-scripts
- TEST_RES=$(cat $TESTS_RES_PATH)
- rm $TESTS_RES_PATH
- cp -R /weston-virtme ./
- rm weston-virtme/bzImage
- exit $TEST_RES
artifacts:
name: weston-$CI_COMMIT_SHA
when: always
paths:
- build-*/*.png
- build-*/meson-logs
- build-*/weston-virtme
- prefix-*
reports:
junit: build-*/meson-logs/testlog.junit.xml
.build-native-meson-no-test:
extends: .build-native
tags:
- kvm
script:
- export PATH=~/.local/bin:$PATH
- cd "$BUILDDIR"
- meson --prefix="$PREFIX" ${MESON_OPTIONS} ..
- ninja -k0
- ninja install
- ninja clean
artifacts:
name: weston-$CI_COMMIT_SHA
when: always
paths:
- build-*/meson-logs
- prefix-*
build-native-meson-default-options:
variables:
MESON_OPTIONS: >
-Doptimization=0
-Db_coverage=true
-Dwerror=true
extends: .build-native-meson
after_script:
- ninja -C build-* coverage-html
- ninja -C build-* coverage-xml
artifacts:
reports:
cobertura: build-*/meson-logs/coverage.xml
build-docs:
variables:
MESON_OPTIONS: >
-Dwerror=true
-Ddoc=true
extends: .build-native-meson-no-test
build-native-meson-no-gl-renderer:
variables:
MESON_OPTIONS: >
-Dsimple-clients=damage,im,shm,touch,dmabuf-v4l
-Drenderer-gl=false
-Dremoting=false
-Dpipewire=false
-Dwerror=true
extends: .build-native-meson
docs-and-coverage:
stage: pages
script:
- mv prefix-weston-build-docs/share/doc/weston Documentation
- mv build-weston-build-native-meson-default-options/meson-logs/coveragereport Test_Coverage
- rm -rf build-* prefix-*
dependencies:
- build-docs
- build-native-meson-default-options
artifacts:
expose_as: 'Documentation preview and test coverage report'
paths:
- Documentation/
- Test_Coverage/
pages:
stage: pages
dependencies:
- build-docs
script:
- export PREFIX=$(pwd)/prefix-weston-build-docs
- mkdir public
- cp -R $PREFIX/share/doc/weston/* public/
artifacts:
paths:
- public
only:
- master