This is an automated email from the ASF dual-hosted git repository.
HyukjinKwon pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark-connect-rust.git
The following commit(s) were added to refs/heads/master by this push:
new 2dc53a8 [MINOR][INFRA] Fix Rust coverage badge stuck at 0.0% (wrong
llvm-cov JSON key)
2dc53a8 is described below
commit 2dc53a8defbda8393a837176cacd9992e08c55cb
Author: Hyukjin Kwon <[email protected]>
AuthorDate: Thu Aug 27 10:05:57 2026 +0900
[MINOR][INFRA] Fix Rust coverage badge stuck at 0.0% (wrong llvm-cov JSON
key)
### What changes were proposed in this pull request?
Fix the Rust coverage badge, which always showed `0.0%` (red) even though
the
crate is ~90% covered.
The badge parser read `data[0]["line_coverage_percent"]` from the
`cargo llvm-cov --json` output, but that key does not exist. The llvm
"export"
format puts the summary under `data[0]["totals"]["lines"]["percent"]` (and
`regions`/`functions`). The lookup missed, fell back to `0`, and published
`"0.0%"`. Read `totals.lines.percent` instead (falling back to regions then
functions).
### Why are the changes needed?
The published Rust coverage badge misreported real coverage as 0%. (The
Python
badge was unaffected - it already reads `totals.percent_covered`.)
### Does this PR introduce _any_ user-facing change?
No (CI badge only).
### How was this patch tested?
Verified against real `cargo llvm-cov --json` output locally: the parser now
yields the actual line-coverage percentage instead of 0.
This pull request and its description were written by Isaac.
Closes #61 from HyukjinKwon/fix-coverage-badges.
Authored-by: Hyukjin Kwon <[email protected]>
Signed-off-by: Hyukjin Kwon <[email protected]>
---
.github/workflows/coverage.yml | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml
index 1f847c7..9115b19 100644
--- a/.github/workflows/coverage.yml
+++ b/.github/workflows/coverage.yml
@@ -84,14 +84,19 @@ jobs:
with open("coverage-rust.json", "r") as f:
data = json.load(f)
- # Extract line coverage percentage (or region if line not available)
+ # cargo-llvm-cov emits the llvm "export" format: the summary lives
under
+ # data[0].totals.{lines,regions,functions}.percent. The previous
code read
+ # data[0].line_coverage_percent, a key that does not exist, so it
always fell
+ # back to 0 and the badge showed 0.0%. Use line coverage, falling
back to
+ # region then function coverage.
coverage_pct = None
- if "data" in data and len(data["data"]) > 0:
- coverage_obj = data["data"][0]
- if "line_coverage_percent" in coverage_obj:
- coverage_pct = coverage_obj["line_coverage_percent"]
- elif "region_coverage_percent" in coverage_obj:
- coverage_pct = coverage_obj["region_coverage_percent"]
+ if data.get("data"):
+ totals = data["data"][0].get("totals", {})
+ for key in ("lines", "regions", "functions"):
+ metric = totals.get(key)
+ if isinstance(metric, dict) and "percent" in metric:
+ coverage_pct = metric["percent"]
+ break
if coverage_pct is None:
coverage_pct = 0
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]