Skip to content

Commit 21a3c6f

Browse files
committed
Add test coverage report
1 parent 8e9e919 commit 21a3c6f

File tree

3 files changed

+21
-9
lines changed

3 files changed

+21
-9
lines changed

.devcontainer/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ RUN apt update && apt upgrade --yes
99

1010
RUN apt install --yes gcc-14 g++-14
1111
RUN apt install --yes clang-format pre-commit
12-
RUN apt install --yes lcov
12+
RUN apt install --yes gcovr lcov
1313

1414
# Choose default gcc and g++ version
1515

.github/workflows/coverage.yml

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,22 @@ on: # rebuild any PRs and main branch changes
88

99
jobs:
1010
coverage:
11-
uses: ./.github/workflows/devcontainer-command.yml
12-
with:
13-
run_cmd: |
14-
cmake -E make_directory build
15-
cmake -B build -DCMAKE_BUILD_TYPE=Debug -DTRAITS_TEST_COVERAGE=On -S .
16-
cmake --build build --config Debug --target all
17-
cmake --build build --config Debug --target test
18-
cmake --build build --config Debug --target coverage
11+
runs-on: 'ubuntu-24.04'
12+
13+
steps:
14+
- name: Check test coverage
15+
uses: ./.github/actions/devcontainer
16+
with:
17+
command: |
18+
cmake -E make_directory build
19+
cmake -B build -DCMAKE_BUILD_TYPE=Debug -DTRAITS_TEST_COVERAGE=On -S .
20+
cmake --build build --config Debug --target all
21+
cmake --build build --config Debug --target test
22+
cmake --build build --config Debug --target coverage
23+
24+
- name: Create test coverage report
25+
uses: irongut/[email protected]
26+
with:
27+
filename: coverage.cobertura.xml
28+
badge: true
1929

tests/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ add_test(NAME test.fetch COMMAND ${CMAKE_COMMAND} --build "${PROJECT_BINARY_DIR}
6868

6969
if(TRAITS_TEST_COVERAGE)
7070
find_program(LCOV lcov REQUIRED)
71+
find_program(GCOVR gcovr REQUIRED)
7172
find_program(GENHTML genhtml REQUIRED)
7273

7374
set(CMAKE_CXX_FLAGS "-O0 -coverage")
@@ -78,5 +79,6 @@ if(TRAITS_TEST_COVERAGE)
7879
COMMAND "${LCOV}" --remove coverage.info '/usr/*' '*/gtest/*' --output-file coverage.info
7980
COMMAND "${LCOV}" --list coverage.info
8081
COMMAND "${GENHTML}" --demangle-cpp -o coverage coverage.info
82+
COMMAND "${GCOVR}" --cobertura --output coverage.cobertura.xml
8183
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}")
8284
endif()

0 commit comments

Comments
 (0)