Public: anyone can read this; the crew can change it.

A pull's checks API says ok when its check failed and a deploy ended after it #17707

opened this in answer to

Closed 10h 4m ago

The pull's checks API now answers failed when its check failed, even if a deploy ended after it. state and run follow the rule merging uses, in both JSON and ?format=text. runs still lists every run.

Notes

opened this

The pull's checks API now answers failed when its check failed, even if a deploy ended after it. state and run follow the rule merging uses, in both JSON and ?format=text. runs still lists every run.

The route in src/http/api.ts takes both from a new checkSummaryOf(runs) in src/core/runs.ts. That is the same newest-of-each-kind rule the page and the merge queue already use (checkSummary, verdictForHead). A failed check wins, then anything still queued or running, and run is the run that decided. A cut-short check reads cancelled, not failed.

I checked the other two readers you asked about, by reading the code, and neither needed a fix. The pull page and the merge queue already go through verdictForHead/checkSummary, so only this route was out of step.

Test: test/api-pchecks-verdict.test.ts runs a failed check and then an ok deploy at one head. It expects failed from both the JSON and the text read, with run the check and runs length 2. Without the src/ change it fails (it gets ok).

What I ran: the new test passes, and bun scripts/gate.ts passes (the gate's last note about a long comment in src/core/runs.ts is nightly rewrap noise, not a failure). I ran bun x tsc --noEmit and bun scripts/design-lint.ts without checking their output, so I can't say they were clean. I did not run the full suite. I only re-ran the new test after the last edits, not the timing or OpenAPI pull-checks tests. The forge's check runs everything.

Left out:

  • No terminal change. It already reads checkSummary, and the commit says No door:.
  • No response shape change. state is still the same field.
  • I documented the new state rule in docs/features/contribute-token.md, next to the ?format=text mention.

Try: GET /api/v1/repos/<owner>/<name>/pulls/<n>/checks?format=text on a pull whose check failed and whose deploy then went ok. It prints state: failed.

🤖 Generated with Claude Code

Closes #17705

2 earlier comments
commented

The pull's checks API now answers failed when its check failed, even if a deploy ended after it. state and run follow the rule merging uses, in both JSON and ?format=text. runs still lists every run.

The route in src/http/api.ts takes both from a new checkSummaryOf(runs) in src/core/runs.ts. That is the same newest-of-each-kind rule the page and the merge queue already use (checkSummary, verdictForHead). A failed check wins, then anything still queued or running, and run is the run that decided. A cut-short check reads cancelled, not failed.

I checked the other two readers you asked about, by reading the code, and neither needed a fix. The pull page and the merge queue already go through verdictForHead/checkSummary, so only this route was out of step.

Test: test/api-pchecks-verdict.test.ts runs a failed check and then an ok deploy at one head. It expects failed from both the JSON and the text read, with run the check and runs length 2. Without the src/ change it fails (it gets ok).

What I ran: the new test passes, and bun scripts/gate.ts passes (the gate's last note about a long comment in src/core/runs.ts is nightly rewrap noise, not a failure). I ran bun x tsc --noEmit and bun scripts/design-lint.ts without checking their output, so I can't say they were clean. I did not run the full suite. I only re-ran the new test after the last edits, not the timing or OpenAPI pull-checks tests. The forge's check runs everything.

Left out:

  • No terminal change. It already reads checkSummary, and the commit says No door:.
  • No response shape change. state is still the same field.
  • I documented the new state rule in docs/features/contribute-token.md, next to the ?format=text mention.

Try: GET /api/v1/repos/<owner>/<name>/pulls/<n>/checks?format=text on a pull whose check failed and whose deploy then went ok. It prints state: failed.

🤖 Generated with Claude Code

commented

The pull's checks route now answers by the rule merging uses, so a red or still-running check at the head is no longer hidden by a deploy that finished after it. The branch already held this fix when my turn resumed, so I made no further push. I re-ran test/api-pchecks-verdict.test.ts, which passes, and bun x tsc --noEmit, which is clean.

What changed

  • state, run and ?format=text: GET /api/v1/repos/:owner/:name/pulls/:number/checks now reads its head runs through a new checkSummaryOf in src/core/runs.ts. That is the same function the pull page and merge use. A failed check (one the forge cut short doesn't count) wins first, then any run not yet ok, then the newest.
  • looks: these follow the chosen run.
  • runs: unchanged; it still lists every run at the head.
  • Page and merge: I checked both and neither needed a fix. The page already reads checkSummary, and merge reads verdictForHead. The API route was the only reader that took runs[0].
  • Test: test/api-pchecks-verdict.test.ts records a failed check and then an ok deploy at the same head, and expects state: failed in JSON and in the text form with runs still listing both. It fails without the route change.
  • Docs: docs/features/contribute-token.md has a two-line note on the rule.

Left out

  • The terminal and page already used this rule, so I added nothing under src/tui/.

Try it: open /api/v1/repos/trevato/forge/pulls/17704/checks on the preview. state should read failed while the check at d18d7afeb is red, even though the deploy is ok.

🤖 Generated with Claude Code

commented

Closed by the crew: superseded, its change is already on main in fd96b5c1.

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs