Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
16 changes: 16 additions & 0 deletions scripts/scorecard/coordinate-scorecard.mts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,22 @@ function renderSummaryLines(input: {
lines.push(job.url ? ` - [${job.name}](${job.url})` : ` - \`${job.name}\``);
}
}
if (summary.timingRows.length > 0) {
const duration = (milliseconds: number | null) =>
milliseconds === null ? "n/a" : `${(milliseconds / 1_000).toFixed(1)}s`;
lines.push(
"",
"### Runner wait vs execution",
"",
"| Job | Runner class | Outcome | Queue | Execution |",
"| --- | --- | --- | ---: | ---: |",
);
for (const row of summary.timingRows) {
lines.push(
`| ${row.name.replaceAll("|", "\\|")} | ${row.runnerClass} | ${row.outcome} | ${duration(row.queueMs)} | ${duration(row.executionMs)} |`,
);
}
}
if (input.perfect) lines.push("", "🎉 **All jobs passed!**");
lines.push(
"",
Expand Down
64 changes: 61 additions & 3 deletions scripts/scorecard/summarize-jobs.mts
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,37 @@
type ApiJob = {
completed_at?: string | null;
conclusion?: string | null;
created_at?: string | null;
html_url?: string | null;
labels?: string[] | null;
name: string;
run_attempt?: number | null;
started_at?: string | null;
status?: string | null;
};

type NeedResult = { result?: string };

type FailedJob = { name: string; url: string | null };

type CountedResult = "cancelled" | "failure" | "skipped" | "success";

export type JobTimingRow = {
executionMs: number | null;
name: string;
outcome: CountedResult;
queueMs: number | null;
runnerClass: "larger" | "standard" | "unknown";
};

export type JobSummary = {
cancelled: number;
failedJobs: FailedJob[];
failure: number;
ran: number;
skipped: number;
success: number;
timingRows: JobTimingRow[];
total: number;
};

Expand All @@ -44,8 +58,6 @@ export type WorkflowRunJobsDeps = {
};
};

type CountedResult = "cancelled" | "failure" | "skipped" | "success";

function isSelectiveDispatch(eventName: string, rawJobs = "", rawTargets = ""): boolean {
return eventName === "workflow_dispatch" && (rawJobs.trim() !== "" || rawTargets.trim() !== "");
}
Expand All @@ -66,7 +78,9 @@ function classifyNeed(value: NeedResult): CountedResult {
return "failure";
}

function countResults(results: CountedResult[]): Omit<JobSummary, "failedJobs" | "ran" | "total"> {
function countResults(
results: CountedResult[],
): Omit<JobSummary, "failedJobs" | "ran" | "timingRows" | "total"> {
return {
cancelled: results.filter((result) => result === "cancelled").length,
failure: results.filter((result) => result === "failure").length,
Expand All @@ -75,6 +89,48 @@ function countResults(results: CountedResult[]): Omit<JobSummary, "failedJobs" |
};
}

function elapsedMs(
start: string | null | undefined,
finish: string | null | undefined,
): number | null {
if (!start || !finish) return null;
const startMs = Date.parse(start);
const finishMs = Date.parse(finish);
if (!Number.isFinite(startMs) || !Number.isFinite(finishMs) || finishMs < startMs) return null;
return finishMs - startMs;
}

function normalizeRunnerClass(
labels: string[] | null | undefined,
): JobTimingRow["runnerClass"] {
if (!labels || labels.length === 0) return "unknown";
const normalized = new Set(labels.map((label) => label.toLowerCase()));
if (normalized.has("ubuntu-latest")) return "standard";
if (normalized.has("self-hosted")) return "unknown";
return "larger";
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
}

function summarizeJobTimings(jobs: ApiJob[]): JobTimingRow[] {
return jobs
.map(
(job): JobTimingRow => ({
executionMs: elapsedMs(job.started_at, job.completed_at),
name: job.name,
outcome: classifyApiJob(job),
queueMs: elapsedMs(job.created_at, job.started_at),
runnerClass: normalizeRunnerClass(job.labels),
}),
)
.filter((row) => row.executionMs !== null || row.queueMs !== null)
.sort(
(left, right) =>
(right.executionMs ?? 0) +
(right.queueMs ?? 0) -
((left.executionMs ?? 0) + (left.queueMs ?? 0)) || left.name.localeCompare(right.name),
)
.slice(0, 10);
}

function preferCandidate(candidate: ApiJob, existing: ApiJob | undefined): boolean {
if (!existing) return true;
const candidateAttempt = candidate.run_attempt ?? 0;
Expand Down Expand Up @@ -142,6 +198,7 @@ function summarizeJobs(input: SummarizeJobsInput): JobSummary {
.filter(({ result }) => result === "failure")
.map(({ job }) => ({ name: job.name, url: job.html_url ?? null })),
ran: jobs.length - counts.skipped,
timingRows: summarizeJobTimings(jobs),
total: jobs.length,
};
}
Expand All @@ -158,6 +215,7 @@ function summarizeJobs(input: SummarizeJobsInput): JobSummary {
.filter(({ result }) => result === "failure")
.map(({ name }) => ({ name, url: null })),
ran: entries.length - counts.skipped,
timingRows: [],
total: entries.length,
};
}
Expand Down
13 changes: 9 additions & 4 deletions test/e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,15 @@ graph as the live targets:
retired. Any future issue escalation should use a separately reviewed
exceptional threshold, such as the same lane failing twice consecutively or
remaining broken for 24 hours, rather than posting on every failed schedule.
- `scorecard` writes the scheduled/manual result summary, adds this run's
semantic phase runtime table, compares the trusted cloud-onboard timing
summary with the latest prior-release `e2e.yaml` run, and posts to the daily
or full-run Slack route.
- `scorecard` writes the scheduled/manual result summary and posts it to the
daily or full-run Slack route. The summary:
- separates queue time from execution time for the ten jobs with the longest
combined duration;
- reports the runner class as `standard`, `larger`, or `unknown` without
exposing runner labels;
- adds this run's semantic phase runtime table; and
- compares the trusted cloud-onboard timing summary with the latest
prior-release `e2e.yaml` run.
- Selective dispatches remain silent unless they run on `main` with
`post_to_slack=true`, which uses the preview Slack route. Branch-dispatched
runs never receive Slack webhook secrets.
Expand Down
65 changes: 65 additions & 0 deletions test/e2e/support/e2e-scorecard-coordinator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,71 @@ describe("scorecard coordinator assembly", () => {
expect(scorecardData).toMatchObject({ total: 2, success: 1, failure: 1, perfect: false });
expect(scorecardData.failedJobs).toEqual([{ name: "hermes-slack", url: null }]);
});

it("separates runner queue time from execution time without exposing runner labels", () => {
const { summaryMarkdown } = coordinator.buildScorecard(
coordinatorInput({
apiJobs: [
{
completed_at: "2026-07-24T00:01:30Z",
conclusion: "failure",
created_at: "2026-07-24T00:00:00Z",
labels: ["private-larger-runner-label"],
name: "mcp-bridge",
started_at: "2026-07-24T00:00:30Z",
status: "completed",
},
{
completed_at: "2026-07-24T00:00:25Z",
conclusion: "success",
created_at: "2026-07-24T00:00:00Z",
labels: ["ubuntu-latest"],
name: "cloud-onboard",
started_at: "2026-07-24T00:00:05Z",
status: "completed",
},
{
completed_at: "2026-07-24T00:00:20Z",
conclusion: "success",
created_at: "invalid",
labels: ["self-hosted", "Linux"],
name: "jetson-nvmap-gpu",
started_at: "2026-07-24T00:00:10Z",
status: "completed",
},
],
rawExplicitOnly: "jetson-nvmap-gpu",
rawJobs: "jetson-nvmap-gpu",
}),
);

expect(summaryMarkdown).toContain("### Runner wait vs execution");
expect(summaryMarkdown).toContain("| mcp-bridge | larger | failure | 30.0s | 60.0s |");
expect(summaryMarkdown).toContain("| cloud-onboard | standard | success | 5.0s | 20.0s |");
expect(summaryMarkdown).toContain("| jetson-nvmap-gpu | unknown | success | n/a | 10.0s |");
expect(summaryMarkdown).not.toContain("private-larger-runner-label");
});

it("bounds the job timing table to the ten slowest rows", () => {
const { summaryMarkdown } = coordinator.buildScorecard(
coordinatorInput({
apiJobs: Array.from({ length: 12 }, (_, index) => ({
completed_at: new Date(Date.UTC(2026, 6, 24, 0, 0, index + 1)).toISOString(),
conclusion: "success",
created_at: "2026-07-24T00:00:00.000Z",
labels: ["ubuntu-latest"],
name: `job-${String(index + 1).padStart(2, "0")}`,
started_at: "2026-07-24T00:00:00.000Z",
status: "completed",
})),
}),
);

expect(summaryMarkdown).toContain("| job-12 | standard | success | 0.0s | 12.0s |");
expect(summaryMarkdown).toContain("| job-03 | standard | success | 0.0s | 3.0s |");
expect(summaryMarkdown).not.toContain("| job-02 |");
expect(summaryMarkdown).not.toContain("| job-01 |");
});
});

describe("scorecard coordinator Slack payload guard", () => {
Expand Down
2 changes: 2 additions & 0 deletions test/e2e/support/e2e-scorecard.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,7 @@ describe("E2E scorecard", () => {
ran: 4,
skipped: 0,
success: 3,
timingRows: [],
total: 4,
});
});
Expand Down Expand Up @@ -501,6 +502,7 @@ describe("E2E scorecard", () => {
ran: 2,
skipped: 1,
success: 1,
timingRows: [],
total: 3,
});
});
Expand Down
Loading