Skip to content

Commit 88b987b

Browse files
authored
[CI] Simplify coverage PR comment to a single linked line (#630)
1 parent 2fc5472 commit 88b987b

4 files changed

Lines changed: 10 additions & 33 deletions

File tree

.github/workflows/linux.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,10 +197,10 @@ jobs:
197197
with:
198198
script: |
199199
const fs = require('fs');
200-
let body = fs.readFileSync('coverage-comment.md', 'utf8');
200+
let body = fs.readFileSync('coverage-comment.md', 'utf8').trim();
201201
const url = process.env.REPORT_URL;
202202
if (url) {
203-
body += `\n\n[Full annotated report](${url})`;
203+
body = `[${body}](${url})`;
204204
}
205205
await github.rest.issues.createComment({
206206
owner: context.repo.owner,

docs/source/user_guide/contributing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ You can run these locally with `pre-commit run -a` after `pip install pre-commit
126126
- **check-markup-links** (`check_markup_links.yml`) — validates links in documentation
127127
- **linux / macosx / win** — build and test on each platform
128128
- **test-gpu** — GPU-specific tests
129-
- **coverage report** — a diff coverage summary is posted as a PR comment on each push, with a link to the full annotated report. This includes kernel-level branch coverage. See [Kernel code coverage](kernel_coverage.md) for details.
129+
- **coverage report** — a one-line diff coverage summary is posted as a PR comment on each push, linking to the full annotated report. This includes kernel-level branch coverage. See [Kernel code coverage](kernel_coverage.md) for details.
130130

131131
### Line wrapping check (`check_wrapping.yml`)
132132

docs/source/user_guide/kernel_coverage.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,6 @@ One edge case: kernel calls inside a `qd.ad.Tape` with `validation=True` will no
9292

9393
Coverage probes change the compiled kernel, so the offline cache will see them as new kernels and recompile. This is expected and does not affect correctness, but the first run with coverage enabled will be slower if you normally rely on cached kernels.
9494

95-
## CI integration
96-
97-
The CI workflow posts a compact coverage summary as a PR comment on each push, showing per-file coverage percentages and missing line ranges. The full annotated report (with per-line hit/miss markers) is published as a GitHub Check — the PR comment includes a link to it. A **new comment** is created each time (rather than editing the previous one) so that the PR timeline shows a clear chronological sequence of commits and their corresponding coverage results.
98-
99-
The report covers only Python files (`.py`) and only lines added or modified in the PR diff — unchanged lines are not reported. C++ files are not included in the coverage report.
100-
10195
## Under the hood
10296

10397
When `QD_KERNEL_COVERAGE=1` is set, quadrants rewrites the Python AST of each `@qd.kernel` and `@qd.func` before compilation. It inserts lightweight probe statements (`field[probe_id] = 1`) at each source line. These probes compile as ordinary field stores and execute on the device alongside your kernel code.

tests/coverage_report.py

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -186,41 +186,24 @@ def output(self):
186186

187187

188188
class _MarkdownSummaryRenderer(_Renderer):
189-
"""Compact markdown summary (for PR comment, under 65K limit)."""
189+
"""One-line summary for the PR comment (turned into a link by the workflow)."""
190190

191191
def __init__(self):
192-
self._buf = []
193-
194-
def _print(self, text=""):
195-
self._buf.append(text)
192+
self._total_hit = self._total_miss = 0
193+
self._total_pct = 0.0
196194

197195
def begin(self, total_hit, total_miss, total_pct):
198196
self._total_hit, self._total_miss, self._total_pct = total_hit, total_miss, total_pct
199-
self._files: list[tuple[str, float, list[int]]] = []
200-
commit = _get_commit_hash()
201-
heading = f"## Coverage Report (`{commit}`)\n" if commit else "## Coverage Report\n"
202-
self._print(heading)
203197

204198
def begin_file(self, filename, pct, missing):
205-
self._files.append((filename, pct, missing))
199+
pass
206200

207201
def finish(self):
208-
overall = _get_overall_coverage()
209-
self._print("| File | Coverage | Missing |")
210-
self._print("|------|----------|---------|")
211-
for filename, pct, missing in self._files:
212-
icon = "🟢" if pct >= 80 else "🔴"
213-
missing_str = _format_ranges(missing) if missing else ""
214-
self._print(f"| {icon} `{filename}` | {pct:.0f}% | {missing_str} |")
215-
self._print()
216-
parts = [f"**Diff coverage: {self._total_pct:.0f}%**"]
217-
if overall:
218-
parts.append(f"Overall: {overall}")
219-
parts.append(f"{self._total_hit + self._total_miss} lines, {self._total_miss} missing")
220-
self._print(" · ".join(parts))
202+
pass
221203

222204
def output(self):
223-
return "\n".join(self._buf)
205+
total = self._total_hit + self._total_miss
206+
return f"Diff coverage: {self._total_pct:.0f}% · {total} lines, {self._total_miss} missing"
224207

225208

226209
_HTML_CSS = """\

0 commit comments

Comments
 (0)