Skip to content

Don't mis-route nightly coverage comment to last-merged PR#849

Merged
mjp41 merged 1 commit intomicrosoft:mainfrom
mjp41:coverage-comment-fix-fallback
May 10, 2026
Merged

Don't mis-route nightly coverage comment to last-merged PR#849
mjp41 merged 1 commit intomicrosoft:mainfrom
mjp41:coverage-comment-fix-fallback

Conversation

@mjp41
Copy link
Copy Markdown
Member

@mjp41 mjp41 commented May 10, 2026

The SHA-based fallback added in #847 (resolve PR by head SHA when workflow_run.pull_requests[] is empty) handles fork PRs correctly, but it also fires for schedule and push runs on main. The nightly's head SHA is the merge commit of whichever PR last landed, and listPullRequestsAssociatedWithCommit returns that PR — so the nightly coverage report ended up posted as a comment on the just- merged (now closed) PR instead of on the tracking issue.

Two changes, both narrowing the fallback:

  1. Only run the SHA fallback when workflow_run.event === 'pull_request'. schedule/push runs on the default branch always belong on the tracking issue and have no business looking up a PR by SHA.

  2. Require the matched PR to be in the open state. The previous "fall back to any PR if only closed ones match (e.g. squash-merge race)" is undesirable: if the PR has already merged, posting a fresh coverage comment on it is noise, not information. If a contributor really wanted the comment on a merged PR they can re-run the workflow.

Together these mean the SHA fallback only ever fires for an open fork PR, which is the only case it was ever meant to handle.

The SHA-based fallback added in microsoft#847 (resolve PR by head SHA when
`workflow_run.pull_requests[]` is empty) handles fork PRs correctly,
but it also fires for `schedule` and `push` runs on `main`. The
nightly's head SHA is the merge commit of whichever PR last landed,
and `listPullRequestsAssociatedWithCommit` returns that PR — so the
nightly coverage report ended up posted as a comment on the just-
merged (now closed) PR instead of on the tracking issue.

Two changes, both narrowing the fallback:

  1. Only run the SHA fallback when
     `workflow_run.event === 'pull_request'`. `schedule`/`push`
     runs on the default branch always belong on the tracking
     issue and have no business looking up a PR by SHA.

  2. Require the matched PR to be in the `open` state. The
     previous "fall back to any PR if only closed ones match
     (e.g. squash-merge race)" is undesirable: if the PR has
     already merged, posting a fresh coverage comment on it is
     noise, not information. If a contributor really wanted the
     comment on a merged PR they can re-run the workflow.

Together these mean the SHA fallback only ever fires for an open
fork PR, which is the only case it was ever meant to handle.
@mjp41 mjp41 merged commit 7559b1e into microsoft:main May 10, 2026
198 checks passed
@mjp41 mjp41 deleted the coverage-comment-fix-fallback branch May 10, 2026 08:35
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