Repository navigation
Description
Problem
Part of #7499. The template pull request of devops repos onboard polls its check runs and sends its own GraphQL enablePullRequestAutoMerge and mergePullRequest mutations (src/devops_cli/github/onboard/template_pr.py:31-55, :137-146, :312-377).
Change
- Read or wait for the checks with
gh pr checks <n> --jsonor--watch. - Merge with
gh pr merge <n> --auto --squash --match-head-commit <sha>. GitHub merges only that head commit, after the required checks pass. Who may merge does not change.
Done when
- The poll and the two mutations of
template_pr.pyare deleted. - A test proves the
gh pr checksandgh pr mergearguments and the map of their answers to the row of the template pull request.
Existing tool considered
GitHub CLI (https://github.com/cli/cli), MIT, v2.106.0: gh pr merge --auto --squash --match-head-commit.
Source
Source: #7499
Alternatives check of 2026-11-28: not-applicable.
Class: refactor, no model call.
Tool: none found.
Proposed design
Problem statement
The template pull request of devops repos onboard polls its check runs through the REST API and sends its own GraphQL enablePullRequestAutoMerge and mergePullRequest mutations. This change deletes that poll and those mutations: the row waits and reads every check with gh pr checks, maps gh's answer to the row states that rows 9, 10 and 11 need, and merges the head that the checks ran on with gh pr merge --auto --squash --match-head-commit. The ready-for-review call, the head check and who may merge do not change. The route table, its read list, the spec of the row and the tests move with it.
Acceptance criteria
Requirement: Wait for the checks with gh
The template pull request row SHALL wait for the checks with gh pr checks <number> --repo <repo> --watch --interval 15 in a confirmed run.
Scenario: A confirmed run waits
- WHEN A confirmed run fakes
gh pr checks 42 --repo owner/name --watch --interval 15and it exits 0. - THEN The test sees that command, and then the read
gh pr checks 42 --repo owner/name --json name,state,bucket,workflow,link.
Requirement: Read every check, not only the required ones
The row SHALL read every check of the template pull request with gh pr checks <number> --repo <repo> --json name,state,bucket,workflow,link, with no --required flag.
Scenario: A non-required check fails
- WHEN The fake
gh pr checks --jsonlistsTrivywith bucketfail, and no ruleset of the repository requiresTrivy. - THEN Row 9 is failed and names Trivy, and the fake process sees no
gh pr mergecall.
Requirement: A pending check waits
The row SHALL map a check of bucket pending to the waiting state of row 9.
Scenario: A check is pending
- WHEN The fake
gh pr checks --jsonlistsTests & Coveragewith bucketpending. - THEN Row 9 is waiting, names
Tests & Coverage, and the fake process sees nogh pr mergecall.
Requirement: A head with no check waits
The row SHALL map the no checks reported answer of gh pr checks to the waiting state of row 9.
Scenario: No check reported
- WHEN The fake
gh pr checks --jsonexits 1 withno checks reported on the 'ci/repository-template' branch. - THEN Row 9 is waiting, and the fake process sees no
gh pr mergecall.
Requirement: A watch that reaches its limit waits
The row SHALL give gh pr checks --watch the timeout _CHECKS_WAIT_SECONDS and SHALL map exit code 124 to the waiting state of row 9.
Scenario: The watch reaches the limit
- WHEN The fake
gh pr checks --watchanswers exit code 124 withGitHub API command timed out after 900.0 seconds. - THEN Row 9 is waiting, and the fake process sees no
gh pr mergecall.
Requirement: Successful and skipped names reach row 10
The row SHALL record the names of state SUCCESS as successful_checks and the names of state SKIPPED as skipped_checks of the row context.
Scenario: A skipped check is not required
- WHEN The fake
gh pr checks --jsonlistsK8swith stateSKIPPEDandLintwith stateSUCCESS, and--confirmruns. - THEN The ruleset of row 10 requires
Lintand notK8s.
Requirement: Merge with the head that the checks ran on
Row 11 SHALL merge the template pull request with gh pr merge <number> --repo <repo> --auto --squash --match-head-commit <sha> after the checks pass.
Scenario: The checks pass
- WHEN Row 9 passed for head
abc123and a confirmed run reaches row 11. - THEN The test sees
gh pr merge 42 --repo owner/name --auto --squash --match-head-commit abc123, and the fake GitHub sees noenablePullRequestAutoMergeormergePullRequestmutation.
Requirement: A plan records the merge and sends it only with confirm
The row 11 merge SHALL go through the route pull-merge, which records RUN gh pr merge <number> in a plan and sends the command only with --confirm.
Scenario: A plan of a repository whose checks passed
- WHEN
--planruns on a repository whose template pull request passed its checks. - THEN The recorded writes hold
RUN gh pr merge 42, and the fake process sees nogh pr mergecall.
Requirement: The poll and the GraphQL mutations leave the module
The module SHALL delete _read_checks, _wait_for_checks, _AUTO_MERGE_MUTATION, _MERGE_MUTATION, _MERGE_STATE_QUERY and _MERGEABLE_NOW.
Scenario: The legacy code is gone
- WHEN A test imports the template pull request module.
- THEN The module holds none of those names, and its source holds no
enablePullRequestAutoMergeormergePullRequest.
Requirement: The route table holds no removed mutation
The route table SHALL hold the pull-merge route of row 11 and SHALL hold no route that names enablePullRequestAutoMerge or mergePullRequest.
Scenario: The route table is read
- WHEN A test reads
ROUTES. - THEN No route names
enablePullRequestAutoMergeormergePullRequest,pull-mergematchesRUN gh pr merge 42, andpull-readystill namesmarkPullRequestReadyForReview.
Existing Tool Considered
GitHub CLI (gh), MIT, v2.106.0 (https://github.com/cli/cli, fetched 2026-11-28), which the repository already uses to read checks (src/devops_cli/github/check_verdict.py:327) and to merge the release pull request (.github/workflows/release-merge.yml:84). It covers the wait (gh pr checks --watch), the read (--json name,state,bucket,workflow,link) and the merge (gh pr merge --auto --squash --match-head-commit). It lacks the onboard row model: it returns a list of checks and an exit code, not a row state, and it records nothing in the --plan output, so the change adds the map to RowState and the pull-merge route.
Key questions
- Which
gh pr checkscommand should the template row use to wait and to read?: Wait withgh pr checks <n> --repo <repo> --watch --interval 15in a confirmed run, then read the names and states withgh pr checks <n> --repo <repo> --json name,state,bucket,workflow,linkthrough the existingread_pr_checks. The watch deletes the poll loop; the read gives row 10 the successful and skipped names. (best practice) [sources: src/devops_cli/github/check_verdict.py:327, src/devops_cli/github/check_verdict.py:333, openspec/changes/archive/2026-10-28-2443-pr-ready-monitor-verdict/proposal.md:46, src/devops_cli/github/onboard/template_pr.py:137]- Chosen:
gh pr checks --watch --interval 15, then a--jsonread. The watch waits as the poll did and the read gives every name and state that rows 9 and 10 need. - Rejected: One
gh pr checks --jsonread with no wait. The issue asks the row to wait with gh; a confirmed run would leave row 9 waiting and need another run. - Rejected: One
gh pr checks --watch --jsoncall. The repository uses the two flags apart and holds no source that shows them together; the read after the watch is one cheap call.
- Chosen:
- Should the row wait for all checks or only required checks?: Read every check, with no
--requiredflag. The project decided this on 2026-11-28 for the same gh read (refactor(pr): read the readiness checks with gh pr checks #7508):--requiredexits 1 withno required checks reportedboth for a branch that requires no check and for required checks that have not started, and it drops a failed check that no ruleset requires. Row 9 fails a failed check today, row 10 needs the successful and skipped names, and AGENTS.md rule 5 forbids lowering that gate. (best practice) [sources: AGENTS.md:11, openspec/changes/archive/2026-11-28-7508-readiness-checks-gh/design.md:5, openspec/changes/archive/2026-11-28-7508-readiness-checks-gh/design.md:13, src/devops_cli/github/onboard/template_pr.py:43, src/devops_cli/github/onboard/settings_rows.py:683]- Chosen: Read every check with
gh pr checks --json name,state,bucket. It keeps the gate that row 9 applies today, gives row 10 each successful and skipped name, and never fails a new repository before row 10 has written the ruleset. - Rejected: Read only the required checks with
--required. gh answers a branch that requires no check, or whose required checks have not started, with exit 1no required checks reported, so row 9 would fail before row 10 writes the ruleset; it also drops a failed check that no ruleset requires, which rule 5 of AGENTS.md forbids.
- Chosen: Read every check with
- What does each
gh pr checksanswer mean for the row?: Useread_pr_checks, which maps theno checks reportedanswer (exit 1) and an empty list to the pending stand-in, and each listed bucket to aCheckBucket. The row then mapsfailandcancelto failed,pendingto waiting, and pass and skipping to passed; the names of stateSUCCESSare the successful names and the names of stateSKIPPEDthe skipped names. A read that fails or prints no list is failed with the reason. (best practice) [sources: src/devops_cli/github/check_verdict.py:31, src/devops_cli/github/check_verdict.py:111, src/devops_cli/github/check_verdict.py:340, tests/github/test_pr_check_verdict.py:274, src/devops_cli/github/onboard/template_pr.py:216]- Chosen: Judge the items of
read_pr_checks. It already tells gh'sno checks reportedanswer from a failed check and gives each bucket and state;devops pr readyand the merge readiness read the checks with it. - Rejected: Judge the exit code of
gh pr checksalone. Exit 1 is both a failed check andno checks reported, so the row would fail a head whose checks have not started.
- Chosen: Judge the items of
- Which merge command should replace the GraphQL mutations?: Use
gh pr merge <n> --repo <repo> --auto --squash --match-head-commit <sha>. GitHub then merges only that head commit, after the required checks pass, and merges at once when nothing is left to wait for, so the merge-state read and the choice ofmergePullRequestgo. (best practice) [sources: src/devops_cli/github/onboard/template_pr.py:46, src/devops_cli/github/onboard/template_pr.py:56, .github/workflows/release-merge.yml:84, openspec/specs/release-scheduled-merge/spec.md:16, RELEASE_CYCLE.md:46]- Chosen:
gh pr merge --auto --squash --match-head-commit. It keeps the required-check gate and the head check in GitHub, and it merges at once when the checks already passed. - Rejected:
gh pr merge --squash --match-head-commitwithout--auto. It merges at once even when GitHub still waits for a required check, so the row would no longer keep the gate in GitHub. - Rejected: Keep GraphQL
enablePullRequestAutoMergeandmergePullRequest. The issue deletes both mutations.
- Chosen:
- How does the plan record the merge that gh sends?: Add the route
pull-mergeof row 11 with methodRUN, path formgh pr merge {pull}and ownerPERSON_LOGIN, and call it throughwriter.run, which recordsRUN gh pr merge <number>in a plan and sends the command only with--confirm. The ready mark stays on thepull-readyroute. (best practice) [sources: src/devops_cli/github/onboard/routes.py:462, src/devops_cli/github/onboard/routes.py:332, src/devops_cli/github/onboard/routes.py:200, src/devops_cli/github/onboard/routes.py:282]- Chosen: A
RUNroutepull-mergethat recordsgh pr merge <number>. It names the command that the row starts, and the plan and the route-ownership test see it as the write that it is. - Rejected: A route on
PUT /repos/{repo}/pulls/{pull}/merge.gh pr merge --autosends the GraphQL enablePullRequestAutoMerge mutation, not the REST merge endpoint, so the plan would name a request that the row does not send. - Rejected: Keep the GraphQL
pull-auto-mergeroute. No row sends either mutation after the change.
- Chosen: A
- Which other repository files must change when the poll and the two mutations leave the template row?: Change
src/devops_cli/github/onboard/routes.pyto replace thepull-auto-mergeGraphQL route withpull-merge, and change the read list from the check-runs read of row 9 and themergeStateStatusread of row 11 to thegh pr checksread of row 9. Changeopenspec/specs/repos-onboard/spec.mdso the requirement and itsCLEANscenario say that row 11 marks the pull request ready and merges it withgh pr merge --auto --squash --match-head-commit, with nomergePullRequest. Change the tests attests/github/onboard/test_onboard_rows.pyandtests/github/onboard/test_onboard_routes.py. [sources: src/devops_cli/github/onboard/routes.py:282, src/devops_cli/github/onboard/routes.py:372, src/devops_cli/github/onboard/routes.py:376, openspec/specs/repos-onboard/spec.md:186, openspec/specs/repos-onboard/spec.md:191, tests/github/onboard/test_onboard_rows.py:118, tests/github/onboard/test_onboard_rows.py:552, tests/github/onboard/test_onboard_routes.py:47] - Which tests prove the gh arguments and the result map?: Extend
tests/github/onboard/test_onboard_rows.py, whoseonboard_githubfixture already routes gh to the process fake: script thegh pr checks --watchand--jsonanswers and thegh pr mergeanswer, assert each argv, the row states and the names that row 10 requires. Add thepull-mergecase to the route test attests/github/onboard/test_onboard_routes.py:47. [sources: tests/github/onboard/test_onboard_rows.py:535, tests/github/onboard/test_onboard_rows.py:552, tests/support/github_repository.py:886, tests/support/github_repository.py:901, tests/github/onboard/test_onboard_routes.py:47]
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
dan-petty commentedon Nov 28, 2026
Both work on template_pr.py and its check-run logic, but #7476 fixes stale check names from merged PRs while the candidate refactors the wait-and-merge implementation to use gh CLI.refactor(pr): read the readiness checks with gh pr checks (#7519)
devops-cli-service commentedon Nov 28, 2026
Next step: the stage job writes the plan of the item. See the section Proposed design of the body.
devops-cli-service commentedon Nov 29, 2026
Released in v0.256.0: https://github.com/dan-petty/devops-cli/releases/tag/v0.256.0
devops-cli-service commentedon Nov 29, 2026
Live since 2026-11-29 22:09 UTC