Report changed coverage misses in workflow logs
Linux / verify (pull_request) Successful in 2m11s
Linux / changed-scope-coverage (pull_request) Skipped
Linux / keyless-cuda (pull_request) Skipped
Linux / hosted-cuda-package (pull_request) Skipped
Linux / linux-cli-container (pull_request) Successful in 17s
Linux / linux-static-cli (pull_request) Successful in 5m10s
Linux / release-cli (pull_request) Skipped
Linux / verify (pull_request) Successful in 2m11s
Linux / changed-scope-coverage (pull_request) Skipped
Linux / keyless-cuda (pull_request) Skipped
Linux / hosted-cuda-package (pull_request) Skipped
Linux / linux-cli-container (pull_request) Successful in 17s
Linux / linux-static-cli (pull_request) Successful in 5m10s
Linux / release-cli (pull_request) Skipped
This commit is contained in:
@@ -64,20 +64,6 @@ jobs:
|
||||
run: python3 scripts/test-changed-scope-coverage.py
|
||||
- name: Run exact changed-production coverage gate
|
||||
run: python3 scripts/check-changed-scope-coverage.py --root "$GITHUB_WORKSPACE" --output-dir "$RUNNER_TEMP/changed-scope-coverage"
|
||||
- name: Archive raw LCOV and machine-readable summary
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v4.4.3
|
||||
with:
|
||||
name: changed-scope-coverage-${{ github.run_id }}-${{ github.run_attempt }}
|
||||
path: |
|
||||
${{ runner.temp }}/changed-scope-coverage/coverage.raw.lcov
|
||||
${{ runner.temp }}/changed-scope-coverage/summary.json
|
||||
${{ runner.temp }}/changed-scope-coverage/summary.txt
|
||||
${{ runner.temp }}/changed-scope-coverage/cargo.stderr
|
||||
${{ runner.temp }}/changed-scope-coverage/llvm-cov.stderr
|
||||
${{ runner.temp }}/changed-scope-coverage/llvm-profdata.stderr
|
||||
if-no-files-found: warn
|
||||
retention-days: 14
|
||||
|
||||
keyless-cuda:
|
||||
if: github.event_name == 'workflow_dispatch' && github.event.inputs.keyless_gpu == 'true'
|
||||
|
||||
@@ -521,12 +521,46 @@ def _coverage_env(out: Path) -> dict:
|
||||
|
||||
def _write_summary(out: Path, report: dict) -> None:
|
||||
(out / "summary.json").write_text(json.dumps(report, indent=2, sort_keys=True) + "\n")
|
||||
rows = summary_lines(report)
|
||||
(out / "summary.txt").write_text("\n".join(rows) + "\n")
|
||||
|
||||
|
||||
def summary_lines(report: dict) -> list[str]:
|
||||
rows = [f"Changed-production coverage vs {report['baseline']}"]
|
||||
for kind, value in report.get("totals", {}).items():
|
||||
totals = report.get("totals", {})
|
||||
for kind in ("lines", "functions", "branches"):
|
||||
value = totals.get(kind, {})
|
||||
rows.append(f"{kind}: {value['hit']}/{value['total']} ({value.get('percent', 0.0):.2f}%)")
|
||||
rows.append(f"Gate: {'PASS' if report.get('passed') else 'FAIL'}")
|
||||
rows.append(f"Reason: {report.get('failure', 'all required gates passed')}")
|
||||
(out / "summary.txt").write_text("\n".join(rows) + "\n")
|
||||
if not report.get("passed"):
|
||||
rows.extend(_miss_inventory(totals))
|
||||
return rows
|
||||
|
||||
|
||||
def _miss_inventory(totals: dict) -> list[str]:
|
||||
rows = ["Miss inventory (file:line; deterministic order):"]
|
||||
for kind in ("lines", "functions", "branches"):
|
||||
misses = totals.get(kind, {}).get("misses", [])
|
||||
rows.append(f"{kind} misses: {len(misses)}")
|
||||
for miss in sorted(misses, key=_miss_sort_key):
|
||||
rows.append(f" {_format_miss(kind, miss)}")
|
||||
return rows
|
||||
|
||||
|
||||
def _miss_sort_key(miss: dict) -> tuple:
|
||||
return (miss.get("file", ""), miss.get("line", 0), miss.get("block", ""),
|
||||
miss.get("branch", ""), miss.get("name", ""), miss.get("taken", ""))
|
||||
|
||||
|
||||
def _format_miss(kind: str, miss: dict) -> str:
|
||||
location = f"{miss.get('file', '<unknown>')}:{miss.get('line', 0)}"
|
||||
if kind == "functions":
|
||||
return f"{location} {miss.get('name', '<unknown>')}"
|
||||
if kind == "branches":
|
||||
return (f"{location} block={miss.get('block', '<unknown>')} "
|
||||
f"branch={miss.get('branch', '<unknown>')} taken={miss.get('taken', '<unknown>')}")
|
||||
return location
|
||||
|
||||
|
||||
def _run_instrumented_tests(root: Path, out: Path, env: dict) -> tuple[int, Path, int]:
|
||||
|
||||
@@ -81,6 +81,25 @@ pub fn with_test_only_block() {
|
||||
report = COVERAGE.coverage_report(records, scopes)
|
||||
self.assertNotEqual(report["totals"]["branches"]["hit"], report["totals"]["branches"]["total"])
|
||||
|
||||
def test_failure_summary_prints_deterministic_complete_miss_inventory(self) -> None:
|
||||
report = {"baseline": "d3e63a7", "passed": False, "failure": "coverage below 100%",
|
||||
"totals": {"lines": {"hit": 0, "total": 1,
|
||||
"misses": [{"file": "b.rs", "line": 9},
|
||||
{"file": "a.rs", "line": 4}]},
|
||||
"functions": {"hit": 0, "total": 1,
|
||||
"misses": [{"file": "a.rs", "line": 7, "name": "f"}]},
|
||||
"branches": {"hit": 0, "total": 1,
|
||||
"misses": [{"file": "b.rs", "line": 9, "block": "1",
|
||||
"branch": "0", "taken": "-"}]}}}
|
||||
lines = COVERAGE.summary_lines(report)
|
||||
self.assertEqual(lines[6:9], ["Miss inventory (file:line; deterministic order):",
|
||||
"lines misses: 2", " a.rs:4"])
|
||||
self.assertIn(" a.rs:7 f", lines)
|
||||
self.assertIn(" b.rs:9 block=1 branch=0 taken=-", lines)
|
||||
self.assertEqual(lines, COVERAGE.summary_lines(report))
|
||||
self.assertFalse(any("a.rs:4" in line for line in COVERAGE.summary_lines(
|
||||
{**report, "passed": True})))
|
||||
|
||||
def test_cargo_json_selects_only_the_package_lib_test_executable(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
binary = Path(directory) / "strata_control-test"
|
||||
@@ -117,11 +136,8 @@ pub fn with_test_only_block() {
|
||||
self.assertIn("inputs.changed_scope_coverage", job)
|
||||
self.assertIn("nightly-2026-10-05", job)
|
||||
self.assertIn("scripts/check-changed-scope-coverage.py", job)
|
||||
self.assertIn("if: always()", job)
|
||||
self.assertIn("actions/upload-artifact@v4.4.3", job)
|
||||
self.assertIn("coverage.raw.lcov", job)
|
||||
self.assertIn("summary.json", job)
|
||||
self.assertIn("summary.txt", job)
|
||||
self.assertNotIn("actions/upload-artifact", job)
|
||||
self.assertNotIn("download-artifact", job)
|
||||
|
||||
|
||||
def _digest(value: str) -> str:
|
||||
|
||||
Reference in New Issue
Block a user