From 88ce4fff68d0598cc0742dc600d6ac4b818807f0 Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Tue, 7 May 2024 15:57:33 -0400 Subject: [PATCH] ci: fix code coverage --- .github/workflows/ci.yml | 7 +++++-- CMakeLists.txt | 18 +++++++++++++----- codecov.yml | 2 ++ tests/CMakeLists.txt | 7 ------- 4 files changed, 20 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f44146b..f2431ea 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -160,18 +160,21 @@ jobs: ${{ steps.python-path.outputs.python-path }} -m pip install gcovr ${{ steps.python-path.outputs.python-path }} -m gcovr -r .. \ --exclude '.*tests/.*' \ - --exclude '.*tests/.*' \ + --exclude '.*third-party/.*' \ --xml-pretty \ -o coverage.xml - name: Upload coverage # any except canceled or skipped if: >- - always() && (steps.test_report.outcome == 'success') && + always() && + (steps.test_report.outcome == 'success') && startsWith(github.repository, 'LizardByte/') uses: codecov/codecov-action@v4 with: + disable_search: true fail_ci_if_error: true files: ./build/coverage.xml flags: ${{ runner.os }} token: ${{ secrets.CODECOV_TOKEN }} + verbose: true diff --git a/CMakeLists.txt b/CMakeLists.txt index 0153e62..f1bb2ad 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,15 +23,23 @@ list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) # option(BUILD_TESTS "Build tests" ON) -# -# Library code is located here -# -add_subdirectory(src) - # # Testing only available if this is the main project # if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTS) + # + # Additional setup for coverage + # https://gcovr.com/en/stable/guide/compiling.html#compiler-options + # + set(CMAKE_CXX_FLAGS "-fprofile-arcs -ftest-coverage -O0") + set(CMAKE_C_FLAGS "-fprofile-arcs -ftest-coverage -O0") + enable_testing() add_subdirectory(tests) endif() + +# +# Library code is located here +# When building tests this must be after the coverage flags are set +# +add_subdirectory(src) diff --git a/codecov.yml b/codecov.yml index e9c9c87..9f91776 100644 --- a/codecov.yml +++ b/codecov.yml @@ -1,6 +1,8 @@ --- codecov: branch: master + notify: + after_n_builds: 3 coverage: status: diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index e314595..06a0e9e 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -56,10 +56,3 @@ target_link_libraries(${TEST_BINARY} # Add the test to CTest gtest_discover_tests(${TEST_BINARY}) - -# -# Additional setup for coverage -# https://gcovr.com/en/stable/guide/compiling.html#compiler-options -# -set(CMAKE_CXX_FLAGS "-fprofile-arcs -ftest-coverage -O1") -set(CMAKE_C_FLAGS "-fprofile-arcs -ftest-coverage -O1")