Skip to content

Commit

Permalink
Add coverage workflow (#120)
Browse files Browse the repository at this point in the history
* update coverage commands

* add coverage workflow

* install aqnwb dependencies

* update lcov arguments
  • Loading branch information
stephprince authored Jan 8, 2025
1 parent 4d15cdc commit a532ec5
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 2 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Coverage

on:
push:
branches:
- main

pull_request:
branches:
- main
workflow_dispatch:

jobs:
coverage:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install LCov and dependencies
run: |
sudo apt-get update -q
sudo apt-get install -q -y lcov libhdf5-dev libboost-all-dev
git clone https://github.com/catchorg/Catch2.git
cd Catch2
git checkout "v3.5.3"
cmake -Bbuild -H. -DBUILD_TESTING=OFF
sudo cmake --build build/ --target install
- name: Configure
run: cmake --preset=ci-coverage

- name: Build
run: cmake --build build/coverage -j 2

- name: Test
working-directory: build/coverage
run: ctest --output-on-failure --no-tests=error -j 2

- name: Process coverage info
run: cmake --build build/coverage -t coverage

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
file: build/coverage/coverage.info
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
13 changes: 13 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,19 @@
"CMAKE_SHARED_LINKER_FLAGS_COVERAGE": "--coverage"
}
},
{
"name": "coverage-darwin",
"binaryDir": "${sourceDir}/build/coverage",
"inherits": "ci-darwin",
"hidden": true,
"cacheVariables": {
"ENABLE_COVERAGE": "ON",
"CMAKE_BUILD_TYPE": "Coverage",
"CMAKE_CXX_FLAGS_COVERAGE": "-Og -g --coverage",
"CMAKE_EXE_LINKER_FLAGS_COVERAGE": "--coverage",
"CMAKE_SHARED_LINKER_FLAGS_COVERAGE": "--coverage"
}
},
{
"name": "ci-coverage",
"inherits": ["coverage-linux", "dev-mode"],
Expand Down
4 changes: 2 additions & 2 deletions cmake/coverage.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ set(
lcov -c -q
-o "${PROJECT_BINARY_DIR}/coverage.info"
-d "${PROJECT_BINARY_DIR}"
--include "${PROJECT_SOURCE_DIR}/*"
--include "${PROJECT_SOURCE_DIR}/src/*"
CACHE STRING
"; separated command to generate a trace for the 'coverage' target"
)

set(
COVERAGE_HTML_COMMAND
genhtml --legend -f -q
genhtml --legend -q
"${PROJECT_BINARY_DIR}/coverage.info"
-p "${PROJECT_SOURCE_DIR}"
-o "${PROJECT_BINARY_DIR}/coverage_html"
Expand Down

0 comments on commit a532ec5

Please sign in to comment.