Skip to content

Add pr-wait.py: wait for a pull request's checks to finish - #30

Merged
bonelifer merged 1 commit into
mainfrom
add-pr-wait
Oct 19, 2026
Merged

bonelifer merged 1 commit into
mainfrom
add-pr-wait

Conversation

@bonelifer

Copy link
Copy Markdown
Contributor

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

  • Asks GitHub about the pull request through gh pr view every 30 seconds (--interval).
  • Follows new pushes: it always waits for the checks of the pull request's latest commit, and says when a new commit arrives.
  • Counts success, neutral and skipped as passed. Failed, cancelled and timed-out checks count as failed, and are listed with their links.
  • Handles both GitHub Actions check runs and commit statuses from outside services.
  • Stops on its own: after 60 minutes (--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.
  • Retries a failed gh call up to five times in a row, but stops at once if gh isn't installed.
  • With no arguments it prints help. Every option has a short and a long form.

Exit status: 0 passed, 1 failed, 2 bad arguments, 3 closed or merged, 4 timed out, 5 no checks appeared, 6 gh failed. 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 fake gh that 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 and flake8 with a 120-character line limit are clean (the repository's other Python files already go past PEP 8's 79).
  • The script on Python 3.7, in a throwaway python:3.7-slim container.
  • The script against real pull requests: stopforumspam#75 (all 3 checks passed, exit 0), knowledgebase#7 (merged, exit 3), and a repository that doesn't exist (gh failed 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

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>
@bonelifer
bonelifer merged commit 4564f3b into main Oct 19, 2026
1 check passed
@bonelifer
bonelifer deleted the add-pr-wait branch October 19, 2026 14:25
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