test: wait for PR head sha after force-push in roundtrip harness#457
Merged
tomasz-tomczyk merged 1 commit intomainfrom May 4, 2026
Merged
test: wait for PR head sha after force-push in roundtrip harness#457tomasz-tomczyk merged 1 commit intomainfrom
tomasz-tomczyk merged 1 commit intomainfrom
Conversation
Fixes #456: TestRoundtrip_AnchorLineDeleted_Outdated could flake with HTTP 422 from gh api when run in the full suite. After the test's git push --force rewinds the PR head, GitHub takes a moment to recompute the PR diff. If the next crit push fires too soon, its commit_id no longer matches the current PR head and GitHub rejects the new comment. Add a waitForPRHeadSHA helper to roundtripEnv that polls GET /repos/{slug}/pulls/{N} until head.sha matches the local HEAD, with a 15s deadline. Call it after the force-push in the AnchorLineDeleted_Outdated scenario before issuing further crit commands. Verified with 5x targeted runs and 2x full-suite runs (all green).
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #457 +/- ##
==========================================
+ Coverage 68.18% 68.23% +0.05%
==========================================
Files 35 35
Lines 9936 9936
==========================================
+ Hits 6775 6780 +5
+ Misses 2642 2639 -3
+ Partials 519 517 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Summary
git push --forcerewinds the PR head SHA, GitHub takes a moment to recompute the PR diff. If the nextcrit pushfires too soon, the new comment'scommit_idno longer matches the PR's recomputed diff and GitHub rejects with HTTP 422.waitForPRHeadSHAhelper toroundtripEnvthat pollsGET /repos/{slug}/pulls/{N}untilhead.shamatches the local HEAD, with a 15s deadline (no rawtime.Sleep).TestRoundtrip_AnchorLineDeleted_Outdatedafter the force-push, before the nextcrit pull/crit comment/crit push.Closes #456.
Review
e2e_githubbuild tag)Test plan
e2e_githubtag)go test ./...: PASS./scripts/e2e-roundtrip.sh -run TestRoundtrip_AnchorLineDeleted_Outdated -v— 7 consecutive PASSmake e2e-roundtrip— 2 consecutive PASS🤖 Generated with Claude Code