Skip to content

Gh 27 wait approval status - #28

Merged
aersam merged 4 commits into
mainfrom
gh-27-wait-approval-status
Sep 23, 2026
Merged

aersam merged 4 commits into
mainfrom
gh-27-wait-approval-status

Conversation

@aersam

@aersam aersam commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

No description provided.

aersam and others added 4 commits September 18, 2026 16:21
Azure Pipelines stages and GitHub Actions environments can pause a run on a
manual approval gate. That leaves the run "in progress" indefinitely, so
--wait polled forever waiting for something only a human can resolve.

Detect it explicitly instead: on Azure DevOps, look for an open
Checkpoint.Approval timeline record and resolve its stage name by walking
the parent chain; on GitHub, a CheckRun's status "WAITING" already flags a
deployment protection rule. Either way, --wait now stops, prints which
stage/check needs a reviewer plus a link to act on it, and exits with a
dedicated code (2) distinct from success/failure.

Fixes #27.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
- gh_pr.py / pr_build.py: don't let a pending-approval report mask an
  already-failed check/pipeline elsewhere in the same PR — report the
  failure (exit 1) instead of just prompting for approval (exit 2), and
  don't silently fall back into the old infinite-poll loop when the
  failure suppressed the approval check.
- pr_build.py: only fetch a build's timeline when its status is actually
  "inProgress" — a build that's "notStarted"/"postponed" has no timeline
  yet and the endpoint 404s, which crashed --wait.
- Add regression tests for both wait-loop interactions and the
  not-started-build skip.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Resolves conflicts from main's concurrent `bdt pr retry`/`bdt pr
watch-deploy` work against this branch's approval-wait fix. The new
`watch-deploy` command (run_watch_deploy in both gh_pr.py and pr_build.py)
had the identical hang-on-approval bug, so it gets the same fix as
`pr status --wait`.

Also fixes issues found by code review during the merge:
- Change EXIT_NEEDS_APPROVAL from 2 to 3 (2 collides with Click/Typer's
  own usage-error exit code).
- An already-failed pipeline/check must not be masked by a co-occurring
  waiting-approval report, in either direction (fixed in both gh_pr.py
  and pr_build.py, for both commands).
- gh_pr.py's run() could still hang if a failed check, a waiting-approval
  check, and a separately-stuck pending check all coexisted.
- pr_build.py's --wait baseline/staleness check treated an already
  in-progress build (present before --wait was even invoked) as
  perpetually "stale, waiting for a new build to start", so the new
  approval detection was never reached unless --wait happened to be
  invoked in the split second before the build was created.
- find_pending_approvals now fails open on a timeline 404 (a build can
  briefly report in-progress before its timeline document exists).
- print_build's result formatting crashed on ADO's explicit `result:
  null` for an in-progress build.
- Extracted shared helpers (exit_if_blocked_on_approval in pr_build.py,
  exit_needs_approval in gh_pr.py) instead of duplicating the
  approval-report logic across run()/run_watch_deploy().

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@aersam
aersam merged commit 086ffb6 into main Sep 23, 2026
1 check passed
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