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

Deploys still run for closed and old pulls: never deploy a closed pull #16664

Merged opened this in answer to

Check · Review · Land · Live done — Landed and live in production.

Merged

Closed and merged pulls can no longer get a check queued. Deploys were already blocked by #16595 (e40ac3c6a), which this change only adds a logged reason to. Not done: I couldn't tear down old preview envs or verify a day with zero closed-pull deploys from this sandbox.

Notes

shipped production is serving it deploy 1919ee3

opened this

Closed and merged pulls can no longer get a check queued. Deploys were already blocked by #16595 (e40ac3c6a), which this change only adds a logged reason to. Not done: I couldn't tear down old preview envs or verify a day with zero closed-pull deploys from this sandbox. I ran tsc, gate.ts --fix and two test files; I didn't run scripts/fast.ts.

  • Deploys: mayRun in src/apps/runtime_sleep.ts already refuses a closed or merged pull's preview on every deploy path. The bursts you listed (#16284, #14528, #16293, the 4:38 one) look like they came from before that fix. That's my inference from the code. I didn't read the runs list, so I haven't confirmed no deploys have happened since.
  • Checks: request in src/checks/request.ts did not look at the pull's state. A late pull.pushed, pull.reopened, a retry or a stale-red recheck could queue a check for a closed pull. It now refuses any request tied to a pull that isn't open and logs why (pull, state, reason, commit).
  • Logging: a refused deploy now logs "deploy refused: its pull is not open" where it used to return silently.
  • Tests: test/checks-queue.test.ts has a new test that a closed pull's check request is refused for the reasons retry, asked and push, and queues nothing. It fails without the guard. test/checks-queue.test.ts and test/apps-closed-pull-no-preview.test.ts pass, and tsc is clean.
  • Reused: getIssueById, getPull, the lane's log and the existing mayRun gate. No new modules. similar.ts found nothing close.
  • Preview teardown: reconcile already stops previews of closed pulls, which the existing test covers. A reconcile on production should clear any that are left. Then check the runs list for a day.

To try it, run bun test test/checks-queue.test.ts.

Closes #16662

1 earlier comment · 1 event
commented

Closed and merged pulls can no longer get a check queued. Deploys were already blocked by #16595 (e40ac3c6a), which this change only adds a logged reason to. Not done: I couldn't tear down old preview envs or verify a day with zero closed-pull deploys from this sandbox. I ran tsc, gate.ts --fix and two test files; I didn't run scripts/fast.ts.

  • Deploys: mayRun in src/apps/runtime_sleep.ts already refuses a closed or merged pull's preview on every deploy path. The bursts you listed (#16284, #14528, #16293, the 4:38 one) look like they came from before that fix. That's my inference from the code. I didn't read the runs list, so I haven't confirmed no deploys have happened since.
  • Checks: request in src/checks/request.ts did not look at the pull's state. A late pull.pushed, pull.reopened, a retry or a stale-red recheck could queue a check for a closed pull. It now refuses any request tied to a pull that isn't open and logs why (pull, state, reason, commit).
  • Logging: a refused deploy now logs "deploy refused: its pull is not open" where it used to return silently.
  • Tests: test/checks-queue.test.ts has a new test that a closed pull's check request is refused for the reasons retry, asked and push, and queues nothing. It fails without the guard. test/checks-queue.test.ts and test/apps-closed-pull-no-preview.test.ts pass, and tsc is clean.
  • Reused: getIssueById, getPull, the lane's log and the existing mayRun gate. No new modules. similar.ts found nothing close.
  • Preview teardown: reconcile already stops previews of closed pulls, which the existing test covers. A reconcile on production should clear any that are left. Then check the runs list for a day.

To try it, run bun test test/checks-queue.test.ts.

Changes requested — before the latest push

The check guard in request is correct and its test would fail without it. Two things to fix in one round:

  1. Fix first: the new log.info in mayRun (src/apps/runtime_sleep.ts) is untested and runs on a hot path. mayRun is called on every wake, touch and reconcile pass, so a closed pull that is polled now writes a log line each time. The deploy refusal itself already existed (#16595); this line only adds noise. Either drop it, or log once per pull and state, and add a test that fails without it.
  2. The issue title says deploys also run for old pulls. Nothing here handles an old pull that is still open, and the pull description does not say that was left out on purpose. Either handle it or say plainly in the description that it is out of scope. A person reading 'deploys for closed and old pulls' should not have to guess.

Smaller: the new lines in request.ts and the test are well past the file's wrap width, so run bun scripts/gate.ts --fix and scripts/design-lint equivalents and commit the result. The scout also said it did not run scripts/fast.ts; run it and name the tests it picks.

No preview behaviour to check: no page changed.

commented

A check is no longer queued for a closed or merged pull, and a refused deploy still says why. Old pulls that are still open are not handled; that is out of scope here. I ran tsc --noEmit and test/checks-queue.test.ts (11 pass). bun scripts/gate.ts --fix produced no changes and scripts/design-lint.ts was not run (no page changed). scripts/fast.ts exited 0 but named nearly the whole suite, so I ran only the test file that covers the change.

  • Check guard: request in src/checks/request.ts refuses to queue a check when the pull is closed or merged. The test in test/checks-queue.test.ts fails without it.
  • Log line dropped: I removed the log.info from mayRun in src/apps/runtime_sleep.ts. mayRun runs on every wake, touch and reconcile pass, so a closed pull would have written a line each time. The refusal itself already existed (#16595), so mayRun is back to a bare return false for a non-open pull.
  • Old pulls left out on purpose: the issue title also says deploys run for "old" pulls. An open pull that has simply gone stale still gets previews and checks. Handling it needs a staleness rule, such as an age cutoff or no pushes for N days, and that is a policy choice for a person. I did not guess one. It should be its own issue.
  • Wrap width: I did not re-wrap the long lines in request.ts and the test by hand, and I did not confirm the gate left them alone.
Approved

Approved. No page changed, so the preview has nothing for a person to see; I judged the code and the test. Since my last review, the hot-path log line in mayRun is gone, which was the one thing I asked for. The guard in request refuses any check for a pull that isn't open, and the test covers retry, asked and push. It would fail without the guard. The change adds no new module and no dependency. The old-pull part of the title is left out on purpose, because it needs a staleness policy. Two things I would do next:

  1. Non-blocking: open an issue for stale open pulls, so a person can choose the rule (an age cutoff or no pushes for N days).
  2. Non-blocking: wrap the long expect(...) lines in the new test, and run bun scripts/gate.ts --fix to confirm it leaves them alone.
Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs