Repository navigation
Post PR coverage comments from a workflow_run workflow - #14
Merged
Merged
Conversation
Fork PRs run CI with a read-only GITHUB_TOKEN: GitHub caps the token for pull_request events from forks regardless of the permissions declared in the workflow, so the comment steps in the test job failed the job on every fork PR while the suite itself passed. The test job now uploads pytest-coverage.txt, junit.xml, and diff-cover-report.md as a coverage-report artifact instead of commenting. The new coverage-comment workflow triggers on CI completion, runs in the base repo's context with pull-requests: write, resolves the PR number from the API by head SHA, and posts the two sticky comments. It follows the same pattern as publish-pr.yml: it downloads report data only and never checks out or executes fork code. Each comment step is gated on its report file existing, since a failed run uploads only the files it produced.
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.
Fork PRs run CI with a read-only
GITHUB_TOKEN— GitHub caps the token forpull_requestevents from forks regardless of thepermissionsdeclared in the workflow. The coverage-comment steps in thetestjob therefore failed withResource not accessible by integrationon every fork PR, failing the job even when the suite passed (see #12, where all 1277 tests pass but the check is red).This splits coverage reporting in two, following the same pattern as
publish-pr.yml:testjob uploadspytest-coverage.txt,junit.xml, anddiff-cover-report.mdas acoverage-reportartifact instead of commenting. The upload still runs on a red suite, so the report explaining a failure is preserved; files the failure suppressed are simply absent. The job's now-ineffectivepull-requests: writegrant is dropped.coverage-commentworkflow triggers on CI completion and runs in the base repo's context withpull-requests: write. It resolves the PR number from the API by head SHA — never from anything the PR controls — downloads the report artifact, and posts the two sticky comments (issue-number/numberinputs, which both actions support forworkflow_runtriggers). It never checks out or executes fork code. Each comment step is gated on its report file existing.The comment now appears on fork and same-repo PRs alike, through a single code path. Note
workflow_runworkflows execute from the default branch, so the new workflow takes effect once this merges; open PRs then need a re-run to pick up the artifact-upload side.