Repository navigation
ci: report benchmark and bundle-size impact on pull requests - #1500
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
Autofix Details
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Green headline hides failed base
- A base-commit suite failure is now added to flagged, so the sticky comment headline warns instead of printing the all-clear when that suite was not compared.
Or push these changes by commenting:
@cursor push ce9f5eea3a
Preview (ce9f5eea3a)
diff --git a/benchmarks/pr-report.mjs b/benchmarks/pr-report.mjs
--- a/benchmarks/pr-report.mjs
+++ b/benchmarks/pr-report.mjs
@@ -150,6 +150,7 @@
continue;
}
if (baseFailure) {
+ flagged.push(`⚠️ ${suite} failed on the base commit`);
sections.push(
'⚠️ The suite failed on the base commit, so there is nothing to compare.',
'',
diff --git a/benchmarks/pr-report.test.mjs b/benchmarks/pr-report.test.mjs
--- a/benchmarks/pr-report.test.mjs
+++ b/benchmarks/pr-report.test.mjs
@@ -57,6 +57,26 @@
assert.match(body, /void-root lost/);
});
+test('a base-commit suite failure is part of the headline', () => {
+ const ok = suite('bundle-size', [{ name: 'octane-tsrx', ops: { js_gzip: bytes(1000) } }]);
+ const body = renderReport({
+ suites: ['js-framework', 'bundle-size'],
+ base: {
+ 'js-framework': { ...suite('js-framework', []), failed: 'base runner died' },
+ 'bundle-size': ok,
+ },
+ head: {
+ 'js-framework': suite('js-framework', [
+ { name: 'octane-tsrx', ops: { run: timed(10, 9, 2) } },
+ ]),
+ 'bundle-size': ok,
+ },
+ });
+ assert.match(body, /⚠️ js-framework failed on the base commit/);
+ assert.match(body, /base runner died/);
+ assert.doesNotMatch(body, /🟢 No size increases and no timing regressions outside noise\./);
+});
+
test('an unchanged pull request reports no regressions', () => {
const results = {
'bundle-size': suite('bundle-size', [{ name: 'octane-tsrx', ops: { js_gzip: bytes(1000) } }]),You can send follow-ups to the cloud agent here.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
Autofix Details
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Failed round silently dropped
- A js-framework round that dies before writing JSON is now recorded as a failed result and fails the merged suite, so the surviving round is not compared alone and a base-round crash cannot produce a green headline.
Or push these changes by commenting:
@cursor push e394732210
Preview (e394732210)
diff --git a/.github/workflows/pr-bench.yml b/.github/workflows/pr-bench.yml
--- a/.github/workflows/pr-bench.yml
+++ b/.github/workflows/pr-bench.yml
@@ -89,9 +89,19 @@
side=${round%%:*}
tree=$GITHUB_WORKSPACE
if [ "$side" = base ]; then tree=$BASE_TREE; fi
- if (cd "$tree" && node benchmarks/bench.mjs --results-dir="$RESULTS/$side-js-${round##*:}" js-framework); then :
- elif [ "$side" = head ]; then status=1
- else echo "::warning::base js-framework round failed"; fi
+ dir="$RESULTS/$side-js-${round##*:}"
+ if (cd "$tree" && node benchmarks/bench.mjs --results-dir="$dir" js-framework); then :
+ else
+ # A throw before writeFileSync leaves no JSON, which the report
+ # cannot tell from the byte directory. Record the failed round.
+ if [ ! -f "$dir/js-framework.json" ]; then
+ mkdir -p "$dir"
+ name=${dir##*/}
+ printf '{"suite":"js-framework","iterations":null,"harnessExit":1,"failed":"js-framework failed before writing a result (%s)","targets":[]}\n' "$name" > "$dir/js-framework.json"
+ fi
+ if [ "$side" = head ]; then status=1
+ else echo "::warning::base js-framework round failed"; fi
+ fi
done
echo "status=$status" >> "$GITHUB_OUTPUT"
diff --git a/benchmarks/pr-report.mjs b/benchmarks/pr-report.mjs
--- a/benchmarks/pr-report.mjs
+++ b/benchmarks/pr-report.mjs
@@ -7,6 +7,9 @@
// Several directories per side are rounds of the same commit. CI measures
// js-framework base, head, head, base so linear runner drift cancels in each
// side's mean; disagreement between rounds widens the margin of error.
+// A directory that already holds a different suite is not a round of this one.
+// A round that died before writing JSON fails the merged suite, so the leftover
+// round is not compared on its own.
//
// Deterministic operations (bytes, DOM-operation and call counts) report every
// change exactly. A timing operation is only called faster or slower outside its
@@ -231,15 +234,27 @@
}
export function mergeRounds(rounds) {
+ const missing = rounds.filter((round) => !round).length;
const results = rounds.filter(Boolean);
- if (results.length <= 1) return results[0] ?? null;
- const failed = results.map((result) => failureOf(result)).filter(Boolean);
+ // A missing round is a crash before writeFileSync, not an empty slot. One
+ // survivor is not a balanced ABBA mean and must not be returned clean.
+ if (missing === 0 && results.length <= 1) return results[0] ?? null;
+ const failed = [
+ ...results.map((result) => failureOf(result)).filter(Boolean),
+ ...(missing === 0
+ ? []
+ : [
+ missing === 1
+ ? '1 round failed before writing a result'
+ : `${missing} rounds failed before writing a result`,
+ ]),
+ ];
const names = [
...new Set(results.flatMap((result) => result.targets.map((target) => target.name))),
];
return {
- suite: results[0].suite,
- iterations: results[0].iterations,
+ suite: results[0]?.suite ?? null,
+ iterations: results[0]?.iterations ?? null,
harnessExit: failed.length ? 1 : 0,
...(failed.length ? { failed: failed.join(' | ') } : null),
targets: names.map((name) => {
@@ -257,15 +272,40 @@
};
}
+function readRound(directory, suite) {
+ const file = path.join(directory, `${suite}.json`);
+ if (fs.existsSync(file)) return JSON.parse(fs.readFileSync(file, 'utf8'));
+ // Byte results and js-framework rounds share one directory list. A directory
+ // that published a different suite never ran this one.
+ const holdsOtherSuite = SUITES.some(
+ (name) => name !== suite && fs.existsSync(path.join(directory, `${name}.json`)),
+ );
+ if (holdsOtherSuite || !fs.existsSync(directory) || suite !== 'js-framework') return null;
+ // bench.mjs leaves build-*.log / server-*.log when startup throws before
+ // writeFileSync. Those files mark a js-framework round, not a byte suite.
+ const diedDuringStartup = fs
+ .readdirSync(directory)
+ .some((name) => name.startsWith('build-') || name.startsWith('server-'));
+ if (!diedDuringStartup) return null;
+ return {
+ suite,
+ iterations: null,
+ harnessExit: 1,
+ failed: `${suite} failed before writing a result (${path.basename(directory)})`,
+ targets: [],
+ };
+}
+
function readSuites(directories) {
return Object.fromEntries(
SUITES.map((suite) => [
suite,
mergeRounds(
- directories.split(',').map((directory) => {
- const file = path.join(directory, `${suite}.json`);
- return fs.existsSync(file) ? JSON.parse(fs.readFileSync(file, 'utf8')) : null;
- }),
+ directories
+ .split(',')
+ .filter(Boolean)
+ .map((directory) => readRound(directory, suite))
+ .filter((round) => round != null),
),
]),
);
diff --git a/benchmarks/pr-report.test.mjs b/benchmarks/pr-report.test.mjs
--- a/benchmarks/pr-report.test.mjs
+++ b/benchmarks/pr-report.test.mjs
@@ -1,7 +1,14 @@
import assert from 'node:assert/strict';
+import { spawnSync } from 'node:child_process';
+import fs from 'node:fs';
+import os from 'node:os';
+import path from 'node:path';
import { test } from 'node:test';
+import { fileURLToPath } from 'node:url';
import { COMMENT_MARKER, compareSuite, mergeRounds, renderReport } from './pr-report.mjs';
+const reportScript = path.join(path.dirname(fileURLToPath(import.meta.url)), 'pr-report.mjs');
+
const bytes = (value) => ({ median: value, min: value, samples: 1 });
const timed = (score, min, rme) => ({ score, median: score, min, rme, scoreRme: rme, samples: 8 });
const suite = (name, targets) => ({ suite: name, iterations: 1, harnessExit: 0, targets });
@@ -65,6 +72,20 @@
assert.equal(mergeRounds([ok, { ...ok, harnessExit: 1, failed: 'gate' }]).failed, 'gate');
});
+test('a missing round fails the merged suite instead of leaving the survivor', () => {
+ const ok = suite('js-framework', [{ name: 'octane-tsrx', ops: { run: timed(10, 9, 3) } }]);
+ const merged = mergeRounds([ok, null]);
+ assert.match(merged.failed, /1 round failed before writing a result/);
+ assert.equal(merged.harnessExit, 1);
+ const body = renderReport({
+ suites: ['js-framework'],
+ base: { 'js-framework': merged },
+ head: { 'js-framework': ok },
+ });
+ assert.match(body, /⚠️ js-framework failed on the base commit and was not compared/);
+ assert.doesNotMatch(body, /🟢 No size increases/);
+});
+
test('timing verdicts never turn the headline red', () => {
const base = {
'js-framework': suite('js-framework', [{ name: 'octane-tsrx', ops: { run: timed(10, 9, 2) } }]),
@@ -108,6 +129,88 @@
assert.doesNotMatch(body, /🟢 No size increases/);
});
+function writeJson(dir, name, value) {
+ fs.mkdirSync(dir, { recursive: true });
+ fs.writeFileSync(path.join(dir, name), JSON.stringify(value));
+}
+
+function renderDirectories(baseDirs, headDirs) {
+ const out = spawnSync(
+ process.execPath,
+ [reportScript, `--base=${baseDirs}`, `--head=${headDirs}`],
+ {
+ encoding: 'utf8',
+ },
+ );
+ assert.equal(out.status, 0, out.stderr);
+ return out.stdout;
+}
+
+const byteSuites = (dir) => {
+ writeJson(
+ dir,
+ 'bundle-size.json',
+ suite('bundle-size', [{ name: 'octane-tsrx', ops: { js_gzip: bytes(1000) } }]),
+ );
+ writeJson(
+ dir,
+ 'bundle-reachability.json',
+ suite('bundle-reachability', [{ name: 'octane', ops: { raw: bytes(1000) } }]),
+ );
+};
+
+test('a js-framework round that dies before writing JSON is not compared alone', () => {
+ const root = fs.mkdtempSync(path.join(os.tmpdir(), 'pr-report-'));
+ try {
+ const base = path.join(root, 'base');
+ const baseRound = path.join(root, 'base-js-1');
+ const crashed = path.join(root, 'base-js-2');
+ const head = path.join(root, 'head');
+ byteSuites(base);
+ byteSuites(head);
+ const timing = suite('js-framework', [{ name: 'octane-tsrx', ops: { run: timed(10, 9, 3) } }]);
+ writeJson(baseRound, 'js-framework.json', timing);
+ fs.mkdirSync(crashed);
+ fs.writeFileSync(path.join(crashed, 'build-octane-tsrx-jsbench.log'), 'build failed');
+ writeJson(head, 'js-framework.json', timing);
+ const body = renderDirectories([base, baseRound, crashed].join(','), head);
+ assert.match(body, /js-framework failed before writing a result \(base-js-2\)/);
+ assert.match(body, /⚠️ js-framework failed on the base commit and was not compared/);
+ assert.doesNotMatch(body, /bundle-size failed/);
+ assert.doesNotMatch(body, /🟢 No size increases/);
+ } finally {
+ fs.rmSync(root, { recursive: true, force: true });
+ }
+});
+
+test('startup logs in a round directory are not a failed byte suite', () => {
+ const root = fs.mkdtempSync(path.join(os.tmpdir(), 'pr-report-'));
+ try {
+ const base = path.join(root, 'base');
+ const round1 = path.join(root, 'base-js-1');
+ const round2 = path.join(root, 'base-js-2');
+ const head = path.join(root, 'head');
+ byteSuites(base);
+ byteSuites(head);
+ const round = (score) =>
+ suite('js-framework', [{ name: 'octane-tsrx', ops: { run: timed(score, score - 0.5, 3) } }]);
+ writeJson(round1, 'js-framework.json', round(10));
+ fs.writeFileSync(path.join(round1, 'server-5176.log'), 'ready');
+ writeJson(round2, 'js-framework.json', round(13));
+ writeJson(head, 'js-framework.json', round(11.5));
+ const empty = path.join(root, 'empty');
+ fs.mkdirSync(empty);
+ const body = renderDirectories(
+ [base, round1, round2, empty, path.join(root, 'missing')].join(','),
+ head,
+ );
+ assert.match(body, /🟢 No size increases and no timing regressions outside noise\./);
+ assert.doesNotMatch(body, /failed before writing a result/);
+ } finally {
+ fs.rmSync(root, { recursive: true, force: true });
+ }
+});
+
test('an unchanged pull request reports no regressions', () => {
const results = {
'bundle-size': suite('bundle-size', [{ name: 'octane-tsrx', ops: { js_gzip: bytes(1000) } }]),
diff --git a/scripts/ci-workflow.test.mjs b/scripts/ci-workflow.test.mjs
--- a/scripts/ci-workflow.test.mjs
+++ b/scripts/ci-workflow.test.mjs
@@ -1676,6 +1676,11 @@
assert.ok(
prBenchWorkflow.includes('--head="$RESULTS/head,$RESULTS/head-js-1,$RESULTS/head-js-2"'),
);
+ assert.match(
+ prBenchWorkflow,
+ /else\n\s+# A throw before writeFileSync leaves no JSON[\s\S]*?if \[ ! -f "\$dir\/js-framework\.json" \]/,
+ );
+ assert.match(prBenchWorkflow, /js-framework failed before writing a result \(%s\)/);
assert.match(packageJson.scripts['ci:workflow:test'], /benchmarks\/pr-report\.test\.mjs/);
});You can send follow-ups to the cloud agent here.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
Autofix Details
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: In-progress rerun hides completed results
- The comment job now keeps completed PR bench and CI runs for this commit, including the triggering run, and prefers a success over a newer in-progress, failed, or cancelled rerun.
Or push these changes by commenting:
@cursor push 6f1bc7ac02
Preview (6f1bc7ac02)
diff --git a/.github/workflows/pr-bench-comment.yml b/.github/workflows/pr-bench-comment.yml
--- a/.github/workflows/pr-bench-comment.yml
+++ b/.github/workflows/pr-bench-comment.yml
@@ -48,21 +48,46 @@
script: |
const { owner, repo } = context.repo;
const sha = context.payload.workflow_run.head_sha;
- const latest = async (workflow_id) => {
+ const triggering = context.payload.workflow_run;
+ const fileOf = (run) => (run.path ?? "").split("/").pop();
+ // The newest row can be an in-progress or cancelled rerun. Keep the
+ // completed run for this commit, preferring a success so a failed
+ // rerun does not hide an artifact or a full timing.
+ const completedFor = async (workflow_id) => {
const { data } = await github.rest.actions.listWorkflowRuns({
owner,
repo,
workflow_id,
head_sha: sha,
event: "pull_request",
- per_page: 1,
+ status: "completed",
+ per_page: 100,
});
- return data.workflow_runs[0];
+ const runs = new Map();
+ for (const run of data.workflow_runs ?? []) {
+ if (
+ run.head_sha === sha &&
+ run.status === "completed" &&
+ run.conclusion !== "cancelled"
+ ) {
+ runs.set(run.id, run);
+ }
+ }
+ if (
+ fileOf(triggering) === workflow_id &&
+ triggering.head_sha === sha &&
+ triggering.status === "completed" &&
+ triggering.conclusion !== "cancelled"
+ ) {
+ runs.set(triggering.id, triggering);
+ }
+ const ordered = [...runs.values()].sort((a, b) => b.id - a.id);
+ return ordered.find((run) => run.conclusion === "success") ?? ordered[0] ?? null;
};
- const bench = await latest("pr-bench.yml");
- const ci = await latest("ci.yml");
- core.setOutput("bench", bench?.status === "completed" ? String(bench.id) : "");
- core.setOutput("ci", ci?.status === "completed" ? String(ci.id) : "");
+ const bench = await completedFor("pr-bench.yml");
+ const ci = await completedFor("ci.yml");
+ core.setOutput("bench", bench ? String(bench.id) : "");
+ core.setOutput("ci", ci ? String(ci.id) : "");
- name: Download benchmark report
id: download
diff --git a/scripts/ci-workflow.test.mjs b/scripts/ci-workflow.test.mjs
--- a/scripts/ci-workflow.test.mjs
+++ b/scripts/ci-workflow.test.mjs
@@ -1693,6 +1693,155 @@
assert.ok(prBenchCommentWorkflow.includes('comment.body?.startsWith(COMMENT_MARKER)'));
assert.match(packageJson.scripts['ci:workflow:test'], /benchmarks\/ci-timing\.test\.mjs/);
});
+
+ test('uses the completed run for this commit when a newer rerun is in progress or cancelled', async () => {
+ const sha = 'a'.repeat(40);
+ const other = 'b'.repeat(40);
+ const queries = [];
+ const listed = {
+ 'pr-bench.yml': [
+ {
+ id: 30,
+ status: 'in_progress',
+ conclusion: null,
+ head_sha: sha,
+ path: '.github/workflows/pr-bench.yml',
+ },
+ {
+ id: 20,
+ status: 'completed',
+ conclusion: 'cancelled',
+ head_sha: sha,
+ path: '.github/workflows/pr-bench.yml',
+ },
+ {
+ id: 9,
+ status: 'completed',
+ conclusion: 'success',
+ head_sha: sha,
+ path: '.github/workflows/pr-bench.yml',
+ },
+ ],
+ 'ci.yml': [
+ {
+ id: 60,
+ status: 'completed',
+ conclusion: 'failure',
+ head_sha: sha,
+ path: '.github/workflows/ci.yml',
+ },
+ {
+ id: 40,
+ status: 'completed',
+ conclusion: 'success',
+ head_sha: other,
+ path: '.github/workflows/ci.yml',
+ },
+ {
+ id: 12,
+ status: 'completed',
+ conclusion: 'success',
+ head_sha: sha,
+ path: '.github/workflows/ci.yml',
+ },
+ ],
+ };
+ const outputs = new Map();
+ const execute = new AsyncFunction(
+ 'github',
+ 'context',
+ 'core',
+ stepScript(prBenchCommentWorkflow, 'Find runs for the commit'),
+ );
+ await execute(
+ {
+ rest: {
+ actions: {
+ listWorkflowRuns: async (input) => {
+ queries.push(input);
+ return { data: { workflow_runs: listed[input.workflow_id] ?? [] } };
+ },
+ },
+ },
+ },
+ {
+ repo: { owner: 'octanejs', repo: 'octane' },
+ payload: {
+ workflow_run: {
+ id: 10,
+ path: '.github/workflows/pr-bench.yml',
+ head_sha: sha,
+ status: 'completed',
+ conclusion: 'success',
+ event: 'pull_request',
+ },
+ },
+ },
+ {
+ setOutput(name, value) {
+ outputs.set(name, value);
+ },
+ },
+ );
+
+ assert.equal(outputs.get('bench'), '10');
+ assert.equal(outputs.get('ci'), '12');
+ assert.ok(queries.length === 2);
+ assert.ok(
+ queries.every(
+ (query) => query.head_sha === sha && query.status === 'completed' && query.per_page === 100,
+ ),
+ );
+
+ listed['ci.yml'] = [
+ {
+ id: 70,
+ status: 'completed',
+ conclusion: 'cancelled',
+ head_sha: sha,
+ path: '.github/workflows/ci.yml',
+ },
+ {
+ id: 61,
+ status: 'completed',
+ conclusion: 'failure',
+ head_sha: sha,
+ path: '.github/workflows/ci.yml',
+ },
+ ];
+ outputs.clear();
+ await execute(
+ {
+ rest: {
+ actions: {
+ listWorkflowRuns: async (input) => ({
+ data: { workflow_runs: listed[input.workflow_id] ?? [] },
+ }),
+ },
+ },
+ },
+ {
+ repo: { owner: 'octanejs', repo: 'octane' },
+ payload: {
+ workflow_run: {
+ id: 61,
+ path: '.github/workflows/ci.yml',
+ head_sha: sha,
+ status: 'completed',
+ conclusion: 'failure',
+ event: 'pull_request',
+ },
+ },
+ },
+ {
+ setOutput(name, value) {
+ outputs.set(name, value);
+ },
+ },
+ );
+ assert.equal(outputs.get('bench'), '9');
+ assert.equal(outputs.get('ci'), '61');
+ });
});
describe('Vercel preview workflow', () => {You can send follow-ups to the cloud agent here.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Empty success hides later reports
- The run picker now ignores a draft success whose real jobs were skipped, so a later failed PR bench or CI run on the same commit is the one whose report and timing are posted.
Or push these changes by commenting:
@cursor push 9888f1b713
Preview (9888f1b713)
diff --git a/.github/workflows/pr-bench-comment.yml b/.github/workflows/pr-bench-comment.yml
--- a/.github/workflows/pr-bench-comment.yml
+++ b/.github/workflows/pr-bench-comment.yml
@@ -49,7 +49,11 @@
const { owner, repo } = context.repo;
const sha = context.payload.workflow_run.head_sha;
const trigger = context.payload.workflow_run;
- // A newer in-progress, cancelled, or failed rerun must not hide a completed success.
+ // Prefer a completed success that actually ran its jobs, so a newer
+ // failure cannot hide it. A draft still concludes success when its
+ // jobs are skipped: PR bench skips its only job, and CI skips the
+ // gate while the required-check reporters pass. That empty success
+ // must not hide the run that produced the report.
const completed = async (workflow_id) => {
const { data } = await github.rest.actions.listWorkflowRuns({
owner,
@@ -65,7 +69,29 @@
runs.push(trigger);
}
runs.sort((a, b) => b.id - a.id);
- return runs.find((run) => run.conclusion === "success") ?? runs[0];
+ const didWork = async (run) => {
+ const jobs = await github.paginate(github.rest.actions.listJobsForWorkflowRun, {
+ owner,
+ repo,
+ run_id: run.id,
+ filter: "latest",
+ per_page: 100,
+ });
+ // Same gate as benchmarks/ci-timing.mjs `ranGatedJobs`.
+ return workflow_id === "ci.yml"
+ ? jobs.some(
+ (job) =>
+ job.name === "classify changeset release" && job.conclusion === "success",
+ )
+ : jobs.some((job) => job.conclusion !== "skipped");
+ };
+ for (const run of runs) {
+ if (run.conclusion === "success" && (await didWork(run))) return run;
+ }
+ for (const run of runs) {
+ if (run.conclusion !== "success" && (await didWork(run))) return run;
+ }
+ return runs[0];
};
const bench = await completed("pr-bench.yml");
const ci = await completed("ci.yml");
diff --git a/scripts/ci-workflow.test.mjs b/scripts/ci-workflow.test.mjs
--- a/scripts/ci-workflow.test.mjs
+++ b/scripts/ci-workflow.test.mjs
@@ -1694,27 +1694,10 @@
assert.match(packageJson.scripts['ci:workflow:test'], /benchmarks\/ci-timing\.test\.mjs/);
});
- // A newer in-progress, cancelled, or failed rerun used to hide the completed success.
- test('picks the completed successful run for the commit over newer reruns', async () => {
- const sha = 'a'.repeat(40);
- const run = (id, path, conclusion) => ({
- id,
- path: `.github/workflows/${path}`,
- head_sha: sha,
- conclusion,
- });
- const listed = {
- 'pr-bench.yml': [run(20, 'pr-bench.yml', 'cancelled'), run(9, 'pr-bench.yml', 'success')],
- 'ci.yml': [run(60, 'ci.yml', 'failure'), run(12, 'ci.yml', 'success')],
- };
+ async function selectRuns({ listed, jobs = new Map(), trigger }) {
const queries = [];
const outputs = {};
- const execute = new AsyncFunction(
- 'github',
- 'context',
- 'core',
- stepScript(prBenchCommentWorkflow, 'Find runs for the commit'),
- );
+ const listJobsForWorkflowRun = async () => undefined;
const github = {
rest: {
actions: {
@@ -1722,29 +1705,127 @@
queries.push(query);
return { data: { workflow_runs: listed[query.workflow_id] } };
},
+ listJobsForWorkflowRun,
},
},
+ paginate: async (method, query) => {
+ assert.equal(method, listJobsForWorkflowRun);
+ if (jobs.has(query.run_id)) return jobs.get(query.run_id);
+ return [
+ { name: 'benchmark report', conclusion: 'success' },
+ { name: 'classify changeset release', conclusion: 'success' },
+ ];
+ },
};
- const core = { setOutput: (name, value) => (outputs[name] = value) };
- const trigger = { ...run(70, 'pr-bench.yml', 'success'), status: 'completed' };
+ const execute = new AsyncFunction(
+ 'github',
+ 'context',
+ 'core',
+ stepScript(prBenchCommentWorkflow, 'Find runs for the commit'),
+ );
await execute(
github,
{ repo: { owner: 'o', repo: 'r' }, payload: { workflow_run: trigger } },
- core,
+ { setOutput: (name, value) => (outputs[name] = value) },
);
- assert.deepEqual(outputs, { bench: '70', ci: '12' });
- assert.ok(queries.every((query) => query.status === 'completed' && query.head_sha === sha));
+ return { outputs, queries };
+ }
- await execute(
- github,
- {
- repo: { owner: 'o', repo: 'r' },
- payload: { workflow_run: { ...trigger, id: 5, conclusion: 'failure' } },
- },
- core,
+ // A newer in-progress, cancelled, or failed rerun used to hide the completed success.
+ test('picks the completed successful run for the commit over newer reruns', async () => {
+ const sha = 'a'.repeat(40);
+ const run = (id, path, conclusion) => ({
+ id,
+ path: `.github/workflows/${path}`,
+ head_sha: sha,
+ conclusion,
+ });
+ const listed = {
+ 'pr-bench.yml': [run(20, 'pr-bench.yml', 'cancelled'), run(9, 'pr-bench.yml', 'success')],
+ 'ci.yml': [run(60, 'ci.yml', 'failure'), run(12, 'ci.yml', 'success')],
+ };
+ const trigger = { ...run(70, 'pr-bench.yml', 'success'), status: 'completed' };
+ const first = await selectRuns({ listed, trigger });
+ assert.deepEqual(first.outputs, { bench: '70', ci: '12' });
+ assert.ok(
+ first.queries.every((query) => query.status === 'completed' && query.head_sha === sha),
);
- assert.deepEqual(outputs, { bench: '9', ci: '12' });
+
+ const second = await selectRuns({
+ listed,
+ trigger: { ...trigger, id: 5, conclusion: 'failure' },
+ });
+ assert.deepEqual(second.outputs, { bench: '9', ci: '12' });
});
+
+ // Opening a draft still completes PR bench and CI as success while the real
+ // jobs are skipped. Marking it ready reuses the SHA, so that empty success
+ // must not hide the later run that actually executed.
+ test('does not let a skipped draft success hide the run that executed the work', async () => {
+ const sha = 'b'.repeat(40);
+ const run = (id, workflowPath, conclusion) => ({
+ id,
+ path: `.github/workflows/${workflowPath}`,
+ head_sha: sha,
+ conclusion,
+ });
+ const listed = {
+ 'pr-bench.yml': [run(30, 'pr-bench.yml', 'failure'), run(8, 'pr-bench.yml', 'success')],
+ 'ci.yml': [run(40, 'ci.yml', 'failure'), run(7, 'ci.yml', 'success')],
+ };
+ const jobs = new Map([
+ [30, [{ name: 'benchmark report', conclusion: 'failure' }]],
+ [8, [{ name: 'benchmark report', conclusion: 'skipped' }]],
+ [
+ 40,
+ [
+ { name: 'classify changeset release', conclusion: 'success' },
+ { name: 'test (24)', conclusion: 'failure' },
+ ],
+ ],
+ [
+ 7,
+ [
+ { name: 'classify changeset release', conclusion: 'skipped' },
+ { name: 'lint', conclusion: 'success' },
+ { name: 'typecheck', conclusion: 'success' },
+ ],
+ ],
+ ]);
+ const laterFailure = await selectRuns({
+ listed,
+ jobs,
+ trigger: { ...run(30, 'pr-bench.yml', 'failure'), status: 'completed' },
+ });
+ assert.deepEqual(laterFailure.outputs, { bench: '30', ci: '40' });
+
+ const laterDraft = await selectRuns({
+ listed: {
+ 'pr-bench.yml': [run(31, 'pr-bench.yml', 'success'), run(8, 'pr-bench.yml', 'failure')],
+ 'ci.yml': [run(41, 'ci.yml', 'success'), run(7, 'ci.yml', 'failure')],
+ },
+ jobs: new Map([
+ [31, [{ name: 'benchmark report', conclusion: 'skipped' }]],
+ [8, [{ name: 'benchmark report', conclusion: 'failure' }]],
+ [
+ 41,
+ [
+ { name: 'classify changeset release', conclusion: 'skipped' },
+ { name: 'lint', conclusion: 'success' },
+ ],
+ ],
+ [
+ 7,
+ [
+ { name: 'classify changeset release', conclusion: 'success' },
+ { name: 'test (24)', conclusion: 'failure' },
+ ],
+ ],
+ ]),
+ trigger: { ...run(31, 'pr-bench.yml', 'success'), status: 'completed' },
+ });
+ assert.deepEqual(laterDraft.outputs, { bench: '8', ci: '7' });
+ });
});
describe('Vercel preview workflow', () => {You can send follow-ups to the cloud agent here.
Reviewed by Cursor Bugbot for commit 223330c. Configure here.
Brings in #1500, #1471, and #1502. #1500 changes vitest.config.js, which every user-app grader digest covers, so manifest.jsonl is regenerated rather than hand-merged. The Strong repair ledger, prompts, and alternatives are unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>


Summary
Every ready pull request now gets one sticky comment that reports its performance and bundle-size impact against its base commit.
PR benchrunsjs-framework(the krausest-style suite published at octanejs.dev/benchmarks, Octane.tsrxand.tsxtargets),bundle-size(the four application fixtures' raw/gzip/brotli bytes), andbundle-reachability(public-import feature bundles) for both the base commit and the merge commit on the same runner. Byte suites run once per tree.js-frameworkruns four rounds (base, head, head, base), so linear runner drift cancels out disagreement between rounds widens the noise band, and a missing round fails the suite.benchmarks/pr-report.mjsdiffs the twoBENCH_JSONresult sets into Markdown. Byte and count changes, such asproduction_calls_1kor DOM insertions, are reported exactly. A timing change only becomes a verdict when it exceeds the combined relative margin of error (5% floor) and one 0.1ms timer tick, and the fastest sample moves the same way. Timing verdicts show as yellow "possibly slower". Only byte or count increases and suite failures show red.PR bench commentposts the report throughworkflow_run, so fork pull requests get comments too, without giving their code a write token.The same sticky comment now also reports CI job durations: every job of the pull request's
CIrun against the last five successfulmainpush runs that ran the full job set, from Actions API timestamps only. This gives toolchain changes (Bun, oxc, TypeScript 7; see spike: evaluate Bun for scripts, transpilation, and test running #1247) a per-job before/after with no extra runner time.Why
Benchcron and the--ratiosgate. A per-PR before/after view makes regressions visible during review.benchmarks/baselines/README.md), so the report always measures both commits in the same job rather than comparing against the recordedbaselines/localsnapshot.Changes
.github/workflows/pr-bench.ymlis unprivileged (contents: read, no persisted credentials). It skips drafts and docs-only changes, cancels superseded runs, uploads the report plus raw JSON aspr-bench-report, and writes the report to the job summary. It fails only when a suite fails on the merge commit. It is informational, not a required check..github/workflows/pr-bench-comment.ymlruns from the default branch withpull-requests: writeandactions: read. It never checks out or executes PR code. It treats the artifact as untrusted: the PR number must resolve to a PR whose head equals the triggering run'shead_sha, and the body must start with the report marker and fit GitHub's comment limit. It updates its existing bot comment in place.benchmarks/pr-report.mjsandbenchmarks/pr-report.test.mjs(wired intoci:workflow:test), new workflow assertions inscripts/ci-workflow.test.mjs, and a README section.benchmarks/ci-timing.mjsandbenchmarks/ci-timing.test.mjs(wired intoci:workflow:test) compare job durations. A job is only called slower or faster outside the wholemainrange, by at least 10% and 15s. Totals are marked as a partial run when the pull request skipped jobs thatmainran..github/workflows/pr-bench-comment.ymlnow also triggers onCIcompletion. It sparse-checks out only the default branch'sci-timing.mjsandpr-report.mjs, still never runs pull request code, resolves the pull request by head SHA instead of trusting the artifact, and rebuilds the whole comment, so whichever workflow finishes last posts both sections.Validation
pnpm format:check(not run repo-wide;pnpm format:filesrun on every changed file)pnpm typecheck(no TypeScript changed)pnpm test(no runtime or package code changed)pnpm ci:workflow:test(301 passed); dry run ofci-timing.mjsagainst this PR's real CI run and 20mainruns rendered the expected table,node --test benchmarks/pr-report.test.mjs(10 passed, including regressions for a base-commit failure reported as green, a sub-tick timing false positive, runner drift, and a dropped timing round),pnpm sync(no generated changes)PR benchran on this PR in about 7.5 minutes. Its first CI report on this no-runtime-change diff flaggedoctane-tsrx select0.18 → 0.26ms as slower, which is below one Chromium timer tick. That false positive is now covered by a test and suppressed. The next run flagged 9 operations as slower, all in the same direction, because head always ran after base on a drifting runner. Merging those two real CI runs as base/head/head/base rounds reports green. The interleaved order fixes that. The first four-round CI run on this PR reported green (benchmark report, 8m58s).PR bench commentcan only run after merge, becauseworkflow_runloads it from the default branch.Risk / follow-ups
Provenance
agent-authored)Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Note
Medium Risk
Introduces long-running PR CI (~8+ minutes per push) and a trusted comment workflow that writes to pull requests; benchmark execution still runs untrusted PR code in the separate read-only bench job.
Overview
Adds per-PR performance visibility through two GitHub Actions workflows and supporting benchmark scripts.
PR benchruns on ready (non-draft) pull requests: it benchmarks the base commit and merge commit on one runner (js-frameworkfor Octane only,bundle-size,bundle-reachability), uses interleaved base/head/head/base timing rounds to cancel runner drift, renders Markdown viapr-report.mjs, uploads an artifact, and fails only when a suite fails on the merge commit. Fork PRs stay read-only; they do not post comments directly.PR bench commenttriggers onPR benchorCIcompletion viaworkflow_run, checks out default-branchpr-report.mjs/ci-timing.mjsonly (no PR code execution), validates the artifact against PR number and head SHA, and creates or updates a single sticky bot comment.ci-timing.mjsadds a CI job-duration table versus the last five fullmainruns (Actions API only, noise thresholds).Tests land in
pr-report.test.mjs,ci-timing.test.mjs, and expandedci-workflow.test.mjs;benchmarks/README.mddocuments the flow.Reviewed by Cursor Bugbot for commit 1dce662. Bugbot is set up for automated code reviews on this repo. Configure here.