Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: fix code coverage #25

Merged
merged 1 commit into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
18 changes: 13 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 2 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
codecov:
branch: master
notify:
after_n_builds: 3

coverage:
status:
Expand Down
7 changes: 0 additions & 7 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")