Skip to content

Commit 6d6bf64

Browse files
committed
Merge branch 'fix-ci-coverage-reporting' into 'master'
Fix CI coverage reporting with gcovr and function coverage See merge request chase/chase-library/ChASE!100
2 parents 9ed9a4f + 3f82fe0 commit 6d6bf64

1 file changed

Lines changed: 54 additions & 21 deletions

File tree

.gitlab-ci.yml

Lines changed: 54 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ build_cpu:
3232
- cmake --version
3333
- mkdir -p build_cpu
3434
- cd build_cpu
35-
- env CFLAGS="$CFLAGS --coverage" CXXFLAGS="$CXXFLAGS --coverage" FFLAGS="$FFLAGS --coverage" cmake -DCMAKE_C_COMPILER=mpicc -DCMAKE_CXX_COMPILER=mpicxx -DCMAKE_Fortran_COMPILER=mpifort -DCHASE_ENABLE_MIXED_PRECISION=ON -DCHASE_ENABLE_TESTS=ON -DMPI_RUN_ARGS="--allow-run-as-root" .. -DCMAKE_EXE_LINKER_FLAGS="-lgfortran -Wl,--copy-dt-needed-entries --coverage"
35+
- cmake -DCMAKE_C_COMPILER=mpicc -DCMAKE_CXX_COMPILER=mpicxx -DCMAKE_Fortran_COMPILER=mpifort -DCHASE_ENABLE_TESTS=ON -DMPI_RUN_ARGS="--allow-run-as-root" .. -DCMAKE_EXE_LINKER_FLAGS="-lgfortran -Wl,--copy-dt-needed-entries"
3636
- make VERBOSE=1 -j4
3737
artifacts:
3838
paths:
@@ -53,10 +53,6 @@ test_cpu:
5353
- cd build_cpu
5454
- CTEST_OUTPUT_ON_FAILURE=1 make test
5555
- rm -rf _deps
56-
artifacts:
57-
paths:
58-
- build_cpu/*
59-
expire_in: 1 week
6056

6157
build_gpu:
6258
stage: build
@@ -71,11 +67,11 @@ build_gpu:
7167
<<: *only_source_changes
7268
script:
7369
- echo $SYSTEMNAME
74-
- module load Stages/2025 GCC/13.3.0 OpenMPI imkl CMake CUDA
70+
- module load Stages/2026 GCC/14.3.0 OpenMPI FlexiBLAS/3.4.5 CMake CUDA
7571
- cmake --version
7672
- mkdir -p build_gpu
7773
- cd build_gpu
78-
- env CFLAGS="$CFLAGS --coverage" CXXFLAGS="$CXXFLAGS --coverage" FFLAGS="$FFLAGS --coverage" cmake -DCMAKE_C_COMPILER=mpicc -DCMAKE_CXX_COMPILER=mpicxx -DCMAKE_Fortran_COMPILER=mpifort -DCHASE_ENABLE_MIXED_PRECISION=ON -DCHASE_ENABLE_TESTS=ON -DMPI_RUN="srun" -DCMAKE_BUILD_TYPE=Release .. -DCMAKE_EXE_LINKER_FLAGS="--coverage"
74+
- env CFLAGS="$CFLAGS --coverage" CXXFLAGS="$CXXFLAGS --coverage" FFLAGS="$FFLAGS --coverage" cmake -DCMAKE_C_COMPILER=mpicc -DCMAKE_CXX_COMPILER=mpicxx -DCMAKE_Fortran_COMPILER=mpifort -DCHASE_ENABLE_TESTS=ON -DMPI_RUN="srun" .. -DCMAKE_EXE_LINKER_FLAGS="--coverage"
7975
- make VERBOSE=1 -j8
8076
artifacts:
8177
paths:
@@ -99,7 +95,7 @@ test_gpu:
9995
<<: *only_source_changes
10096
script:
10197
- echo $SYSTEMNAME
102-
- module load Stages/2025 GCC/13.3.0 OpenMPI imkl CMake CUDA
98+
- module load Stages/2026 GCC/14.3.0 OpenMPI FlexiBLAS/3.4.5 CMake CUDA
10399
- export CUDA_VISIBLE_DEVICES=0,1,2,3
104100
- cd build_gpu
105101
- CTEST_OUTPUT_ON_FAILURE=1 make test
@@ -111,29 +107,60 @@ test_gpu:
111107

112108
coverage_generate:
113109
stage: coverage
114-
coverage: '/lines......: (\d+[.]\d+)/'
110+
coverage: '/functions......: (\d+[.]\d+)/'
115111
dependencies:
116112
- test_gpu
117-
tags: [ public-docker ]
118-
image:
119-
name: xinzhewu/lcov-gcc13.3.0
113+
tags:
114+
- juwels_booster
115+
- jacamar
116+
- login
117+
- shell
118+
id_tokens:
119+
SITE_ID_TOKEN:
120+
aud: https://gitlab.jsc.fz-juelich.de
120121
<<: *only_source_changes
121122
script:
122-
# Ignore gcov errors (e.g. stamp mismatch when artifacts from different runner)
123-
- lcov --capture --directory ./build_gpu --output-file coverage.info --ignore-errors gcov
124-
125-
# Extract coverage number
123+
- echo $SYSTEMNAME
124+
- module load Stages/2026 GCC/14.3.0 OpenMPI FlexiBLAS/3.4.5 CMake CUDA
125+
126+
# Install gcovr and update PATH
126127
- |
127-
COV=$(lcov --summary coverage.info | grep -oP 'lines.*: \K\d+\.\d+')
128-
echo "Total coverage = ${COV}%"
129-
130-
# Choose badge color
128+
echo "Installing gcovr..."
129+
pip install --user gcovr
130+
export PATH=${HOME}/.local/bin:$PATH
131+
echo "gcovr version: $(gcovr --version)"
132+
133+
# Generate coverage reports
134+
- |
135+
echo "Generating coverage reports..."
136+
cd build_gpu
137+
gcovr --root .. \
138+
--json-summary coverage.json \
139+
--xml coverage.xml \
140+
--html coverage.html \
141+
--html-details \
142+
--html-title "ChASE Coverage Report" \
143+
--exclude-unreachable-branches \
144+
--exclude "tests/" \
145+
--exclude "external/" \
146+
--exclude "_deps/" \
147+
--gcov-ignore-errors=all \
148+
--print-summary
149+
cd ..
150+
151+
# Extract function coverage percentage
152+
- |
153+
COV=$(jq -r '.function_percent' build_gpu/coverage.json)
154+
echo "Function coverage = ${COV}%"
155+
156+
# Choose badge color based on function coverage
131157
- |
132158
if (( $(echo "$COV < 70" | bc -l) )); then COLOR=red
133159
elif (( $(echo "$COV < 85" | bc -l) )); then COLOR=yellow
134160
else COLOR=brightgreen
135161
fi
136-
162+
echo "Badge color: ${COLOR}"
163+
137164
# Create Shields-compatible JSON
138165
- |
139166
mkdir -p coverage
@@ -145,8 +172,14 @@ coverage_generate:
145172
"color": "${COLOR}"
146173
}
147174
EOF
175+
176+
# Display badge JSON
177+
- cat coverage/coverage.json
148178
artifacts:
149179
paths:
180+
- build_gpu/coverage.json
181+
- build_gpu/coverage.xml
182+
- build_gpu/coverage.html
150183
- coverage/coverage.json
151184
expire_in: 1 week
152185

0 commit comments

Comments
 (0)