Show each scenario's totals in the coverage comment - #38
Merged
Conversation
The comment linked the artifact zips but said nothing about what was in them, so seeing whether a PR moved coverage meant downloading and unzipping four files. Inline each scenario's totals as a table, collapsed behind <details> so the comment stays short, with the artifact links kept underneath. The workflow still executes nothing from the PR: it downloads the coverage artifacts and JSON.parses them, which is data handling rather than code execution. Every value read out of that JSON is coerced to a finite, non-negative number before it reaches the comment, so a fork cannot inject markdown through a crafted coverage-summary.json. Also uploads the parallel scenario's coverage-parallel folder, which had no artifact of its own.
Contributor
Coverage reports
Each artifact is the scenario's From this CI run for 7dc5891. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note
Made with Claude Code. Apologies if I've stepped on how you wanted this to read — the layout is a guess, and the security reasoning below is the part most worth a second pair of eyes.
The comment linked the artifact zips but said nothing about what was in them, so seeing whether a PR moved coverage meant downloading and unzipping up to four files. This inlines each scenario's totals, collapsed behind
<details>so the comment stays short, with the artifact table kept underneath.Rendered from real scenario output:
v2-addon-js
█████████████████░░░█████████████████░░░████████████░░░░░░░░████████████████████vite-app-js
███████████████████░███████████████████░█████████████░░░░░░░█████████████░░░░░░░The security bit
The header comment on this workflow makes a specific promise —
workflow_runhands it a write-capable token, and that's only safe because it "executes no code from the PR — no checkout, only GitHub API calls". Reading the numbers means touching PR-produced data, so I wanted to be careful not to quietly weaken that.What it now does: downloads the coverage artifacts (
actions/download-artifactwithrun-id, so still no checkout) andJSON.parses them. That's data handling, not code execution — nothing from the PR is installed, built, or run.The parsed JSON is still untrusted, so only numbers are taken out of it, each coerced through:
No string from
coverage-summary.jsonreaches the comment body — scenario names come from the artifact names, which CI controls. So a fork can't smuggle markdown, a link, or a-->through a crafted summary file. The bar is clamped to 0–20 characters too, so a wildpctcan't produce a giant row.I updated the header comment to say all this rather than leaving the old "only GitHub API calls" wording, which would no longer be strictly accurate.
Also
Adds an artifact for
coverage-parallel. The parallel scenario reuses thevite-app-jsapp but writes to its own folder, so it wasn't being uploaded at all — meaning the one scenario that exercises multi-browser merging had no downloadable report.Testing
I dry-ran the rendering against real
coverage-summary.jsonfiles from two scenarios (that's the output above). A scenario whose artifact has no summary — failed before writing one, or expired — falls through to just its zip link rather than erroring.oxlint+oxfmtclean; both workflow files parse.What I can't test locally is the
workflow_runtrigger itself, so the download step'srun-idwiring is only exercised once this is onmain.