Skip to content

Commit

Permalink
Add coverage option and codecov CI
Browse files Browse the repository at this point in the history
Signed-off-by: Cristian Le <cristian.le@mpsd.mpg.de>
  • Loading branch information
LecrisUT committed Nov 7, 2023
1 parent 6c11914 commit 9e0e314
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/step_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ jobs:
uses: lukka/run-cmake@v10.3
with:
workflowPreset: "${{ matrix.toolchain }}-ci"
- name: Get lcov data
uses: danielealbano/lcov-action@v3
with:
remove_patterns: /test/,/cmake-build*/
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
files: coverage.info
pass:
needs: [ tests ]
runs-on: ubuntu-latest
Expand Down
4 changes: 4 additions & 0 deletions cmake/CMakePresets-CI.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
"TEMPLATE_TESTS": {
"type": "BOOL",
"value": true
},
"TEMPLATE_TEST_COVERAGE": {
"type": "BOOL",
"value": true
}
},
"errors": {
Expand Down
9 changes: 9 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,19 @@ set(CMAKE_CXX_EXTENSIONS ON)
# Options #
]==============================================================================================]

include(CMakeDependentOption)
cmake_dependent_option(TEMPLATE_TEST_COVERAGE "Template: Test with coverage" OFF "TEMPLATE_TESTS;Template_IS_TOP_LEVEL" OFF)
add_feature_info(Coverage TEMPLATE_TEST_COVERAGE "Compile with test coverage")
mark_as_advanced(TEMPLATE_TEST_COVERAGE)

#[==============================================================================================[
# Project configuration #
]==============================================================================================]

if (TEMPLATE_TEST_COVERAGE)
target_compile_options(Template_Template PRIVATE --coverage)
endif ()

#[==============================================================================================[
# External packages #
]==============================================================================================]
Expand Down

0 comments on commit 9e0e314

Please sign in to comment.