Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
schema: spec-driven
created: 2026-11-17
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Design

## Decisions

### One no-CI rule in the merge-readiness verdict

`_judge_checks` decides that no check can start, so `devops pr check-readiness`, `devops pr
ready` and `devops pr monitor` share one verdict. The verdict sets `no_ci`, adds an INFO advisory
and adds no `CHECKS_PENDING` blocker. `devops pr ready` reads `no_ci` instead of the branch-wide
workflow count.

### Read the workflow triggers at the head commit

`GitHubClient.pull_request_workflow_at` lists `.github/workflows` at the head commit, reads each
YAML file and parses its `on` key. A workflow that lists `pull_request` or `pull_request_target`
can start a check on the pull request. A missing folder means no CI. A folder that holds only
`push` or `workflow_dispatch` workflows also means no CI.

YAML 1.1 reads a bare `on` key as the boolean `True`, so the parser reads both keys.

### Fail closed on an unread workflow

A read error, or a workflow file that is not valid YAML, keeps the pending check. An unread
workflow is no proof that no check can start, so `devops pr ready` waits (exit 8) and
`devops pr monitor` waits until its timeout rather than report a pull request ready.

### A conflict stops the monitor before the pending check

Once the no-CI rule removes the pending stand-in, the monitor's settled result names the merge
conflict at once. It no longer sleeps for a check that no workflow will start.

### Remove `count_workflows`

The branch-wide count reads no trigger and no head commit, so it answered the wrong question. No
caller remains after this change.

## Rejected alternatives

- **Keep `count_workflows`:** it counts workflows on any branch and ignores triggers, so it
reports CI for a workflow that cannot run on a pull request.
- **Fix each command separately:** three copies drift, and #5142 already left `pr monitor` and
`check-readiness` behind.
- **Read the workflow file names only:** a workflow with only `push` or `workflow_dispatch`
triggers cannot start a check on the pull request.
- **Treat an unread workflow as no CI:** that reports a pull request ready on no evidence.
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Proposal: #5144

## Why

`devops pr monitor` and `devops pr check-readiness` take the head commit of a pull request with no
check as a running check. In a repository with no GitHub Actions workflow no check will start, so
`check-readiness` exits 1 with a pending-check blocker and `pr monitor` waits until its timeout and
exits 3. Pull request #5142 (#3767) excused that case for `devops pr ready` only. Closes #5144.

## What Changes

- The merge-readiness verdict reads the workflows at the head commit and their triggers. A
repository with no workflow, or none that lists `pull_request` or `pull_request_target`, has no
CI for the pull request.
- The verdict adds an INFO advisory and no pending-check blocker when no workflow can start a
check on the pull request, so `devops pr check-readiness` exits 0 and `devops pr monitor`
settles on its first poll.
- `devops pr ready` uses the same verdict instead of `GitHubClient.count_workflows`.
- A workflow read that fails keeps the pending check, so all three commands fail closed.

## Capabilities

### Modified

- `pr-merge-readiness`: the verdict, `devops pr check-readiness`, `devops pr ready` and
`devops pr monitor` share one no-CI decision.

## Impact

`devops pr check-readiness`, `devops pr ready` and `devops pr monitor` no longer wait for a check
that a repository without a pull-request workflow cannot start. `GitHubClient.count_workflows` is
removed, since its branch-wide count ignores the triggers and the head commit.

## Feasibility

Confirmed against the issue and the code at `origin/main`: `_judge_checks` in
`src/devops_cli/github/merge_readiness.py` holds the pending stand-in, `_no_ci` in
`src/devops_cli/commands/pr.py` used `GitHubClient.count_workflows`, and
`CheckVerdictSummary.reports_nothing` detects the stand-in. `GitHubClient.get_file_at` already
reads a file at a ref, and PyYAML is a project dependency.

## Existing Tool Considered

No open tool or library covers this need. The change uses the existing GitHub contents endpoint
and PyYAML, adds no dependency, and costs about 8,000 tokens and one engineer-day to build and
test.
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
## MODIFIED Requirements

### Requirement: pr ready does not wait for checks in a repository with no CI

When the head commit of the pull request reports no check run and no commit status, the merge
readiness verdict SHALL read the workflows at that commit and their triggers. When no workflow
lists `pull_request` or `pull_request_target`, no check can start. Then the verdict SHALL add no
pending-check blocker and SHALL name the missing CI in an INFO advisory. `devops pr ready` SHALL
say so, SHALL NOT judge the checks or warn of them, and SHALL mark the pull request ready with no
`--force`.

#### Scenario: A repository with no CI

- **WHEN** the head commit reports no check and holds no workflow file
- **THEN** `pr ready` names the repository, says that it has no workflow that runs on a pull
request, marks the pull request ready, and exits 0 with no warning about "no checks reported"

#### Scenario: A push-only workflow

- **WHEN** the head commit reports no check and holds one workflow with only `push` and
`workflow_dispatch` triggers
- **THEN** `pr ready` marks the pull request ready and exits 0

### Requirement: pr ready waits for checks that a workflow can start

When the head commit reports no check and holds a workflow that lists `pull_request` or
`pull_request_target`, `devops pr ready` SHALL wait for the checks as before. A read of the
workflows that fails SHALL keep the pending check, so `devops pr ready` SHALL exit 8 and marks
nothing.

#### Scenario: Checks that have not started

- **WHEN** the head commit reports no check and holds a workflow that lists `pull_request`
- **THEN** `pr ready` exits 8 and marks nothing

#### Scenario: The workflows cannot be read

- **WHEN** the head commit reports no check and GitHub answers the read of the workflows with an
error
- **THEN** `pr ready` exits 8 and marks nothing

## ADDED Requirements

### Requirement: The verdict reads the workflow triggers at the head commit

The merge-readiness verdict SHALL read `.github/workflows` at the head commit and the `on` key of
each workflow file. A 404, an empty folder, or a folder whose workflows all list other triggers
SHALL mean that no CI can run on the pull request.

#### Scenario: A pull-request workflow keeps the pending check

- **WHEN** a test gives the head commit one workflow whose `on` key lists `pull_request` and
gives no check runs
- **THEN** the verdict holds `BlockerKind.CHECKS_PENDING` and `pending_checks` holds
`no checks reported`

#### Scenario: A push-only workflow suppresses the pending check

- **WHEN** a test gives the head commit one workflow with only `push` and `workflow_dispatch`
triggers and gives no check runs
- **THEN** the verdict holds no `BlockerKind.CHECKS_PENDING` blocker and holds the no-CI advisory

#### Scenario: An unread workflow fails closed

- **WHEN** a test makes the workflow read fail and gives no check runs
- **THEN** the verdict holds `BlockerKind.CHECKS_PENDING` and `pending_checks` holds
`no checks reported`

### Requirement: check-readiness reports a repository with no CI

`devops pr check-readiness` SHALL exit 0 with the no-CI advisory when no workflow can run on the
head commit and no other blocker applies.

#### Scenario: check-readiness on a repository with no CI

- **WHEN** a test runs `devops pr check-readiness` for a pull request whose head commit holds no
workflow and no check
- **THEN** the test asserts exit code 0 and that the output contains the no-CI advisory

### Requirement: pr monitor does not wait for a repository with no CI

`devops pr monitor` SHALL settle on its first poll when no workflow can run on the head commit
and no other blocker applies.

#### Scenario: pr monitor on a repository with no CI

- **WHEN** a test runs `devops pr monitor` with a fake clock for a pull request whose head commit
holds no workflow and no check
- **THEN** the test asserts exit code 0 and that the monitor made no sleep call

### Requirement: pr monitor stops on a conflict before pending checks

`devops pr monitor` SHALL report a merge conflict and stop before it waits on the pending
no-checks stand-in.

#### Scenario: Conflict with no checks

- **WHEN** a test gives the verdict a `mergeable_state` of `dirty` and no check runs
- **THEN** the output names the merge conflict and the monitor made no sleep call
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Tasks

## 1. Behavior

- [x] 1.1 Write the failing tests for a head commit with no check and no pull-request workflow, a
pull-request workflow, a push-only workflow, and an unread workflow.
- Verification: `$ uv run devops ci test tests/github/test_merge_readiness.py`
- [x] 1.2 Read the workflow triggers at the head commit and suppress the pending check when no
workflow can start one.
- Verification: `$ uv run devops ci test tests/github/test_merge_readiness.py tests/commands/test_pr.py`
- [x] 1.3 Make `devops pr ready` read the verdict's no-CI decision and remove `count_workflows`.
- Verification: `$ uv run devops ci test tests/commands/test_pr.py`

## 2. Documents

- [x] 2.1 Update the `pr-merge-readiness` specification with the head-workflow rule.
- Verification: `$ uv run devops openspec check`
- [x] 2.2 Archive the change into the main specification.
- Verification: `$ uv run devops openspec archive 5144-pr-monitor-fits-a-repository-with`
92 changes: 85 additions & 7 deletions openspec/specs/pr-merge-readiness/spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,22 +125,43 @@ The verdict SHALL hold one blocker of the kind body form for each problem that `
- **THEN** `merge_conflict` returns None and the row posts no comment

### Requirement: pr ready does not wait for checks in a repository with no CI
When the head commit of the pull request reports no check run and no commit status, and the repository has no GitHub Actions workflow, no check will start. Then `devops pr ready` SHALL say so, SHALL NOT judge the checks or warn of them, and SHALL mark the pull request ready with no `--force`.

When the head commit of the pull request reports no check run and no commit status, the merge
readiness verdict SHALL read the workflows at that commit and their triggers. When no workflow
lists `pull_request` or `pull_request_target`, no check can start. Then the verdict SHALL add no
pending-check blocker and SHALL name the missing CI in an INFO advisory. `devops pr ready` SHALL
say so, SHALL NOT judge the checks or warn of them, and SHALL mark the pull request ready with no
`--force`.

#### Scenario: A repository with no CI
- **WHEN** the head commit reports no check and the repository has no workflow
- **THEN** `pr ready` names the repository, says that it has no GitHub Actions workflow, marks the pull request ready, and exits 0 with no warning about "no checks reported"

- **WHEN** the head commit reports no check and holds no workflow file
- **THEN** `pr ready` names the repository, says that it has no workflow that runs on a pull
request, marks the pull request ready, and exits 0 with no warning about "no checks reported"

#### Scenario: A push-only workflow

- **WHEN** the head commit reports no check and holds one workflow with only `push` and
`workflow_dispatch` triggers
- **THEN** `pr ready` marks the pull request ready and exits 0

### Requirement: pr ready waits for checks that a workflow can start
When the head commit reports no check and the repository has a GitHub Actions workflow, `devops pr ready` SHALL wait for the checks as before. A read of the workflows that fails SHALL stop the command with exit 1 and the error.

When the head commit reports no check and holds a workflow that lists `pull_request` or
`pull_request_target`, `devops pr ready` SHALL wait for the checks as before. A read of the
workflows that fails SHALL keep the pending check, so `devops pr ready` SHALL exit 8 and marks
nothing.

#### Scenario: Checks that have not started
- **WHEN** the head commit reports no check and the repository has 2 workflows

- **WHEN** the head commit reports no check and holds a workflow that lists `pull_request`
- **THEN** `pr ready` exits 8 and marks nothing

#### Scenario: The workflows cannot be read
- **WHEN** the head commit reports no check and GitHub answers the read of the workflows with an error
- **THEN** `pr ready` exits 1 and marks nothing

- **WHEN** the head commit reports no check and GitHub answers the read of the workflows with an
error
- **THEN** `pr ready` exits 8 and marks nothing

### Requirement: Readiness reads the file list at the merge base
The command `devops pr check-readiness` SHALL read the files a pull request changes from the compare endpoint of the tip of the base branch and the head commit, and MUST NOT compare from the `base.sha` of the pull request payload.
Expand Down Expand Up @@ -267,3 +288,60 @@ The stage eval evidence SHALL hold a number beside `before` and beside `after`,
#### Scenario: A model flag with no name is refused
- **WHEN** the body holds `--model` with no name
- **THEN** `stage_eval_problems` names the flag

### Requirement: The verdict reads the workflow triggers at the head commit

The merge-readiness verdict SHALL read `.github/workflows` at the head commit and the `on` key of
each workflow file. A 404, an empty folder, or a folder whose workflows all list other triggers
SHALL mean that no CI can run on the pull request.

#### Scenario: A pull-request workflow keeps the pending check

- **WHEN** a test gives the head commit one workflow whose `on` key lists `pull_request` and
gives no check runs
- **THEN** the verdict holds `BlockerKind.CHECKS_PENDING` and `pending_checks` holds
`no checks reported`

#### Scenario: A push-only workflow suppresses the pending check

- **WHEN** a test gives the head commit one workflow with only `push` and `workflow_dispatch`
triggers and gives no check runs
- **THEN** the verdict holds no `BlockerKind.CHECKS_PENDING` blocker and holds the no-CI advisory

#### Scenario: An unread workflow fails closed

- **WHEN** a test makes the workflow read fail and gives no check runs
- **THEN** the verdict holds `BlockerKind.CHECKS_PENDING` and `pending_checks` holds
`no checks reported`

### Requirement: check-readiness reports a repository with no CI

`devops pr check-readiness` SHALL exit 0 with the no-CI advisory when no workflow can run on the
head commit and no other blocker applies.

#### Scenario: check-readiness on a repository with no CI

- **WHEN** a test runs `devops pr check-readiness` for a pull request whose head commit holds no
workflow and no check
- **THEN** the test asserts exit code 0 and that the output contains the no-CI advisory

### Requirement: pr monitor does not wait for a repository with no CI

`devops pr monitor` SHALL settle on its first poll when no workflow can run on the head commit
and no other blocker applies.

#### Scenario: pr monitor on a repository with no CI

- **WHEN** a test runs `devops pr monitor` with a fake clock for a pull request whose head commit
holds no workflow and no check
- **THEN** the test asserts exit code 0 and that the monitor made no sleep call

### Requirement: pr monitor stops on a conflict before pending checks

`devops pr monitor` SHALL report a merge conflict and stop before it waits on the pending
no-checks stand-in.

#### Scenario: Conflict with no checks

- **WHEN** a test gives the verdict a `mergeable_state` of `dirty` and no check runs
- **THEN** the output names the merge conflict and the monitor made no sleep call
17 changes: 6 additions & 11 deletions src/devops_cli/commands/pr.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
parse_update_error,
plan_update_single_pr,
)
from devops_cli.github.check_verdict import CheckVerdictSummary
from devops_cli.github.client import PullStatus
from devops_cli.github.defect_classifier import (
PRHardeningAudit,
Expand Down Expand Up @@ -1410,15 +1409,11 @@ def _handle_pr_ready_failure(stderr_text: str, number: int) -> None:
print_error(f"Failed to mark PR #{number} ready: {clean_err or 'Unknown error'}", safe=True)


def _no_ci(repo: str, checks: CheckVerdictSummary | None) -> bool:
"""Whether no check will come for the pull request (#3767): its head commit reports no check
run and no commit status, and `repo` has no GitHub Actions workflow to start one. A read that
fails raises the error of the session."""
if checks is None or not checks.reports_nothing:
return False
from devops_cli.github.session import get_github_session

return get_github_session().client.count_workflows(repo) == 0
def _no_ci(verdict: MergeReadiness) -> bool:
"""Whether no check will come for the pull request (#3767, #5144): the merge-readiness verdict
reads the workflows at its head and finds none that runs on a pull request, so it excuses the
missing checks. A workflow read that fails keeps the pending check, so the verdict says no."""
return verdict.no_ci


def _validate_pr_ready(number: int, owner: str, repo_name: str, pr_data: dict[str, Any]) -> Draft:
Expand All @@ -1436,7 +1431,7 @@ def _validate_pr_ready(number: int, owner: str, repo_name: str, pr_data: dict[st
repo = f"{owner}/{repo_name}"
pull = PullStatus.model_validate(pr_data)
try:
no_ci = _no_ci(repo, verdict.checks)
no_ci = _no_ci(verdict)
checks = None if no_ci else verdict.checks
draft = read_draft(repo, number, pull=pull, checks=checks, declared=True)
except (GitHubOperationError, GitHubUnreadError) as exc:
Expand Down
Loading