Skip to content

Commit c283063

Browse files
committed
build: split unit vs. aggregate coverage gates in Codecov
Summary - Splits the single Codecov upload into two flagged reports: unittests (per-module unit coverage from xrpl4j-core/xrpl4j-client, gates PRs) and aggregate (unit + IT coverage via the xrpl4j-coverage module, informational only) — so integration tests can't mask real unit-test gaps. - Adds named codecov.yml status checks (unittests-gate for both project/patch, aggregate-visibility informational-only) with disable_search: true on both upload steps so neither can fall back to auto-discovering unintended XML files. - Feeds ConfidentialTransfersIT coverage into the aggregate from the linux x86-64 leg of build_confidential_native_its (the one deterministic native/local-rippled leg), which previously uploaded no coverage at all. - Drops xrpl4j-mpt-crypto from the unit upload — it ships no Java sources (only downloaded native resources), so referencing its nonexistent jacoco.xml with fail_ci_if_error: true would have broken CI on merge. Signed-off-by: David Fuelling <sappenin@gmail.com>
1 parent 05f3783 commit c283063

2 files changed

Lines changed: 116 additions & 1 deletion

File tree

.github/workflows/workflow.yml

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,24 @@ jobs:
8383
token: ${{ secrets.GITLAB_REGISTRY_TOKEN }}
8484
- name: Build
8585
run: mvn clean install
86-
- name: Upload to Codecov
86+
- name: Upload unit coverage to Codecov
8787
uses: codecov/codecov-action@v5
8888
with:
8989
token: ${{ secrets.CODECOV_TOKEN }}
90+
files: >-
91+
xrpl4j-core/target/site/jacoco/jacoco.xml,
92+
xrpl4j-client/target/site/jacoco/jacoco.xml
93+
flags: unittests
94+
disable_search: true
9095
fail_ci_if_error: true
96+
- name: Upload aggregate coverage to Codecov
97+
uses: codecov/codecov-action@v5
98+
with:
99+
token: ${{ secrets.CODECOV_TOKEN }}
100+
files: xrpl4j-coverage/target/site/jacoco-aggregate/jacoco.xml
101+
flags: aggregate
102+
disable_search: true
103+
fail_ci_if_error: false
91104

92105
build_jdk_semeru_8:
93106
needs: resolve_xrpld_image
@@ -301,6 +314,21 @@ jobs:
301314
run: mvn clean install -DskipITs -Dmaven.javadoc.skip=true
302315
- name: Run ConfidentialTransfersIT
303316
run: mvn -pl xrpl4j-integration-tests verify -Dit.test=ConfidentialTransfersIT ${{ matrix.it_flags }} -Dmaven.javadoc.skip=true
317+
# Only the linux-x86-64 leg (real native library against a local rippled Testcontainer, the most
318+
# deterministic environment) feeds the aggregate report - the other legs exist for cross-platform native
319+
# compatibility, not to generate additional coverage data.
320+
- name: Build aggregate coverage report including ConfidentialTransfersIT
321+
if: matrix.platform == 'linux-x86-64'
322+
run: mvn -pl xrpl4j-coverage -am verify -DskipTests -DskipITs -Dmaven.javadoc.skip=true
323+
- name: Upload confidential-mpt aggregate coverage to Codecov
324+
if: matrix.platform == 'linux-x86-64'
325+
uses: codecov/codecov-action@v5
326+
with:
327+
token: ${{ secrets.CODECOV_TOKEN }}
328+
files: xrpl4j-coverage/target/site/jacoco-aggregate/jacoco.xml
329+
flags: aggregate
330+
disable_search: true
331+
fail_ci_if_error: false
304332

305333
build_devnet_its:
306334
runs-on: ubuntu-latest

codecov.yml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,89 @@
1+
# --- What this file does ---------------------------------------------------------------------------------------
2+
# JaCoCo is the Java tool that instruments test runs and records which lines of code actually executed ("exec
3+
# data"). Maven produces jacoco XML reports per module, and this project also has an `xrpl4j-coverage` module
4+
# that merges (aggregates) exec data from unit tests AND integration tests (ITs) together into one combined
5+
# report.
6+
#
7+
# We upload TWO separate reports to Codecov instead of one:
8+
# 1. "unittests" - only the per-module unit-test reports (xrpl4j-core, xrpl4j-client). This is what actually
9+
# gates PRs. (xrpl4j-mpt-crypto ships no Java sources of its own - it only bundles downloaded native
10+
# tarballs as resources - so it has nothing for JaCoCo to instrument and is excluded here.)
11+
# 2. "aggregate" - the combined unit+IT report from xrpl4j-coverage. Informational only. Lets us see the
12+
# fuller picture without letting IT coverage (which can look high without meaningfully unit-testing
13+
# anything) count toward the merge-blocking number.
14+
# ---------------------------------------------------------------------------------------------------------------
15+
16+
coverage:
17+
status:
18+
# "project" status = coverage of the whole codebase (as opposed to "patch" status below, which only looks
19+
# at lines changed in a PR).
20+
project:
21+
unittests-gate:
22+
# Only reads uploads tagged with the `unittests` flag (see `flags:` below) - so IT-derived hits never
23+
# factor into this number.
24+
flags:
25+
- unittests
26+
# `target: auto` = don't require a fixed percentage; just don't let coverage drop below what the base
27+
# branch already has.
28+
target: auto
29+
# Allow up to a 1% drop before failing - avoids false failures from noise/rounding on small PRs.
30+
threshold: 1%
31+
# THIS is the one that should be set as a required GitHub status check in branch protection. It's the
32+
# actual quality gate.
33+
34+
aggregate-visibility:
35+
# Reads the combined unit+IT report instead.
36+
flags:
37+
- aggregate
38+
target: auto
39+
# `informational: true` means this check always shows as passing/visible on the PR, but can never block
40+
# a merge - it's there so reviewers can see "here's what IT coverage adds on top of unit coverage,"
41+
# without that number having any teeth.
42+
informational: true
43+
44+
# "patch" status = coverage of only the NEW/changed lines in a PR. This is what usually catches "you added
45+
# a function with no test."
46+
patch:
47+
unittests-gate:
48+
flags:
49+
- unittests
50+
target: auto
51+
# No aggregate-visibility patch check on purpose: patch coverage is exactly the "did you unit test what
52+
# you just wrote" question, which is the one place blending in IT coverage would be most likely to mask
53+
# a real gap.
54+
55+
# Flags are labels attached to a coverage upload (set in the GitHub Actions workflow via `flags: unittests` /
56+
# `flags: aggregate` on the codecov-action step). They're what let the `status:` checks above tell the two
57+
# reports apart, even though both cover the same source files.
58+
#
59+
# NOTE: `paths:` below are identical for both flags on purpose - this is NOT a copy-paste mistake. A flag's
60+
# `paths:` is a real filter on which files get attributed to it, but here both lists cover every module either
61+
# report could ever contain, so neither one actually excludes anything. The unit-vs-aggregate split happens
62+
# entirely in workflow.yml, via which jacoco.xml file each codecov-action step's `files:` argument points at
63+
# (per-module unit reports vs. the xrpl4j-coverage aggregate report).
64+
flags:
65+
unittests:
66+
paths:
67+
- xrpl4j-core/
68+
- xrpl4j-client/
69+
# `carryforward: false` = don't reuse a previous commit's coverage data if this flag doesn't get a fresh
70+
# upload on some commit. We always upload fresh on every build, so there's nothing to carry forward.
71+
carryforward: false
72+
73+
aggregate:
74+
paths:
75+
- xrpl4j-core/
76+
- xrpl4j-client/
77+
carryforward: false
78+
79+
# Controls the PR comment Codecov posts: show the per-flag breakdown, the diff coverage, and a file-by-file
80+
# table.
81+
comment:
82+
layout: "flags, diff, files"
83+
require_changes: false
84+
85+
# Rewrites absolute CI build paths (e.g. /home/runner/work/xrpl4j/xrpl4j/...) down to paths relative to the
86+
# repo root, so Codecov can match reported files to the actual repo structure. Unrelated to the unit/aggregate
87+
# split above.
188
fixes:
289
- "/home/runner/work/xrpl4j/xrpl4j/::"

0 commit comments

Comments
 (0)