Skip to content

CI: publish diff and overall coverage numbers into the pull request description - #336

Merged
ccozianu merged 4 commits into
mainfrom
ws-maintenance/coverage-in-pr
Nov 4, 2026
Merged

ccozianu merged 4 commits into
mainfrom
ws-maintenance/coverage-in-pr

Conversation

@ccozianu

@ccozianu ccozianu commented Nov 4, 2026 •

Copy link
Copy Markdown
Owner

Owner order of 2026-11-04, maintenance workstream, following #335.

What changes

scripts/publish_coverage_numbers_to_pr.py runs in the pytest job on pull requests, after diff coverage. It reads coverage.json and diff-cover.json, renders one block bounded by two HTML comment markers with the changed-lines figure and the whole-package figure, and replaces that block in this description through the REST API, appending it when absent. Text outside the block is never touched. The pytest job gains pull-requests: write for that one step. coverage.json joins the coverage artifact.

The merge commit half

No code. Under Settings, Pull Requests, set the default merge commit message to "Pull request title and description". The block then lands in the merge commit's detail as the description stands at merge time, which is after the green run that wrote it. Until the setting is flipped, the numbers live in the pull request only.

What the first run taught

The first run on this PR spliced the block into the paragraph above, because that paragraph quoted the two markers literally and the upsert matched them mid-sentence. The markers are now matched only when each stands alone on its line, with a test for markers quoted in prose. The same run reported "100% of 0 changed lines", because this PR touches no line of the devcapsule package; that case now reads "none measured" instead of a percentage.

Evidence

  • Eleven mirror tests in tests/unit/scripts/test_publish_coverage_numbers_to_pr.py, triple form: the figures, the block in both cases, the upsert in its four cases, the step with a recorded API, the refusals.
  • mypy clean; validate_unittests_follow_conventions.py: 110 legacy files, 1524 tests, 3 files follow the convention, 0 breaches.
  • The proof is this pull request: its run appends the block below this line.

🤖 Generated with Claude Code

Test coverage, from CI run

Changed lines covered none measured: the change touches no line of devcapsule
Overall devcapsule 88.1% (17,583 of 19,488 statements)

ccozianu and others added 4 commits November 4, 2026 00:04
Add scripts/publish_coverage_numbers_to_pr.py: after the tests and
diff-cover steps on a pull request, read coverage.json and diff-cover.json,
render one block between marker comments with the changed-lines figure and
the whole-package figure, and replace that block in the pull request's
description through the REST API, appending it when absent. The author's
text outside the block is never touched. The pytest job gains
pull-requests: write for that step; coverage.json joins the artifact. Nine
mirror tests in triple form; mypy clean; the conventions check reports 0
breaches. The merge-commit half is a repository setting the owner flips:
default merge message from the pull request's title and description.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…changed line is measured

The first run on #336 spliced the block into the description's prose, which
quoted the markers literally; a block is now matched only where each marker
stands alone on its line, with a test for markers quoted in prose. The same
run reported 100% of 0 changed lines on a change outside the devcapsule
package; that case now reads "none measured". 13 mirror tests pass; mypy
clean; the conventions check reports 0 breaches.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The owner set the merge commit's title and message to the pull request's
title and description on 2026-11-04; verified through the repository API.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@ccozianu
ccozianu merged commit 445469f into main Nov 4, 2026
5 checks passed
@ccozianu
ccozianu deleted the ws-maintenance/coverage-in-pr branch November 4, 2026 00:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant