fix(ci): prefer GitHub Actions PR-event head SHA over GITHUB_SHA#1469
Conversation
This was referenced May 27, 2026
This was referenced May 27, 2026
Member
Author
|
This pull request is part of a Mergify stack:
|
This was referenced May 27, 2026
Contributor
Merge ProtectionsYour pull request matches the following merge protections and will not be merged until they are valid. 🔴 ⛓️ Depends-On RequirementsWaiting for
This rule is failing.Requirement based on the presence of
🔴 👀 Review RequirementsWaiting for
This rule is failing.
🔴 🔎 ReviewsWaiting for
This rule is failing.
🟢 🤖 Continuous IntegrationWonderful, this rule succeeded.
🟢 Enforce conventional commitWonderful, this rule succeeded.Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
🟢 📕 PR descriptionWonderful, this rule succeeded.
|
57bb83b to
bd85763
Compare
73d824f to
53e9e75
Compare
Member
Author
Revision history
|
53e9e75 to
eb452fa
Compare
bd85763 to
c994e93
Compare
eb452fa to
ab01533
Compare
8460659 to
de0921a
Compare
ab01533 to
dbb0765
Compare
dbb0765 to
edcef26
Compare
On GitHub Actions `pull_request` builds, `GITHUB_SHA` points at the synthetic merge commit GitHub creates by pre-merging the PR head into the base — not the actual code the tests ran against. The contributor's real head SHA lives in the event payload at `pull_request.head.sha`, and that's the value Mergify dashboards correlate with. Without this fix, every `ci junit-process` run on a PR was uploading the wrong `vcs.ref.head.revision` resource attribute. `get_github_actions_head_sha` now reads `GITHUB_EVENT_PATH`, looks for `pull_request.head.sha`, and falls back to `GITHUB_SHA` if the payload is missing, malformed, or the build isn't a `pull_request` event — matching Python's `get_github_actions_head_sha`. The PR-event JSON read is shared across the pull-request-number lookup (existing) and the head-SHA lookup (new); the number lookup stays strict about parse errors because it's load-bearing for `scopes-send` dispatch, while the SHA lookup stays lenient because `GITHUB_SHA` is a sane fallback. Three unit tests pin: payload-wins-over-env, no-PR-field-falls- back-to-env, and missing-event-file-still-uses-env. The CircleCI PR-build API fallback Python implements stays Python-side for now — it requires a GitHub REST API client we don't have on the Rust side yet. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> Change-Id: I99912b552f5841c3364c1a84e29a73486d6c083e
a823367 to
7a63271
Compare
edcef26 to
1573dd6
Compare
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.
On GitHub Actions
pull_requestbuilds,GITHUB_SHApoints atthe synthetic merge commit GitHub creates by pre-merging the PR
head into the base — not the actual code the tests ran against.
The contributor's real head SHA lives in the event payload at
pull_request.head.sha, and that's the value Mergify dashboardscorrelate with. Without this fix, every
ci junit-processrunon a PR was uploading the wrong
vcs.ref.head.revisionresourceattribute.
get_github_actions_head_shanow readsGITHUB_EVENT_PATH, looks forpull_request.head.sha, and fallsback to
GITHUB_SHAif the payload is missing, malformed, orthe build isn't a
pull_requestevent — matching Python'sget_github_actions_head_sha. The PR-event JSON read is sharedacross the pull-request-number lookup (existing) and the head-SHA
lookup (new); the number lookup stays strict about parse errors
because it's load-bearing for
scopes-senddispatch, while theSHA lookup stays lenient because
GITHUB_SHAis a sane fallback.Three unit tests pin: payload-wins-over-env, no-PR-field-falls-
back-to-env, and missing-event-file-still-uses-env.
The CircleCI PR-build API fallback Python implements stays
Python-side for now — it requires a GitHub REST API client we
don't have on the Rust side yet.
Co-Authored-By: Claude Opus 4.7 noreply@anthropic.com
Depends-On: #1468