-
Notifications
You must be signed in to change notification settings - Fork 5k
ci(build): keep waiting for build-cpp while a retry is queued instead of bailing on a stale errored outcome #36339
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
robobun
wants to merge
6
commits into
main
Choose a base branch
from
farm/de87bcd2/ci-wait-for-sibling-retry
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+197
−30
Open
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
49c95e4
ci(build): keep waiting for build-cpp while a retry is queued instead…
robobun c17ae1a
[autofix.ci] apply automated fixes
autofix-ci[bot] a38ab92
preserve the spawn-error fast-fail in get()
robobun 84d7a4c
use bunExe() in the fake-agent stub instead of system node
robobun fd8b149
use the step-state vocabulary (ready/running/finished) for the retry …
robobun 3897ad1
treat a failed state read as non-terminal; name stepKey/attr in the s…
robobun File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| /** | ||
| * Unit tests for the build-bun → build-cpp sibling poll in | ||
| * scripts/build/ci.ts::waitForStepOutcome(). | ||
| * | ||
| * Buildkite's `step get outcome` reports the last *completed* job, so an | ||
| * earlier attempt that expired in the queue reads as `errored` even while a | ||
| * retry is queued or running. The poll must consult `step get state` (the | ||
| * step-level state: `ready`/`running`/`failing`/`finished`/…) and only give up | ||
| * once that is terminal too. Build 85043's linux-aarch64-build-bun logged | ||
| * `state=running` → `state=finished`, which is the vocabulary these fixtures | ||
| * use. | ||
| */ | ||
| import { describe, expect, test } from "bun:test"; | ||
| import { waitForStepOutcome, type StepGetResult } from "../../scripts/build/ci.ts"; | ||
|
|
||
| /** Drive `waitForStepOutcome` through a canned sequence of `outcome`/`state` reads. */ | ||
| function run(script: ReadonlyArray<{ outcome: string; state: string } | { ok: false; err: string }>) { | ||
| let i = 0; | ||
| const get = (_stepKey: string, attr: string): StepGetResult => { | ||
| const entry = script[Math.min(i, script.length - 1)]!; | ||
| // One poll = outcome then state; advance on state so both reads see the same entry. | ||
| if (attr === "state") i++; | ||
| if ("ok" in entry) { | ||
| // A transient agent failure: the poll retries without reading `state`. | ||
| if (attr === "outcome") i++; | ||
| return { ok: false, out: "", err: entry.err }; | ||
| } | ||
| return { ok: true, out: entry[attr as "outcome" | "state"], err: "" }; | ||
| }; | ||
| return waitForStepOutcome("linux-x64-build-cpp", { pollMs: 0, get }); | ||
| } | ||
|
|
||
| describe.concurrent("waitForStepOutcome", () => { | ||
| test("resolves once the sibling passes", async () => { | ||
| await run([ | ||
| { outcome: "", state: "running" }, | ||
| { outcome: "passed", state: "finished" }, | ||
| ]); | ||
| }); | ||
|
|
||
| test("keeps polling while a retry is queued after an earlier error", async () => { | ||
| // Build 84838: attempt 1 expired (outcome=errored), attempt 2 sat in the | ||
| // queue. The old outcome-only poll bailed at index 0. | ||
| await run([ | ||
| { outcome: "errored", state: "ready" }, | ||
| { outcome: "errored", state: "ready" }, | ||
| { outcome: "errored", state: "running" }, | ||
| { outcome: "passed", state: "finished" }, | ||
| ]); | ||
| }); | ||
|
|
||
| test("keeps polling through state=failing", async () => { | ||
| // `failing` is a documented non-terminal step state (a job failed but the | ||
| // step has not settled); a retry can still turn it around. | ||
| await run([ | ||
| { outcome: "errored", state: "failing" }, | ||
| { outcome: "errored", state: "failing" }, | ||
| { outcome: "errored", state: "running" }, | ||
| { outcome: "passed", state: "finished" }, | ||
| ]); | ||
| }); | ||
|
|
||
| test("keeps polling through an unknown state value", async () => { | ||
| // A state we have not enumerated must not be mistaken for terminal; the | ||
| // 60 min deadline still bounds the wait. | ||
| await run([ | ||
| { outcome: "errored", state: "limiting" }, | ||
| { outcome: "errored", state: "limiting" }, | ||
| { outcome: "passed", state: "finished" }, | ||
| ]); | ||
| }); | ||
|
|
||
| test("tolerates the gap between one attempt finishing and its retry appearing", async () => { | ||
| // A retry job is created ~1s after its predecessor ends, so one poll can | ||
| // land on state=finished before the next attempt takes it back to ready. | ||
| await run([ | ||
| { outcome: "errored", state: "finished" }, | ||
| { outcome: "errored", state: "ready" }, | ||
| { outcome: "passed", state: "finished" }, | ||
| ]); | ||
| }); | ||
|
|
||
| test("throws once the sibling is terminally failed with no retry in flight", async () => { | ||
| await expect( | ||
| run([ | ||
| { outcome: "hard_failed", state: "finished" }, | ||
| { outcome: "hard_failed", state: "finished" }, | ||
| ]), | ||
| ).rejects.toThrow("linux-x64-build-cpp hard_failed"); | ||
| }); | ||
|
|
||
| test("falls back to outcome when state is unavailable", async () => { | ||
| // An empty/unavailable state must not mask a real failure. | ||
| await expect( | ||
| run([ | ||
| { outcome: "errored", state: "" }, | ||
| { outcome: "errored", state: "" }, | ||
| ]), | ||
| ).rejects.toThrow("linux-x64-build-cpp errored"); | ||
| }); | ||
|
|
||
| test("retries a transient agent error", async () => { | ||
| await run([ | ||
| { ok: false, err: "transient 502" }, | ||
| { outcome: "passed", state: "finished" }, | ||
| ]); | ||
| }); | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.