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>
dev
Pekka Paalanen 5 years ago
parent 022ea43f9b
commit e72119f1ee
  1. 18
      .gitlab-ci.yml
  2. 2
      .gitlab-ci/debian-install.sh

@ -20,7 +20,7 @@ stages:
variables: variables:
FDO_DISTRIBUTION_VERSION: buster FDO_DISTRIBUTION_VERSION: buster
FDO_DISTRIBUTION_EXEC: 'bash .gitlab-ci/debian-install.sh' FDO_DISTRIBUTION_EXEC: 'bash .gitlab-ci/debian-install.sh'
FDO_DISTRIBUTION_TAG: '2021-02-25.1' FDO_DISTRIBUTION_TAG: '2021-03-04.1'
container_prep: container_prep:
@ -67,7 +67,6 @@ container_prep:
- virtme-run --rw --pwd --kimg /weston-virtme/bzImage --script-dir ../.gitlab-ci/virtme-scripts - virtme-run --rw --pwd --kimg /weston-virtme/bzImage --script-dir ../.gitlab-ci/virtme-scripts
- TEST_RES=$(cat $TESTS_RES_PATH) - TEST_RES=$(cat $TESTS_RES_PATH)
- rm $TESTS_RES_PATH - rm $TESTS_RES_PATH
- ninja clean
- cp -R /weston-virtme ./ - cp -R /weston-virtme ./
- rm weston-virtme/bzImage - rm weston-virtme/bzImage
- exit $TEST_RES - exit $TEST_RES
@ -103,8 +102,16 @@ container_prep:
build-native-meson-default-options: build-native-meson-default-options:
variables: variables:
MESON_OPTIONS: > MESON_OPTIONS: >
-Doptimization=0
-Db_coverage=true
-Dwerror=true -Dwerror=true
extends: .build-native-meson 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: build-docs:
variables: variables:
@ -123,17 +130,20 @@ build-native-meson-no-gl-renderer:
-Dwerror=true -Dwerror=true
extends: .build-native-meson extends: .build-native-meson
preview-docs: docs-and-coverage:
stage: pages stage: pages
script: script:
- mv prefix-weston-build-docs/share/doc/weston Documentation - 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-* - rm -rf build-* prefix-*
dependencies: dependencies:
- build-docs - build-docs
- build-native-meson-default-options
artifacts: artifacts:
expose_as: 'Documentation preview' expose_as: 'Documentation preview and test coverage report'
paths: paths:
- Documentation/ - Documentation/
- Test_Coverage/
pages: pages:
stage: pages stage: pages

@ -36,7 +36,9 @@ apt-get -y --no-install-recommends install \
build-essential \ build-essential \
curl \ curl \
doxygen \ doxygen \
gcovr \
git \ git \
lcov \
libasound2-dev \ libasound2-dev \
libbluetooth-dev \ libbluetooth-dev \
libcairo2-dev \ libcairo2-dev \

Loading…
Cancel
Save