-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
In order to find out that our code is properly tested, code coverage is a nice metric to find possible unwanted behavior. This metric alone has nothing to say about wether the unit tests are meaningful but they allow us to find out where we can do better.
- Loading branch information
Showing
6 changed files
with
93 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
name: Coverage | ||
|
||
on: | ||
# Triggers the workflow on push or pull request events but only for the "master" branch | ||
push: | ||
branches: | ||
- "master" | ||
- "develop" | ||
pull_request: | ||
branches: | ||
- "master" | ||
- "develop" | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: 🔧 Install GCC | ||
uses: egor-tensin/[email protected] | ||
with: | ||
version: 13 | ||
|
||
- name: 🔧 Setup python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.10' | ||
cache: pip | ||
|
||
- name: ☁️ Install required packages | ||
run: | | ||
sudo apt-get install -y lcov | ||
pip install -r requirements.txt | ||
- name: 🐸 Create default Conan profile | ||
run: conan profile detect | ||
|
||
- name: ☁️ Get dependencies | ||
run: conan install ${{ github.workspace }} --build=missing --output-folder=build --settings compiler.cppstd=20 | ||
|
||
- name: 🛠️ Configure CMake | ||
run: > | ||
cmake -B build | ||
-DCMAKE_BUILD_TYPE=Release | ||
-DBUILD_TESTING=ON | ||
-DCODE_COVERAGE=ON | ||
--toolchain=conan_toolchain.cmake | ||
-S ${{ github.workspace }} | ||
- name: 🔨 Build project | ||
run: cmake --build build --config Release --parallel | ||
|
||
- name: 🏃 Run test suite | ||
working-directory: build | ||
run: ctest --build-config Release | ||
|
||
- name: 📊 Generate coverage reports with lcov | ||
run: | | ||
lcov --directory . --capture --output-file coverage.info --gcov-tool gcov-13 | ||
lcov --remove coverage.info '/usr/*' --remove coverage.info '**/.conan*' --remove coverage.info '**/test*' --output-file coverage.info | ||
lcov --list coverage.info | ||
- name: ☂️ Upload coverage reports to Codecov | ||
uses: codecov/codecov-action@v3 | ||
env: | ||
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
cmake_minimum_required(VERSION 3.24) | ||
|
||
# Code coverage configuration | ||
add_library(coverage_config INTERFACE) | ||
if(CODE_COVERAGE AND CMAKE_CXX_COMPILER_ID MATCHES "GNU") | ||
message("Enabling code coverage") | ||
target_compile_options(coverage_config INTERFACE | ||
-O0 # no optimization | ||
-g # generate debug info | ||
--coverage # sets all required flags | ||
) | ||
target_link_options(coverage_config INTERFACE --coverage) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters