Skip to content

Commit d304f9c

Browse files
Broneksophiax851
authored andcommitted
chore: Improve codecov coverage reporting (XRPLF#4977)
* Amend `.codecov.yml` to disable coverage reporting of test sources and explicitly set most parameters * Increase codecov upload retry time to 210s (from 35s) * Upgrade gcovr adding support for more coverage formats (lcov, clover, jacoco) * Upgrade github actions in coverage workflow * Explicitly disable codecov plugins (also removing `gcov` coverage, which is not correctly handled by codecov codecov/feedback#334)
1 parent ea278da commit d304f9c

File tree

3 files changed

+56
-8
lines changed

3 files changed

+56
-8
lines changed

.codecov.yml

+31
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,37 @@
1+
codecov:
2+
require_ci_to_pass: true
3+
4+
comment:
5+
behavior: default
6+
layout: reach,diff,flags,tree,reach
7+
show_carryforward_flags: false
8+
19
coverage:
10+
range: "60..80"
11+
precision: 1
12+
round: nearest
213
status:
314
project:
415
default:
516
target: 60%
617
threshold: 2%
18+
patch:
19+
default:
20+
target: auto
21+
threshold: 2%
22+
changes: false
23+
24+
github_checks:
25+
annotations: true
26+
27+
parsers:
28+
cobertura:
29+
partials_as_hits: true
30+
handle_missing_conditions : true
31+
32+
slack_app: false
33+
34+
ignore:
35+
- "src/test/"
36+
- "src/ripple/beast/test/"
37+
- "src/ripple/beast/unit_test/"

.github/workflows/nix.yml

+8-4
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,8 @@ jobs:
179179
run: |
180180
mkdir -p ~/.conan
181181
tar -xzf conan.tar -C ~/.conan
182+
- name: install gcovr
183+
run: pip install "gcovr>=7,<8"
182184
- name: check environment
183185
run: |
184186
echo ${PATH} | tr ':' '\n'
@@ -207,7 +209,7 @@ jobs:
207209
-DCMAKE_CXX_FLAGS="-O0"
208210
-DCMAKE_C_FLAGS="-O0"
209211
cmake-target: coverage
210-
- name: build
212+
- name: move coverage report
211213
shell: bash
212214
run: |
213215
mv "${build_dir}/coverage.xml" ./
@@ -218,13 +220,15 @@ jobs:
218220
path: coverage.xml
219221
retention-days: 30
220222
- name: upload coverage report
221-
uses: wandalen/wretry.action@v1.3.0
223+
uses: wandalen/wretry.action@v1.4.10
222224
with:
223-
action: codecov/codecov-action@v4
225+
action: codecov/codecov-action@v4.3.0
224226
with: |
225227
files: coverage.xml
226228
fail_ci_if_error: true
229+
disable_search: true
227230
verbose: true
231+
plugin: noop
228232
token: ${{ secrets.CODECOV_TOKEN }}
229233
attempt_limit: 5
230-
attempt_delay: 35000 # in milliseconds
234+
attempt_delay: 210000 # in milliseconds

Builds/CMake/CodeCoverage.cmake

+17-4
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@
9595
# - replace both functions setup_target_for_coverage_gcovr_* with a single setup_target_for_coverage_gcovr
9696
# - add support for all gcovr output formats
9797
#
98+
# 2024-04-03, Bronek Kozicki
99+
# - add support for output formats: jacoco, clover, lcov
100+
#
98101
# USAGE:
99102
#
100103
# 1. Copy this file into your cmake modules path.
@@ -256,10 +259,10 @@ endif()
256259
# BASE_DIRECTORY "../" # Base directory for report
257260
# # (defaults to PROJECT_SOURCE_DIR)
258261
# FORMAT "cobertura" # Output format, one of:
259-
# # xml cobertura sonarqube json-summary
260-
# # json-details coveralls csv txt
261-
# # html-single html-nested html-details
262-
# # (xml is an alias to cobertura;
262+
# # xml cobertura sonarqube jacoco clover
263+
# # json-summary json-details coveralls csv
264+
# # txt html-single html-nested html-details
265+
# # lcov (xml is an alias to cobertura;
263266
# # if no format is set, defaults to xml)
264267
# EXCLUDE "src/dir1/*" "src/dir2/*" # Patterns to exclude (can be relative
265268
# # to BASE_DIRECTORY, with CMake 3.4+)
@@ -308,6 +311,8 @@ function(setup_target_for_coverage_gcovr)
308311
set(GCOVR_OUTPUT_FILE ${Coverage_NAME}.txt)
309312
elseif(Coverage_FORMAT STREQUAL "csv")
310313
set(GCOVR_OUTPUT_FILE ${Coverage_NAME}.csv)
314+
elseif(Coverage_FORMAT STREQUAL "lcov")
315+
set(GCOVR_OUTPUT_FILE ${Coverage_NAME}.lcov)
311316
else()
312317
set(GCOVR_OUTPUT_FILE ${Coverage_NAME}.xml)
313318
endif()
@@ -320,6 +325,14 @@ function(setup_target_for_coverage_gcovr)
320325
set(Coverage_FORMAT cobertura) # overwrite xml
321326
elseif(Coverage_FORMAT STREQUAL "sonarqube")
322327
list(APPEND GCOVR_ADDITIONAL_ARGS --sonarqube "${GCOVR_OUTPUT_FILE}" )
328+
elseif(Coverage_FORMAT STREQUAL "jacoco")
329+
list(APPEND GCOVR_ADDITIONAL_ARGS --jacoco "${GCOVR_OUTPUT_FILE}" )
330+
list(APPEND GCOVR_ADDITIONAL_ARGS --jacoco-pretty )
331+
elseif(Coverage_FORMAT STREQUAL "clover")
332+
list(APPEND GCOVR_ADDITIONAL_ARGS --clover "${GCOVR_OUTPUT_FILE}" )
333+
list(APPEND GCOVR_ADDITIONAL_ARGS --clover-pretty )
334+
elseif(Coverage_FORMAT STREQUAL "lcov")
335+
list(APPEND GCOVR_ADDITIONAL_ARGS --lcov "${GCOVR_OUTPUT_FILE}" )
323336
elseif(Coverage_FORMAT STREQUAL "json-summary")
324337
list(APPEND GCOVR_ADDITIONAL_ARGS --json-summary "${GCOVR_OUTPUT_FILE}" )
325338
list(APPEND GCOVR_ADDITIONAL_ARGS --json-summary-pretty)

0 commit comments

Comments
 (0)