ci: fix coverage to match Code Coverage job output
All checks were successful
CI Code / Check coding style (pull_request) Successful in 28s
CI Code / Check spelling (pull_request) Successful in 17s
CI Code / Linux (arch) (pull_request) Successful in 6m46s
CI Code / Linux (debian) (pull_request) Successful in 6m37s
CI Code / Linux (ubuntu) (pull_request) Successful in 6m37s
CI Code / Code Coverage (pull_request) Successful in 15m23s

Use --extract '*/src/src/*' instead of --remove to properly filter
production code from tests. Coverage now shows 27.5% lines matching
the dedicated Code Coverage job.
This commit is contained in:
2026-01-28 22:51:46 +03:00
parent 9a2a7614a9
commit 6c5c523a1a

View File

@@ -259,16 +259,11 @@ build_and_test() {
if [ "$run_coverage" = "yes" ]; then
echo "--> Collecting coverage data..."
if command -v lcov >/dev/null 2>&1; then
lcov --capture --directory . --output-file coverage.info \
lcov --capture --directory . --output-file coverage-full.info \
--rc lcov_branch_coverage=1 --ignore-errors inconsistent 2>&1 || true
# Remove test files, stubs, system headers - only keep src/ production code
lcov --remove coverage.info \
'/usr/*' \
'*/tests/*' \
'*test*.c' \
'*stub*.c' \
'*/functionaltests/*' \
'*/unittests/*' \
# Extract only production code from src/ directory, exclude tests
# Pattern matches both Docker (/src/src/*) and CI (/usr/src/profanity/src/*)
lcov --extract coverage-full.info '*/profanity/src/*' '*/src/src/*' \
--output-file coverage.info \
--rc lcov_branch_coverage=1 --ignore-errors inconsistent 2>&1 || true
if [ -f coverage.info ] && [ -s coverage.info ]; then