diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 90f57ad..c8ab04a 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -13,10 +13,11 @@ jobs: config: - name: Ubuntu Latest (GCC) os: ubuntu-latest - build_type: Release + build_type: Debug test_path: CommonTest cc: gcc cxx: g++ + code_coverage: true - name: macOS Latest (Clang) os: macos-latest @@ -41,10 +42,22 @@ jobs: run: mkdir build - name: Configure - run: cd build && cmake .. -DCMAKE_BUILD_TYPE=${{ matrix.config.build_type }} + working-directory: ./build + run: cmake .. -DCMAKE_BUILD_TYPE=${{ matrix.config.build_type }} -DCODE_COVERAGE=${{ matrix.config.code_coverage && 'ON' || 'OFF' }} - name: Build - run: cmake --build build --config ${{ matrix.config.build_type }} + working-directory: ./build + run: cmake --build . --config ${{ matrix.config.build_type }} - name: Test - run: ./build/test/${{ matrix.config.test_path }} + working-directory: ./build + run: ./test/${{ matrix.config.test_path }} + + - name: Upload coverage + uses: codecov/codecov-action@v3 + if: ${{ matrix.config.code_coverage }} + with: + verbose: true + gcov: true + gcov_ignore: + /usr/include* diff --git a/CMakeLists.txt b/CMakeLists.txt index 6e59554..f872a80 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,6 +20,8 @@ set(CMAKE_CXX_STANDARD 11) include(lib/system/cmake/system.cmake) +option(CODE_COVERAGE "Enable code coverage instrumentation" OFF) + add_subdirectory(lib) add_subdirectory(common) add_subdirectory(test) diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 6a50605..052449c 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -25,3 +25,8 @@ target_link_libraries(common storm tempest ) + +if(CODE_COVERAGE) + target_compile_options(common PRIVATE --coverage) + target_link_options(common PUBLIC --coverage) +endif()