Enable Test Coverage Visualization for merge requests
This feature allows GitLab to visualize test coverage information in the
file diff view of merge requests.
This commit makes the gcov CI job depend on the following chain of jobs:
gcc:buster:amd64 → unit:gcc:buster:amd64 → system:gcc:buster:amd64
The reason for running the last two jobs above sequentially rather than
in parallel is that both of them create *.gcda files (containing
coverage data) in the same locations. While some way of merging these
files from different job artifact archives could probably be designed
with the help of additional tools, the simplest thing to do is not to
run unit test and system test jobs in parallel, carrying *.gcda files
over between jobs as gcov knows how to append coverage data to existing
*.gcda files.
Also note that test coverage will not be visualized if any of the jobs
in the above dependency chain fails (because the gcov job will not be
run).
This commit is contained in:
@@ -290,6 +290,13 @@ stages:
|
||||
expire_in: "1 day"
|
||||
when: on_failure
|
||||
|
||||
.system_test_gcov: &system_test_gcov_job
|
||||
<<: *system_test_common
|
||||
artifacts:
|
||||
untracked: true
|
||||
expire_in: "1 day"
|
||||
when: always
|
||||
|
||||
.system_test_tsan: &system_test_tsan_job
|
||||
<<: *system_test_common
|
||||
allow_failure: true
|
||||
@@ -347,6 +354,13 @@ stages:
|
||||
expire_in: "1 day"
|
||||
when: on_failure
|
||||
|
||||
.unit_test_gcov: &unit_test_gcov_job
|
||||
<<: *unit_test_common
|
||||
artifacts:
|
||||
untracked: true
|
||||
expire_in: "1 day"
|
||||
when: always
|
||||
|
||||
.unit_test_tsan: &unit_test_tsan_job
|
||||
<<: *unit_test_common
|
||||
after_script:
|
||||
@@ -629,21 +643,21 @@ unit:gcc:stretch:amd64:
|
||||
gcc:buster:amd64:
|
||||
variables:
|
||||
CC: gcc
|
||||
CFLAGS: "${CFLAGS_COMMON}"
|
||||
EXTRA_CONFIGURE: "${WITH_READLINE_LIBEDIT}"
|
||||
CFLAGS: "${CFLAGS_COMMON} --coverage -O0"
|
||||
EXTRA_CONFIGURE: "--enable-dnstap --with-libidn2 ${WITH_READLINE_LIBEDIT}"
|
||||
<<: *debian_buster_amd64_image
|
||||
<<: *build_job
|
||||
|
||||
system:gcc:buster:amd64:
|
||||
<<: *debian_buster_amd64_image
|
||||
<<: *system_test_job
|
||||
<<: *system_test_gcov_job
|
||||
needs:
|
||||
- job: gcc:buster:amd64
|
||||
- job: unit:gcc:buster:amd64
|
||||
artifacts: true
|
||||
|
||||
unit:gcc:buster:amd64:
|
||||
<<: *debian_buster_amd64_image
|
||||
<<: *unit_test_job
|
||||
<<: *unit_test_gcov_job
|
||||
needs:
|
||||
- job: gcc:buster:amd64
|
||||
artifacts: true
|
||||
@@ -1374,21 +1388,12 @@ abi-check:
|
||||
|
||||
gcov:
|
||||
<<: *base_image
|
||||
stage: build
|
||||
<<: *default_triggering_rules
|
||||
stage: postcheck
|
||||
needs:
|
||||
- job: autoreconf
|
||||
- job: system:gcc:buster:amd64
|
||||
artifacts: true
|
||||
variables:
|
||||
CC: gcc
|
||||
CFLAGS: "${CFLAGS_COMMON} --coverage -O0"
|
||||
EXTRA_CONFIGURE: "--enable-dnstap --with-libidn2"
|
||||
script:
|
||||
- *configure
|
||||
- *setup_interfaces
|
||||
- *setup_softhsm
|
||||
- make -j${BUILD_PARALLEL_JOBS:-1} -k all V=1
|
||||
- make -j${TEST_PARALLEL_JOBS:-1} -k unit V=1 || true
|
||||
- make -C bin/tests/system -j${TEST_PARALLEL_JOBS:-1} -k check V=1 || cat bin/tests/system/test-suite.log
|
||||
# *.gcno and *.gcda files generated for shared library objects are created
|
||||
# in directories in which gcovr is unable to process them properly
|
||||
# (.../.libs/...). Move such *.gcno and *.gcda files one level higher.
|
||||
@@ -1396,15 +1401,20 @@ gcov:
|
||||
# Help gcovr process the nasty tricks in lib/dns/code.h, where we include C
|
||||
# source files from lib/dns/rdata/*/, using an even nastier trick.
|
||||
- find lib/dns/rdata/* -name "*.c" -execdir cp -f "{}" ../../ \;
|
||||
# Generate XML file in the Cobertura XML format suitable for use by GitLab
|
||||
# for the purpose of displaying code coverage information in the diff view
|
||||
# of a given merge request.
|
||||
- gcovr --root . --exclude-directories bin/tests --exclude-directories doc --exclude-directories libltdl --exclude-directories lib/samples --exclude 'lib/.*/tests/.*' --xml -o coverage.xml
|
||||
- gcovr --root . --exclude-directories bin/tests --exclude-directories doc --exclude-directories libltdl --exclude-directories lib/samples --exclude 'lib/.*/tests/.*' --html-details -o coverage.html
|
||||
- gcovr --root . --exclude-directories bin/tests --exclude-directories doc --exclude-directories libltdl --exclude-directories lib/samples --exclude 'lib/.*/tests/.*' -o coverage.txt
|
||||
- tail -n 3 coverage.txt
|
||||
artifacts:
|
||||
paths:
|
||||
- coverage*.html
|
||||
only:
|
||||
- main@isc-projects/bind9
|
||||
- /^v9_[1-9][0-9]$/@isc-projects/bind9
|
||||
- coverage.txt
|
||||
- coverage.xml
|
||||
reports:
|
||||
cobertura: coverage.xml
|
||||
|
||||
# Pairwise testing of ./configure options
|
||||
|
||||
|
||||
Reference in New Issue
Block a user