Skip to content

Commit 93c30de

Browse files
authored
ci: restore timing summary artifact (#87832)
* ci: restore timing summary artifact * ci: report pnpm warmup fanout timing * ci: run timing summary from trusted base
1 parent 0006756 commit 93c30de

5 files changed

Lines changed: 257 additions & 11 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1960,3 +1960,53 @@ jobs:
19601960
exit 1
19611961
;;
19621962
esac
1963+
1964+
ci-timings-summary:
1965+
permissions:
1966+
actions: read
1967+
contents: read
1968+
name: ci-timings-summary
1969+
needs:
1970+
- preflight
1971+
- security-fast
1972+
- pnpm-store-warmup
1973+
- build-artifacts
1974+
- checks-fast-core
1975+
- checks-fast-plugin-contracts-shard
1976+
- checks-fast-channel-contracts-shard
1977+
- checks-node-compat
1978+
- checks-node-core-test-nondist-shard
1979+
- check-shard
1980+
- check-additional-shard
1981+
- check-docs
1982+
- skills-python
1983+
- checks-windows
1984+
- macos-node
1985+
- macos-swift
1986+
- android
1987+
if: ${{ !cancelled() && always() && (github.event_name != 'pull_request' || !github.event.pull_request.draft) }}
1988+
runs-on: ubuntu-24.04
1989+
timeout-minutes: 5
1990+
steps:
1991+
- name: Checkout timing summary helper
1992+
uses: actions/checkout@v6
1993+
with:
1994+
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || needs.preflight.outputs.checkout_revision || github.sha }}
1995+
fetch-depth: 1
1996+
fetch-tags: false
1997+
persist-credentials: false
1998+
submodules: false
1999+
2000+
- name: Write CI timing summary
2001+
env:
2002+
GH_TOKEN: ${{ github.token }}
2003+
run: |
2004+
node scripts/ci-run-timings.mjs "$GITHUB_RUN_ID" --limit 25 > ci-timings-summary.txt
2005+
cat ci-timings-summary.txt >> "$GITHUB_STEP_SUMMARY"
2006+
2007+
- name: Upload CI timing summary
2008+
uses: actions/upload-artifact@v7
2009+
with:
2010+
name: ci-timings-summary
2011+
path: ci-timings-summary.txt
2012+
retention-days: 14

‎docs/ci.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ OpenClaw CI runs on every push to `main` and every pull request. The `preflight`
4343

4444
GitHub may mark superseded jobs as `cancelled` when a newer push lands on the same PR or `main` ref. Treat that as CI noise unless the newest run for the same ref is also failing. Matrix jobs use `fail-fast: false`, and `build-artifacts` reports embedded channel, core-support-boundary, and gateway-watch failures directly instead of queuing tiny verifier jobs. The automatic CI concurrency key is versioned (`CI-v7-*`) so a GitHub-side zombie in an old queue group cannot indefinitely block newer main runs. Manual full-suite runs use `CI-manual-v1-*` and do not cancel in-progress runs.
4545

46-
Use `pnpm ci:timings`, `pnpm ci:timings:recent`, or `node scripts/ci-run-timings.mjs <run-id>` to summarize wall time, queue time, slowest jobs, and failures from GitHub Actions. For build timing, check the `build-artifacts` job's `Build dist` step: `pnpm build:ci-artifacts` prints `[build-all] phase timings:` and includes `ui:build`. The job also uploads the `startup-memory` artifact.
46+
Use `pnpm ci:timings`, `pnpm ci:timings:recent`, or `node scripts/ci-run-timings.mjs <run-id>` to summarize wall time, queue time, slowest jobs, failures, and the `pnpm-store-warmup` fanout barrier from GitHub Actions. CI also uploads the same run summary as a `ci-timings-summary` artifact. For build timing, check the `build-artifacts` job's `Build dist` step: `pnpm build:ci-artifacts` prints `[build-all] phase timings:` and includes `ui:build`; the job also uploads the `startup-memory` artifact.
47+
48+
For pull request runs, the terminal timing-summary job runs the helper from the trusted base revision before passing `GH_TOKEN` to `gh run view`. That keeps the tokened query out of branch-controlled code while still summarizing the pull request's current CI run.
4749

4850
## Real behavior proof
4951

‎scripts/ci-run-timings.mjs‎

Lines changed: 86 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,35 @@ function formatSeconds(value) {
1818
return value === null ? "" : `${value}s`;
1919
}
2020

21+
function percentile(values, percentileValue) {
22+
if (values.length === 0) {
23+
return null;
24+
}
25+
const sorted = [...values].toSorted((left, right) => left - right);
26+
const index = Math.min(sorted.length - 1, Math.ceil(sorted.length * percentileValue) - 1);
27+
return sorted[index];
28+
}
29+
2130
function parseRunList(raw) {
2231
const parsed = JSON.parse(raw);
2332
return Array.isArray(parsed) ? parsed : [];
2433
}
2534

35+
function isPnpmStoreWarmupGatedJobName(name) {
36+
return (
37+
name === "build-artifacts" ||
38+
name === "check-docs" ||
39+
name === "check-guards" ||
40+
name === "check-prod-types" ||
41+
name === "check-lint" ||
42+
name === "check-dependencies" ||
43+
name === "check-test-types" ||
44+
name.startsWith("check-additional-") ||
45+
name.startsWith("checks-fast-") ||
46+
(name.startsWith("checks-node-") && !name.startsWith("checks-node-compat-"))
47+
);
48+
}
49+
2650
function collectRunTimingContext(run) {
2751
const created = parseTime(run.createdAt);
2852
const updated = parseTime(run.updatedAt);
@@ -69,6 +93,46 @@ export function summarizeRunTimings(run, limit = 15) {
6993
};
7094
}
7195

96+
export function summarizePnpmStoreWarmupBarrier(run, windowSeconds = 5) {
97+
const { jobs } = collectRunTimingContext(run);
98+
const preflight = jobs.find((job) => job.name === "preflight");
99+
const warmup = jobs.find((job) => job.name === "pnpm-store-warmup");
100+
if (!warmup?.started || !warmup?.completed) {
101+
return null;
102+
}
103+
104+
const postWarmupJobs = jobs.filter(
105+
(job) =>
106+
job.name !== "preflight" &&
107+
job.name !== "security-fast" &&
108+
job.name !== "pnpm-store-warmup" &&
109+
isPnpmStoreWarmupGatedJobName(job.name) &&
110+
job.status === "completed" &&
111+
job.conclusion !== "skipped" &&
112+
job.started !== null &&
113+
job.started >= warmup.completed &&
114+
(job.durationSeconds ?? 0) > 5,
115+
);
116+
const startDelays = postWarmupJobs
117+
.map((job) => secondsBetween(warmup.completed, job.started))
118+
.filter((delay) => delay !== null);
119+
120+
return {
121+
activePostWarmupJobCount: postWarmupJobs.length,
122+
firstPostWarmupStartDelaySeconds: startDelays.length === 0 ? null : Math.min(...startDelays),
123+
postWarmupP95StartDelaySeconds: percentile(startDelays, 0.95),
124+
postWarmupStartedWithinWindow: startDelays.filter((delay) => delay <= windowSeconds).length,
125+
preflightToWarmupCompleteSeconds: secondsBetween(
126+
preflight?.completed ?? null,
127+
warmup.completed,
128+
),
129+
preflightToWarmupStartSeconds: secondsBetween(preflight?.completed ?? null, warmup.started),
130+
warmupDurationSeconds: secondsBetween(warmup.started, warmup.completed),
131+
warmupResult: `${warmup.status}/${warmup.conclusion}`,
132+
windowSeconds,
133+
};
134+
}
135+
72136
export function selectLatestMainPushCiRun(runs, headSha = null) {
73137
const pushRuns = runs.filter((run) => run.event === "push");
74138
if (headSha) {
@@ -193,15 +257,6 @@ function summarizeJobs(run) {
193257
};
194258
}
195259

196-
function percentile(values, percentileValue) {
197-
if (values.length === 0) {
198-
return null;
199-
}
200-
const sorted = [...values].toSorted((left, right) => left - right);
201-
const index = Math.min(sorted.length - 1, Math.ceil(sorted.length * percentileValue) - 1);
202-
return sorted[index];
203-
}
204-
205260
function printSection(title, jobs, metric) {
206261
console.log(title);
207262
for (const job of jobs) {
@@ -265,11 +320,32 @@ async function main() {
265320
return;
266321
}
267322
const runId = explicitRunId ?? (useLatestMain ? getLatestMainPushCiRunId() : getLatestCiRunId());
268-
const summary = summarizeRunTimings(loadRun(runId), limit);
323+
const run = loadRun(runId);
324+
const summary = summarizeRunTimings(run, limit);
325+
const warmupBarrier = summarizePnpmStoreWarmupBarrier(run);
269326

270327
console.log(
271328
`CI run ${runId}: ${summary.status}/${summary.conclusion} wall=${formatSeconds(summary.wallSeconds)}`,
272329
);
330+
if (warmupBarrier) {
331+
console.log("\npnpm-store-warmup barrier");
332+
console.log(
333+
[
334+
`result=${warmupBarrier.warmupResult}`,
335+
`preflight->start=${formatSeconds(warmupBarrier.preflightToWarmupStartSeconds)}`,
336+
`duration=${formatSeconds(warmupBarrier.warmupDurationSeconds)}`,
337+
`preflight->complete=${formatSeconds(warmupBarrier.preflightToWarmupCompleteSeconds)}`,
338+
].join(" "),
339+
);
340+
console.log(
341+
[
342+
`active-post-warmup-jobs=${warmupBarrier.activePostWarmupJobCount}`,
343+
`first-start-delay=${formatSeconds(warmupBarrier.firstPostWarmupStartDelaySeconds)}`,
344+
`p95-start-delay=${formatSeconds(warmupBarrier.postWarmupP95StartDelaySeconds)}`,
345+
`started-within-${warmupBarrier.windowSeconds}s=${warmupBarrier.postWarmupStartedWithinWindow}`,
346+
].join(" "),
347+
);
348+
}
273349
printSection("\nSlowest jobs", summary.byDuration, "durationSeconds");
274350
printSection("\nLongest queues", summary.byQueue, "queueSeconds");
275351
if (summary.badJobs.length > 0) {

‎test/scripts/ci-run-timings.test.ts‎

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { describe, expect, it } from "vitest";
22
import {
33
parseRunTimingArgs,
44
selectLatestMainPushCiRun,
5+
summarizePnpmStoreWarmupBarrier,
56
summarizeRunTimings,
67
} from "../../scripts/ci-run-timings.mjs";
78

@@ -80,6 +81,71 @@ describe("scripts/ci-run-timings.mjs", () => {
8081
});
8182
});
8283

84+
it("summarizes the pnpm store warmup fanout barrier", () => {
85+
expect(
86+
summarizePnpmStoreWarmupBarrier({
87+
conclusion: "success",
88+
createdAt: "2026-05-28T23:03:01Z",
89+
jobs: [
90+
{
91+
completedAt: "2026-05-28T23:04:05Z",
92+
conclusion: "success",
93+
name: "preflight",
94+
startedAt: "2026-05-28T23:03:55Z",
95+
status: "completed",
96+
},
97+
{
98+
completedAt: "2026-05-28T23:04:27Z",
99+
conclusion: "success",
100+
name: "pnpm-store-warmup",
101+
startedAt: "2026-05-28T23:04:07Z",
102+
status: "completed",
103+
},
104+
{
105+
completedAt: "2026-05-28T23:06:26Z",
106+
conclusion: "success",
107+
name: "checks-fast-bundled-protocol",
108+
startedAt: "2026-05-28T23:04:29Z",
109+
status: "completed",
110+
},
111+
{
112+
completedAt: "2026-05-28T23:04:28Z",
113+
conclusion: "skipped",
114+
name: "check-docs",
115+
startedAt: "2026-05-28T23:04:28Z",
116+
status: "completed",
117+
},
118+
{
119+
completedAt: "2026-05-28T23:04:35Z",
120+
conclusion: "success",
121+
name: "security-fast",
122+
startedAt: "2026-05-28T23:03:55Z",
123+
status: "completed",
124+
},
125+
{
126+
completedAt: "2026-05-28T23:05:30Z",
127+
conclusion: "success",
128+
name: "checks-node-compat-node22",
129+
startedAt: "2026-05-28T23:04:30Z",
130+
status: "completed",
131+
},
132+
],
133+
status: "completed",
134+
updatedAt: "2026-05-28T23:07:33Z",
135+
}),
136+
).toEqual({
137+
activePostWarmupJobCount: 1,
138+
firstPostWarmupStartDelaySeconds: 2,
139+
postWarmupP95StartDelaySeconds: 2,
140+
postWarmupStartedWithinWindow: 1,
141+
preflightToWarmupCompleteSeconds: 22,
142+
preflightToWarmupStartSeconds: 2,
143+
warmupDurationSeconds: 20,
144+
warmupResult: "completed/success",
145+
windowSeconds: 5,
146+
});
147+
});
148+
83149
it("falls back to the newest push CI run when the exact SHA has not appeared yet", () => {
84150
expect(
85151
selectLatestMainPushCiRun(

‎test/scripts/ci-workflow-guards.test.ts‎

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,58 @@ describe("ci workflow guards", () => {
4747
expect(buildArtifactSteps.some((step) => step.run === "pnpm ui:build")).toBe(false);
4848
});
4949

50+
it("uploads a CI timing summary after the run lanes finish", () => {
51+
const workflow = readCiWorkflow();
52+
const timingJob = workflow.jobs["ci-timings-summary"];
53+
54+
expect(timingJob.permissions).toMatchObject({ actions: "read", contents: "read" });
55+
expect(timingJob.needs).toEqual([
56+
"preflight",
57+
"security-fast",
58+
"pnpm-store-warmup",
59+
"build-artifacts",
60+
"checks-fast-core",
61+
"checks-fast-plugin-contracts-shard",
62+
"checks-fast-channel-contracts-shard",
63+
"checks-node-compat",
64+
"checks-node-core-test-nondist-shard",
65+
"check-shard",
66+
"check-additional-shard",
67+
"check-docs",
68+
"skills-python",
69+
"checks-windows",
70+
"macos-node",
71+
"macos-swift",
72+
"android",
73+
]);
74+
expect(timingJob.if).toContain("always()");
75+
expect(timingJob.if).toContain("!cancelled()");
76+
77+
const checkoutStep = timingJob.steps.find(
78+
(step) => step.name === "Checkout timing summary helper",
79+
);
80+
expect(checkoutStep.uses).toBe("actions/checkout@v6");
81+
expect(checkoutStep.with.ref).toBe(
82+
"${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || needs.preflight.outputs.checkout_revision || github.sha }}",
83+
);
84+
expect(checkoutStep.with["persist-credentials"]).toBe(false);
85+
86+
const writeStep = timingJob.steps.find((step) => step.name === "Write CI timing summary");
87+
expect(writeStep.env).toMatchObject({ GH_TOKEN: "${{ github.token }}" });
88+
expect(writeStep.run).toContain(
89+
'node scripts/ci-run-timings.mjs "$GITHUB_RUN_ID" --limit 25 > ci-timings-summary.txt',
90+
);
91+
expect(writeStep.run).toContain('cat ci-timings-summary.txt >> "$GITHUB_STEP_SUMMARY"');
92+
93+
const uploadStep = timingJob.steps.find((step) => step.name === "Upload CI timing summary");
94+
expect(uploadStep.uses).toBe("actions/upload-artifact@v7");
95+
expect(uploadStep.with).toMatchObject({
96+
name: "ci-timings-summary",
97+
path: "ci-timings-summary.txt",
98+
"retention-days": 14,
99+
});
100+
});
101+
50102
it("keeps push docs validation ClawHub-backed", () => {
51103
const workflow = readFileSync(".github/workflows/docs.yml", "utf8");
52104

0 commit comments

Comments
 (0)