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
9 changes: 5 additions & 4 deletions actions/setup/js/push_routing_history.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -345,10 +345,11 @@ async function listRuns({ githubClient, owner, repo, workflowFile, defaultBranch
const jobs = await githubClient.paginate(githubClient.rest.actions.listJobsForWorkflowRunAttempt, { owner, repo, run_id: run.id, attempt_number: 1, per_page: 100 });
listed.agent_ran = jobs.some((/** @type {any} */ job) => job?.name === "agent" && job.conclusion !== "skipped" && Boolean(job.started_at));
const writer = jobs.find((/** @type {any} */ job) => job?.name === WRITER_JOB);
// Nothing is owed by a run compiled while adaptive routing was off (no history job), a dry run
// (job disabled though the agent ran), or a run whose job succeeded: it saved the run, or
// declined it, as for a pull request into another branch.
if (!writer || writer.conclusion === "success" || (writer.conclusion === "skipped" && listed.agent_ran)) continue;
// A run that failed before any job was created (jobs.length === 0) is recorded as no_agent.
// When jobs exist, nothing is owed by a run compiled while adaptive routing was off (no
// history job), a dry run (job disabled though the agent ran), or a run whose job succeeded:
// it saved the run, or declined it, as for a pull request into another branch.
if (jobs.length > 0 && (!writer || writer.conclusion === "success" || (writer.conclusion === "skipped" && listed.agent_ran))) continue;
Comment thread
rabeckett marked this conversation as resolved.
Resolved
}
listing.push(listed);
}
Expand Down
24 changes: 24 additions & 0 deletions actions/setup/js/push_routing_history.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,30 @@ describe("push_routing_history saves", () => {
expect(remoteState(remote).unexplained).toBe(0);
});

it("records zero-job startup failures as no_agent without charging unexplained, while ignoring pre-opt-in runs", async () => {
Comment thread
rabeckett marked this conversation as resolved.
Resolved
const remote = bareRemote();
await save(remote, 50, "success");
const run = (number, conclusion = "failure") => ({ id: 9000 + number, run_number: number, status: "completed", conclusion, head_branch: "main", event: "schedule", run_attempt: 1 });
const agent = { name: "agent", conclusion: "failure", started_at: "2026-11-24T09:00:00Z" };
const runs = [run(53, "startup_failure"), run(52, "failure"), run(51, "failure")];
const jobs = { 9051: [agent], 9052: [], 9053: [] };
const github = fakeGitHub(remote, { runs, jobs });
await save(remote, 54, "success", { github });

expect(remoteRuns(remote).map(({ number, attempt, outcome, note, counted }) => ({ number, attempt, outcome, note, counted }))).toEqual([
{ number: 50, attempt: 1, outcome: "success", note: null, counted: true },
{ number: 52, attempt: 1, outcome: null, note: "no_agent", counted: false },
{ number: 53, attempt: 1, outcome: null, note: "no_agent", counted: false },
{ number: 54, attempt: 1, outcome: "success", note: null, counted: true },
]);
expect(remoteState(remote).unexplained).toBe(0);

// Once recorded as no_agent, subsequent saves do not re-query their jobs.
const nextGitHub = fakeGitHub(remote, { runs, jobs });
await save(remote, 55, "success", { github: nextGitHub });
expect(nextGitHub.calls.jobs).toEqual([9051]);
});

it("charges a failed save from a pull_request_target run, and never a run whose history job succeeded", async () => {
const remote = bareRemote();
await save(remote, 50, "success");
Expand Down
Loading