From 36551f95947f8a3815dd3dc579e8a3ed10302e76 Mon Sep 17 00:00:00 2001 From: Hugo Date: Wed, 30 Sep 2026 07:58:18 +0200 Subject: [PATCH 1/3] ci: report test coverage and enforce a minimum threshold --- .github/workflows/coverage.yml | 52 ++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 .github/workflows/coverage.yml diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 0000000..6ed41e4 --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,52 @@ +# SPDX-License-Identifier: MIT +name: Coverage + +on: + push: + branches: [main] + pull_request: + workflow_dispatch: + +jobs: + coverage: + name: Line coverage + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install dependencies + run: | + set -euo pipefail + sudo apt-get update + sudo apt-get install -y --no-install-recommends cmake ninja-build g++ + pipx install gcovr==8.6 + + - name: Configure + run: | + set -euo pipefail + cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Debug \ + -DCMAKE_CXX_FLAGS="--coverage" \ + -DCMAKE_EXE_LINKER_FLAGS="--coverage" + + - name: Build + run: cmake --build build + + - name: Test + run: ctest --test-dir build --output-on-failure + + # Search only the library, example and test objects: CMake's compiler + # detection also leaves coverage data under build/CMakeFiles. + - name: Report + run: | + set -euo pipefail + status=0 + gcovr --root . --filter src/ --filter include/ \ + --print-summary --markdown-summary coverage.md \ + --fail-under-line 90 \ + build/CMakeFiles/coretrace_logger.dir \ + build/CMakeFiles/coretrace_logger_example.dir \ + build/tests || status=$? + cat coverage.md >> "$GITHUB_STEP_SUMMARY" + exit "$status" From 9413f1989f06b1e194f2c8aecda1880943008592 Mon Sep 17 00:00:00 2001 From: Hugo Date: Wed, 30 Sep 2026 08:01:23 +0200 Subject: [PATCH 2/3] ci: use atomic coverage counters for the multithreaded tests --- .github/workflows/coverage.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 6ed41e4..a331bcd 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -26,8 +26,10 @@ jobs: - name: Configure run: | set -euo pipefail + # Atomic counters: the multithreaded tests would otherwise corrupt + # them and gcov reports negative hits (GCC bug 68080). cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Debug \ - -DCMAKE_CXX_FLAGS="--coverage" \ + -DCMAKE_CXX_FLAGS="--coverage -fprofile-update=atomic" \ -DCMAKE_EXE_LINKER_FLAGS="--coverage" - name: Build @@ -48,5 +50,7 @@ jobs: build/CMakeFiles/coretrace_logger.dir \ build/CMakeFiles/coretrace_logger_example.dir \ build/tests || status=$? - cat coverage.md >> "$GITHUB_STEP_SUMMARY" + if [ -f coverage.md ]; then + cat coverage.md >> "$GITHUB_STEP_SUMMARY" + fi exit "$status" From 10c356fc7334323d8fa360359695dc38da2b1cec Mon Sep 17 00:00:00 2001 From: Hugo Date: Wed, 30 Sep 2026 08:04:04 +0200 Subject: [PATCH 3/3] ci: set the coverage floor to the measured 88% of lines --- .github/workflows/coverage.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index a331bcd..87a6dd9 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -40,13 +40,15 @@ jobs: # Search only the library, example and test objects: CMake's compiler # detection also leaves coverage data under build/CMakeFiles. + # The floor is the coverage measured with GCC 13 on 2026-09-30 (88.7% of + # lines). Raise it when coverage grows. - name: Report run: | set -euo pipefail status=0 gcovr --root . --filter src/ --filter include/ \ --print-summary --markdown-summary coverage.md \ - --fail-under-line 90 \ + --fail-under-line 88 \ build/CMakeFiles/coretrace_logger.dir \ build/CMakeFiles/coretrace_logger_example.dir \ build/tests || status=$?