Skip to content

Commit 3e79da9

Browse files
ci: fix code coverage (#25)
1 parent 8fa9d69 commit 3e79da9

File tree

4 files changed

+20
-14
lines changed

4 files changed

+20
-14
lines changed

.github/workflows/ci.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,18 +160,21 @@ jobs:
160160
${{ steps.python-path.outputs.python-path }} -m pip install gcovr
161161
${{ steps.python-path.outputs.python-path }} -m gcovr -r .. \
162162
--exclude '.*tests/.*' \
163-
--exclude '.*tests/.*' \
163+
--exclude '.*third-party/.*' \
164164
--xml-pretty \
165165
-o coverage.xml
166166
167167
- name: Upload coverage
168168
# any except canceled or skipped
169169
if: >-
170-
always() && (steps.test_report.outcome == 'success') &&
170+
always() &&
171+
(steps.test_report.outcome == 'success') &&
171172
startsWith(github.repository, 'LizardByte/')
172173
uses: codecov/codecov-action@v4
173174
with:
175+
disable_search: true
174176
fail_ci_if_error: true
175177
files: ./build/coverage.xml
176178
flags: ${{ runner.os }}
177179
token: ${{ secrets.CODECOV_TOKEN }}
180+
verbose: true

CMakeLists.txt

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,23 @@ list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
2323
#
2424
option(BUILD_TESTS "Build tests" ON)
2525

26-
#
27-
# Library code is located here
28-
#
29-
add_subdirectory(src)
30-
3126
#
3227
# Testing only available if this is the main project
3328
#
3429
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTS)
30+
#
31+
# Additional setup for coverage
32+
# https://gcovr.com/en/stable/guide/compiling.html#compiler-options
33+
#
34+
set(CMAKE_CXX_FLAGS "-fprofile-arcs -ftest-coverage -O0")
35+
set(CMAKE_C_FLAGS "-fprofile-arcs -ftest-coverage -O0")
36+
3537
enable_testing()
3638
add_subdirectory(tests)
3739
endif()
40+
41+
#
42+
# Library code is located here
43+
# When building tests this must be after the coverage flags are set
44+
#
45+
add_subdirectory(src)

codecov.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
---
22
codecov:
33
branch: master
4+
notify:
5+
after_n_builds: 3
46

57
coverage:
68
status:

tests/CMakeLists.txt

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,3 @@ target_link_libraries(${TEST_BINARY}
5656

5757
# Add the test to CTest
5858
gtest_discover_tests(${TEST_BINARY})
59-
60-
#
61-
# Additional setup for coverage
62-
# https://gcovr.com/en/stable/guide/compiling.html#compiler-options
63-
#
64-
set(CMAKE_CXX_FLAGS "-fprofile-arcs -ftest-coverage -O1")
65-
set(CMAKE_C_FLAGS "-fprofile-arcs -ftest-coverage -O1")

0 commit comments

Comments
 (0)