From 18bcda274ff8c2d52884e8bf54e878fe9abb474c Mon Sep 17 00:00:00 2001 From: Kevin Mooney Date: Fri, 21 Jun 2024 13:49:02 +0000 Subject: [PATCH] Add coverage stats to CI. This patch adds a CI pipeline that builds the project with --coverage, runs the unit tests and collects the coverage data with gcovr. A coverage statistic is printed to the console log, which is extracted with a regex. The current gitlab runners don't support SVE, so all coverage statistics for files containing the string "sve" are excluded. Unfortunately, gcovr's parser is unstable, so the docker image has been fixed to a version that is known to work for us, in this case ubuntu 22.04. Putting keywords in the the top section is deprecated, so all default settings have been moved into a default section. DEBIAN_FRONTENT=noninteractive is set, to prevent apt waiting for user input. --- .gitlab-ci.yml | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b5e888b..3bb9f20 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,12 +1,20 @@ -image: gcc - -before_script: - - apt-get update --yes - - apt-get install --yes cmake - -build: +default: + image: ubuntu:22.04 tags: - arm64 + before_script: + - apt update --yes + - DEBIAN_FRONTEND=noninteractive apt install --yes cmake g++ git gcovr + - mkdir build && cd build + +build-and-test: + script: + - cmake .. && make -j $(nproc) && ctest -j $(nproc) + +code-coverage: script: - - mkdir build - - cd build && cmake .. && make -j && ctest + - cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS="--coverage" -DCMAKE_EXE_LINKER_FLAGS="--coverage" + - make -j $(nproc) + - ctest -j $(nproc) + - gcovr -r .. -f "../src" -e ".*sve" + coverage: /^TOTAL.*\s+(\d+\%)$/ -- GitLab