# Stop a branch check when a pull request is opened while it runs #679

Closed
opened 2026-11-13 16:30:02 +01:00 by simon · 0 comments
Owner

Problem

check-branch asks once, in its first step (skip, ci/skip-check.exs open-pr), whether the branch has an open pull request. When the pull request is opened a minute after the push, which is the usual order, the branch check has already passed that step and runs in full beside the check-pr build of the same commit.

Seen on 2026-11-13: push to issue/mitgliederverwaltung-541 at 11:20 (build 3048), pull request #677 opened at 11:21 (build 3049). Both ran the complete check at the same time on the one runner (4 CPUs, 3.8 GiB RAM) and both took clearly longer than a single run. Only the pull request build counts: its status is the one branch protection requires.

Options that do not help:

  • Limiting the runner to one build at a time makes the pull request build wait for the branch build, so the required status arrives later.
  • Drone's auto-cancel acts on builds of the same event and ref; a push build (refs/heads/…) and a pull request build (refs/pull/…) are different refs (to be confirmed, not relied on).

Proposal

Ask the same question again right before the expensive part: the test step of check-branch first runs elixir ci/skip-check.exs open-pr … and ends the build early (exit 78) when a pull request is open by then. The test step starts after deps, roughly 2–3 minutes after the push, so a pull request opened within that window costs only the duplicated deps/lint/typecheck work, not a second test suite.

check-pr and check-main stay as they are. The script, its API read and its token-free access are unchanged, so the trust boundary does not move.

To check while building

  • What Drone does with steps that run in parallel (lint, typecheck) when test exits 78: are they stopped, or do they finish? If they finish, decide whether the second check also belongs in front of typecheck (Dialyzer is the second-largest step).
  • rebuild-cache depends on test; confirm it is skipped, so an early end never writes a half-built cache.
  • test/ci/drone_render_test.exs pins the test step command of check-branch (second skip check present, check-pr and check-main without it).

Acceptance criteria

  • A push followed by opening the pull request within about two minutes runs the test suite once (in check-pr), not twice; the branch build ends green with the "open pull request" message.
  • A push to a branch without a pull request runs the full check as before, with no noticeable extra time (the API read takes about a second).
  • Measured on two such push + pull request pairs: runner time of both builds together, against the 2026-11-13 pair (builds 3048 + 3049).
## Problem `check-branch` asks once, in its first step (`skip`, `ci/skip-check.exs open-pr`), whether the branch has an open pull request. When the pull request is opened a minute after the push, which is the usual order, the branch check has already passed that step and runs in full beside the `check-pr` build of the same commit. Seen on 2026-11-13: push to `issue/mitgliederverwaltung-541` at 11:20 (build 3048), pull request #677 opened at 11:21 (build 3049). Both ran the complete check at the same time on the one runner (4 CPUs, 3.8 GiB RAM) and both took clearly longer than a single run. Only the pull request build counts: its status is the one branch protection requires. Options that do not help: - Limiting the runner to one build at a time makes the pull request build wait for the branch build, so the required status arrives later. - Drone's auto-cancel acts on builds of the same event and ref; a push build (`refs/heads/…`) and a pull request build (`refs/pull/…`) are different refs (to be confirmed, not relied on). ## Proposal Ask the same question again right before the expensive part: the `test` step of `check-branch` first runs `elixir ci/skip-check.exs open-pr …` and ends the build early (exit 78) when a pull request is open by then. The test step starts after `deps`, roughly 2–3 minutes after the push, so a pull request opened within that window costs only the duplicated deps/lint/typecheck work, not a second test suite. `check-pr` and `check-main` stay as they are. The script, its API read and its token-free access are unchanged, so the trust boundary does not move. ## To check while building - What Drone does with steps that run in parallel (`lint`, `typecheck`) when `test` exits 78: are they stopped, or do they finish? If they finish, decide whether the second check also belongs in front of `typecheck` (Dialyzer is the second-largest step). - `rebuild-cache` depends on `test`; confirm it is skipped, so an early end never writes a half-built cache. - `test/ci/drone_render_test.exs` pins the `test` step command of `check-branch` (second skip check present, `check-pr` and `check-main` without it). ## Acceptance criteria - A push followed by opening the pull request within about two minutes runs the test suite once (in `check-pr`), not twice; the branch build ends green with the "open pull request" message. - A push to a branch without a pull request runs the full check as before, with no noticeable extra time (the API read takes about a second). - Measured on two such push + pull request pairs: runner time of both builds together, against the 2026-11-13 pair (builds 3048 + 3049).
simon closed this issue 2026-11-13 18:41:14 +01:00
Sign in to join this conversation.
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
local-it/mitgliederverwaltung#679
No description provided.