Repository navigation
Add pr-wait.py: wait for a pull request's checks to finish - #30
Merged
Merged
Conversation
Polls a pull request with gh until every check on its latest commit has finished, following new pushes, and exits with a status that says how they ended (passed, failed, closed or merged, timed out, no checks, gh failed). Offline tests with a fake gh run in CI. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Adds
pr-wait.py, which waits until every check on a pull request has finished and then exits with a status that says how they ended. It's meant to be started in the background, by a person or by Claude, so whoever started it can act on the result instead of checking CI by hand.What it does
gh pr viewevery 30 seconds (--interval).--timeout), when the pull request is closed or merged, or when no check appears on the latest commit within 3 minutes (--first-check-wait), so it can't wait forever on a repository without CI.ghcall up to five times in a row, but stops at once ifghisn't installed.Exit status: 0 passed, 1 failed, 2 bad arguments, 3 closed or merged, 4 timed out, 5 no checks appeared, 6
ghfailed. Progress lines show the time in UTC.It only uses the Python standard library and
gh, and runs on Python 3.7 or later.Other changes
tests/test-pr-wait.sh: 22 offline checks with a fakeghthat plays back scripted responses.ci.yml: runs the new tests, and ShellCheck on the test script. The job keeps its name.README.md: a section on the script with its exit statuses, plus the requirement and test lines.Testing
Claude ran:
tests/test-pr-wait.sh: all 22 checks pass. ShellCheck andflake8with a 120-character line limit are clean (the repository's other Python files already go past PEP 8's 79).python:3.7-slimcontainer.ghfailed five times, exit 6).Not tested yet: waiting through checks that are still running on a real pull request. Claude will run it on this pull request's own CI once it's open.
Investigated and written by Claude on behalf of William Jacoby (bonelifer).
🤖 Generated with Claude Code