Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions .github/workflows/bvt-codecoverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
on:
workflow_call:
workflow_dispatch:

jobs:
bvt-codecoverage:
runs-on: ubuntu-24.04
container: gcc:16
steps:
- uses: actions/checkout@v7

- name: Install CMake, Ninja, and gcovr
run: |
apt-get update
apt-get install -y cmake ninja-build gcovr

- name: Check toolchain versions
run: |
g++ --version
gcov --version
cmake --version
ninja --version
gcovr --version

- name: Build and run tests with code coverage instrumentation
run: |
cmake --preset coverage -DCMAKE_CXX_STANDARD=23 -DPROXY_BUILD_MODULES=TRUE
cmake --build --preset coverage -j
ctest --preset coverage -j

- name: Build and run freestanding tests with code coverage instrumentation

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we count coverage of freestanding separately?

run: |
cmake --preset coverage-freestanding -DCMAKE_CXX_STANDARD=23 -DPROXY_BUILD_MODULES=TRUE
cmake --build --preset coverage-freestanding -j
ctest --preset coverage-freestanding -j

- name: Generate code coverage report
run: |
mkdir -p build/coverage/report
gcovr --root . \
--filter 'include/proxy/' \
--gcov-executable gcov \
--exclude-unreachable-branches \
--print-summary \
--txt build/coverage/report/coverage.txt \
--xml-pretty --output build/coverage/report/coverage.xml \
--html-details build/coverage/report/coverage.html \
build/coverage build/coverage-freestanding \
| tee build/coverage/report/summary.txt

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reviewed the generated coverage.function.html, looks like most "uncovered" functions are just template instantiations from unit tests/doc examples/benchmarks. The more instantiations there are, the less function coverage there will be. I think we should turn off function coverage if possible - it's meaningless for a template library.


- name: Publish coverage summary
run: |
{
echo "## Code coverage"
echo '```'
cat build/coverage/report/summary.txt
echo '```'
} >> "$GITHUB_STEP_SUMMARY"

- name: Upload code coverage report

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we use GitHub integration actions/upload-code-coverage?

uses: actions/upload-artifact@v7
with:
name: coverage-report
path: build/coverage/report/
5 changes: 5 additions & 0 deletions .github/workflows/pipeline-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ jobs:
name: Run BVT for compatibility
if: github.event_name != 'push' || github.repository == 'ngcpp/proxy'

run-bvt-codecoverage:
uses: ./.github/workflows/bvt-codecoverage.yml
name: Run BVT for code coverage
if: github.event_name != 'push' || github.repository == 'ngcpp/proxy'

report:
uses: ./.github/workflows/bvt-report.yml
name: Generate report
Expand Down
42 changes: 42 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,26 @@
"cacheVariables": {
"PROXY_FREESTANDING": "ON"
}
},
{
"name": "coverage",
"displayName": "Code coverage build",
"inherits": "default",
"binaryDir": "${sourceDir}/build/coverage",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_CXX_FLAGS": "--coverage -O0 -g",
"CMAKE_EXE_LINKER_FLAGS": "--coverage"
}
},
{
"name": "coverage-freestanding",
"displayName": "Code coverage freestanding build",
"inherits": "coverage",
"binaryDir": "${sourceDir}/build/coverage-freestanding",
"cacheVariables": {
"PROXY_FREESTANDING": "ON"
}
}
],
"buildPresets": [
Expand All @@ -34,6 +54,14 @@
{
"name": "freestanding",
"configurePreset": "freestanding"
},
{
"name": "coverage",
"configurePreset": "coverage"
},
{
"name": "coverage-freestanding",
"configurePreset": "coverage-freestanding"
}
],
"testPresets": [
Expand All @@ -50,6 +78,20 @@
"output": {
"outputOnFailure": true
}
},
{
"name": "coverage",
"configurePreset": "coverage",
"output": {
"outputOnFailure": true
}
},
{
"name": "coverage-freestanding",
"configurePreset": "coverage-freestanding",
"output": {
"outputOnFailure": true
}
}
]
}
Loading