8000 ci: remap two-line workflows to main (3.x) and v2.x for the branch move (#937) by adityamukho · Pull Request #971 · project-minigraf/minigraf · GitHub
[go: up one dir, main page]

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
4 changes: 2 additions & 2 deletions .github/bench/bindings-report.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ test('CLI verifies execution and records provenance even when upload is partial'
fs.writeFileSync(path.join(dir, 'binding/binding-results.json'), JSON.stringify(data('python')));
fs.writeFileSync(path.join(dir, 'binding-execution.txt'), expected('python').map(id => `ok: ${id}`).join('\n'));
fs.writeFileSync(path.join(dir, 'binding-sha.txt'), 'binding-commit\n');
const env = { ...process.env, BINDING: 'python', BENCH_SHA: 'core-commit', WORKFLOW_SHA: 'workflow-commit', BENCH_REF: 'v3', BINDING_HISTORY: 'binding-experiment/v3/pr', BENCHER_OUTCOME: 'success' };
const env = { ...process.env, BINDING: 'python', BENCH_SHA: 'core-commit', WORKFLOW_SHA: 'workflow-commit', BENCH_REF: 'main', BINDING_HISTORY: 'binding-experiment/main/pr', BENCHER_OUTCOME: 'success' };
const run = command => spawnSync(process.execPath, [path.join(__dirname, 'bindings-report.cjs'), command], { cwd: dir, env, encoding: 'utf8' });
assert.equal(run('validate').status, 0);
fs.appendFileSync(path.join(dir, 'binding-execution.txt'), '\nok: binding/python/aggregate/1k');
Expand All @@ -39,7 +39,7 @@ test('CLI verifies execution and records provenance even when upload is partial'
assert.equal(report.bindingSha, 'binding-commit');
assert.equal(report.workflowSha, 'workflow-commit');
assert.equal(report.testbed, 'binding-python-ubuntu24-v1');
assert.equal(report.historyBranch, 'binding-experiment/v3/pr');
assert.equal(report.historyBranch, 'binding-experiment/main/pr');
assert.equal(report.uploaded.length, 0);
assert.ok(report.errors.length);
} finally { fs.rmSync(dir, { recursive: true, force: true }); }
Expand Down
39 changes: 20 additions & 19 deletions .github/bench/bindings-workflow.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ test('new rows use the actual binding suite job names', () => {
assert.match(bindingJob, /binding: wasi/);
assert.match(workflow, /jvm-ref:/);
});
test('main skips; either v3 lane fails when its measured validator is absent', () => {
test('v2.x skips; either 3.x lane fails when its measured validator is absent', () => {
for (const binding of ['jvm', 'wasi']) {
const main = shell('Check v3 binding suite availability', {BENCH_REF: 'main', BINDING: binding});
const main = shell('Check v3 binding suite availability', {BENCH_REF: 'v2.x', BINDING: binding});
assert.equal(main.status, 0, main.stderr);
assert.match(main.summary, /Skipping/);
assert.doesNotMatch(main.output, /enabled=true/);
for (const missing of [true, false]) {
const result = shell('Check v3 binding suite availability', {BENCH_REF: 'v3', BINDING: binding}, cwd => {
const result = shell('Check v3 binding suite availability', {BENCH_REF: 'main', BINDING: binding}, cwd => {
for (const file of ['benches/minigraf_bench/prepared.rs', 'benchmarks/bindings839/nightly.py',
'benchmarks/bindings839/wasi.py', ...(missing ? [] : ['benchmarks/bindings839/validate.py'])]) {
fs.mkdirSync(path.dirname(path.join(cwd, file)), {recursive: true});
Expand Down Expand Up @@ -69,7 +69,7 @@ test('reporting CI skips absent Python tests on main and runs them on v3', () =>
}
});
for (const binding of ['jvm', 'wasi']) test(`${binding} uploads only to its own testbed without inherited history`, () => {
for (const history of ['v3', 'binding-experiment/experiment/v3']) {
for (const history of ['main', 'binding-experiment/experiment/main']) {
const result = shell('Upload foreign runtime metrics', {BINDING: binding, BINDING_HISTORY: history, BENCH_SHA: 'a'.repeat(40), BENCH_THRESHOLD: '0.999'}, undefined,
'bencher() { printf "%s\\0" "$@"; }\n');
assert.equal(result.status, 0, result.stderr);
Expand All @@ -88,19 +88,19 @@ for (const binding of ['jvm', 'wasi']) test(`${binding} repeated exact IDs, imme
const alert = name => `- ${name} (Latency): https://bencher.dev/console/projects/minigraf/alerts/123`;
const original = {...process.env};
try {
Object.assign(process.env, {SUITE: suite, BENCH_REF: 'v3', BENCH_SHA: 'a'.repeat(40)});
Object.assign(process.env, {SUITE: suite, BENCH_REF: 'main', BENCH_SHA: 'a'.repeat(40)});
for (const scenario of ['repeat', 'different-id', 'upload-failure', 'lookup-failure', 'existing-issue', 'experiment-prior']) {
const calls = [], warnings = [];
const github = {rest: {actions: {
listWorkflowRuns: async () => ({data: {workflow_runs: [{id: 1, display_title: 'Nightly Benchmarks (main)'}, {id: 2, display_title: 'Nightly Benchmarks (v3)', html_url: 'prior'}]}}),
listWorkflowRuns: async () => ({data: {workflow_runs: [{id: 1, display_title: 'Nightly Benchmarks (v2.x)'}, {id: 2, display_title: 'Nightly Benchmarks (main)', html_url: 'prior'}]}}),
listJobsForWorkflowRun: async args => { assert.equal(args.run_id, 2); return {data: {jobs: [{id: 3, name: `bench / ${suite}`}, {id: 4, name: 'bench / binding_python'}]}}; },
downloadJobLogsForWorkflowRun: async args => {
assert.equal(args.job_id, 3);
if (scenario === 'lookup-failure') throw new Error('unavailable logs');
return {data: `History branch: ${scenario === 'experiment-prior' ? 'binding-experiment/v3/java-only' : 'v3'}; testbed: binding-${binding}-ubuntu24-v1;\n` + alert(scenario === 'different-id' ? `${id}/other` : id)};
return {data: `History branch: ${scenario === 'experiment-prior' ? 'binding-experiment/main/java-only' : 'main'}; testbed: binding-${binding}-ubuntu24-v1;\n` + alert(scenario === 'different-id' ? `${id}/other` : id)};
},
}, issues: {
listForRepo: async () => ({data: scenario === 'existing-issue' ? [{number: 8, title: `Benchmark regression: ${suite} (v3)`}] : []}),
listForRepo: async () => ({data: scenario === 'existing-issue' ? [{number: 8, title: `Benchmark regression: ${suite} (main)`}] : []}),
create: async args => { calls.push(args); return {data: {number: 9}}; },
createComment: async args => { calls.push(args); },
}}};
Expand All @@ -123,10 +123,11 @@ for (const binding of ['jvm', 'wasi']) test(`${binding} repeated exact IDs, imme

test('experimental binding and core refs are isolated, including WASI without a repo', () => {
for (const [binding, ref, bindingRef, history] of [
['jvm', 'v3', 'v3', 'v3'],
['jvm', 'v3', 'java-only', 'binding-experiment/v3/java-only'],
['jvm', 'candidate', 'v3', 'binding-experiment/candidate/v3'],
['wasi', 'candidate', 'v3', 'binding-experiment/candidate/v3'],
['jvm', 'main', 'main', 'main'],
['jvm', 'main', 'java-only', 'binding-experiment/main/java-only'],
['jvm', 'candidate', 'main', 'binding-experiment/candidate/main'],
['wasi', 'candidate', 'main', 'binding-experiment/candidate/main'],
['jvm', 'v3', 'v3', 'binding-experiment/v3/v3'],
]) {
const result = shell('Pin binding source', {BINDING: binding, BENCH_REF: ref, BINDING_REF: bindingRef}, undefined,
'git() { printf "%s\\n" binding-sha; }\n');
Expand Down Expand Up @@ -186,19 +187,19 @@ for (const binding of ['jvm', 'wasi']) test(`${binding} finds the most recent pr
const original = {...process.env};
const suite = `binding_${binding}`, id = `binding/${binding}/example`;
const alert = `- ${id} (Latency): https://bencher.dev/console/projects/minigraf/alerts/123`;
const production = `History branch: v3; testbed: binding-${binding}-ubuntu24-v1;`;
const production = `History branch: main; testbed: binding-${binding}-ubuntu24-v1;`;
try {
Object.assign(process.env, {SUITE: suite, BENCH_REF: 'v3', BENCH_SHA: 'a'.repeat(40)});
Object.assign(process.env, {SUITE: suite, BENCH_REF: 'main', BENCH_SHA: 'a'.repeat(40)});
for (const scenario of ['repeat-after-experiment', 'clean-production', 'wrong-testbed', 'no-suite', 'lookup-failure', 'exhausted', 'failed-before-summary', 'failed-experiment', 'failed-production-alert']) {
const calls = [], warnings = [], visited = [];
const github = {rest: {actions: {
listWorkflowRuns: async args => {
assert.equal(args.status, 'completed');
assert.equal(args.per_page, 20);
return {data: {workflow_runs: [
{id: 100, display_title: 'Nightly Benchmarks (v3)'}, // current
{id: 99, display_title: 'Nightly Benchmarks (main)'},
...Array.from({length: 18}, (_, i) => ({id: 98 - i, display_title: 'Nightly Benchmarks (v3)', html_url: `prior-${98 - i}`})),
{id: 100, display_title: 'Nightly Benchmarks (main)'}, // current
{id: 99, display_title: 'Nightly Benchmarks (v2.x)'},
...Array.from({length: 18}, (_, i) => ({id: 98 - i, display_title: 'Nightly Benchmarks (main)', html_url: `prior-${98 - i}`})),
]}};
},
listJobsForWorkflowRun: async args => {
Expand All @@ -210,8 +211,8 @@ for (const binding of ['jvm', 'wasi']) test(`${binding} finds the most recent pr
if (job_id === 98 && scenario === 'failed-before-summary') return {data: `build failed\n${alert}`};
if (job_id === 98 && scenario === 'failed-production-alert') return {data: `${production}\n${alert}`};
if (job_id === 98 || scenario === 'exhausted') {
const history = scenario === 'wrong-testbed' ? 'History branch: v3; testbed: binding-python-ubuntu24-v1;' :
`History branch: binding-experiment/v3/java-only; testbed: binding-${binding}-ubuntu24-v1;`;
const history = scenario === 'wrong-testbed' ? 'History branch: main; testbed: binding-python-ubuntu24-v1;' :
`History branch: binding-experiment/main/java-only; testbed: binding-${binding}-ubuntu24-v1;`;
return {data: `${history}\n${alert}`};
}
return {data: `${production}\n${scenario === 'clean-production' && job_id === 97 ? '' : alert}`};
Expand Down
6 changes: 6 additions & 0 deletions .github/bench/bindings.sh
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,15 @@ cd binding
if [[ "$mode" = build ]]; then
mkdir -p .cargo
# Benchmark the exact measured core checkout, not the binding's release pin.
# Before a release the pin is a git revision; after it, the exact crates.io
# version (#937, #929). Patch both sources: Cargo ignores the unused one, and
# the check below fails if neither replaced the pin.
cat > .cargo/config.toml <<EOF
[patch."https://github.com/project-minigraf/minigraf"]
minigraf = { path = "$core_dir" }

[patch.crates-io]
minigraf = { path = "$core_dir" }
EOF
cargo update -p minigraf
cargo metadata --format-version 1 > target-metadata.json
Expand Down
116 changes: 116 additions & 0 deletions .github/bench/branch-move.test.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
// #937: runs created before the branch move named the 2.x line `main` and the
// 3.x line `v3`. "Report regression" must read them under the new names, so a
// new `main` (3.x) alert never pairs with an old 2.x run, and each line's
// alert streak continues across the move. No network or GitHub writes.
const { test } = require('node:test');
const assert = require('node:assert/strict');
const fs = require('node:fs');
const path = require('node:path');

const workflow = fs.readFileSync(path.join(__dirname, '../workflows/bench.yml'), 'utf8');
const [nativeJob, bindingJob] = workflow.split('\n bindings:\n');
const movedAt = /^ BRANCH_MOVED_AT: '([^']+)'$/m.exec(workflow)[1];
const AsyncFunction = Object.getPrototypeOf(async function () {}).constructor;

function script(job) {
const step = job.split(' - name: Report regression\n')[1];
assert.ok(step, 'missing Report regression step');
return step.split(' script: |\n')[1].split(/\n - |\n\n # /)[0].replace(/^ /gm, '').trimEnd();
}

test('BRANCH_MOVED_AT is a valid UTC timestamp', () => {
assert.match(movedAt, /^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\dZ$/);
assert.ok(!Number.isNaN(Date.parse(movedAt)));
});

const before = new Date(Date.parse(movedAt) - 3600e3).toISOString();
const after = new Date(Date.parse(movedAt) + 3600e3).toISOString();

async function report(job, {ref, suite, runs, logs, alertFile}) {
const calls = [], warnings = [], visited = [];
const github = {rest: {actions: {
listWorkflowRuns: async () => ({data: {workflow_runs: runs}}),
listJobsForWorkflowRun: async ({run_id}) => {
visited.push(run_id);
return {data: {jobs: [{id: run_id, name: `bench / ${suite}`, status: 'completed', conclusion: 'success'}]}};
},
downloadJobLogsForWorkflowRun: async ({job_id}) => ({data: logs[job_id] || ''}),
}, issues: {
listForRepo: async () => ({data: []}),
create: async args => { calls.push(args); return {data: {number: 1}}; },
createComment: async args => { calls.push(args); },
update: async () => {},
}}};
const summary = {addHeading() {return this;}, addRaw() {return this;}, addList() {return this;}, addBreak() {return this;}, async write() {}};
const original = {...process.env};
Object.assign(process.env, {SUITE: suite, BENCH_REF: ref, BENCH_SHA: 'a'.repeat(40), BRANCH_MOVED_AT: movedAt});
try {
await new AsyncFunction('require', 'github', 'context', 'core', 'console', script(job))(
() => ({readFileSync: () => alertFile}), github,
{repo: {owner: 'test', repo: 'test'}, runId: 100, serverUrl: 'https://example.com'},
{warning: m => warnings.push(m), summary}, {log() {}});
} finally {
for (const key of ['SUITE', 'BENCH_REF', 'BENCH_SHA', 'BRANCH_MOVED_AT']) {
if (original[key] === undefined) delete process.env[key]; else process.env[key] = original[key];
}
}
return {calls, warnings, visited};
}

const alert = id => `- ${id} (Latency): https://bencher.dev/console/projects/minigraf/alerts/1`;

for (const [ref, expectedPrior] of [['main', 98], ['v2.x', 99]]) {
test(`native ${ref} pairs only with the same line's run from before the move`, async () => {
const id = 'query/example';
const runs = [
{id: 100, display_title: `Nightly Benchmarks (${ref})`, created_at: after},
{id: 99, display_title: 'Nightly Benchmarks (main)', created_at: before, html_url: 'prior-99'}, // 2.x
{id: 98, display_title: 'Nightly Benchmarks (v3)', created_at: before, html_url: 'prior-98'}, // 3.x
];
const logs = {99: alert(id), 98: alert(id)};
const {calls, visited} = await report(nativeJob, {ref, suite: 'query', runs, logs, alertFile: alert(id)});
assert.deepEqual(visited, [expectedPrior]);
assert.equal(calls.length, 1);
assert.equal(calls[0].title, `Benchmark regression: query (${ref})`);
assert.match(calls[0].body, new RegExp(`Previous run:\\*\\* prior-${expectedPrior}`));
});
}

test('native main after the move never reads an old 2.x run titled main', async () => {
const runs = [
{id: 100, display_title: 'Nightly Benchmarks (main)', created_at: after},
{id: 99, display_title: 'Nightly Benchmarks (main)', created_at: before, html_url: 'prior-99'},
];
const {calls, visited} = await report(nativeJob, {ref: 'main', suite: 'query', runs, logs: {99: alert('query/x')}, alertFile: alert('query/x')});
assert.deepEqual(visited, []);
assert.equal(calls.length, 0);
});

for (const binding of ['jvm', 'wasi']) test(`${binding} continues the 3.x streak from a v3 run before the move`, async () => {
const suite = `binding_${binding}`, id = `binding/${binding}/example`;
const testbed = `binding-${binding}-ubuntu24-v1`;
const runs = [
{id: 100, display_title: 'Nightly Benchmarks (main)', created_at: after},
{id: 99, display_title: 'Nightly Benchmarks (main)', created_at: before, html_url: 'prior-99'}, // 2.x: skipped
{id: 98, display_title: 'Nightly Benchmarks (v3)', created_at: before, html_url: 'prior-98'},
];
const logs = {98: `History branch: v3; testbed: ${testbed};\n${alert(id)}`};
const {calls, visited} = await report(bindingJob, {ref: 'main', suite, runs, logs, alertFile: alert(id)});
assert.deepEqual(visited, [98]);
assert.equal(calls.length, 1);
assert.match(calls[0].body, /Previous run:\*\* prior-98/);
});

for (const binding of ['jvm', 'wasi']) test(`${binding} after the move requires the main history name`, async () => {
const suite = `binding_${binding}`, id = `binding/${binding}/example`;
const testbed = `binding-${binding}-ubuntu24-v1`;
const runs = [
{id: 100, display_title: 'Nightly Benchmarks (main)', created_at: after},
{id: 98, display_title: 'Nightly Benchmarks (main)', created_at: after, html_url: 'prior-98'},
];
for (const [history, reported] of [['main', 1], ['v3', 0]]) {
const logs = {98: `History branch: ${history}; testbed: ${testbed};\n${alert(id)}`};
const {calls} = await report(bindingJob, {ref: 'main', suite, runs, logs, alertFile: alert(id)});
assert.equal(calls.length, reported, history);
}
});
2 changes: 1 addition & 1 deletion .github/bench/history.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function uploadArgs(ref) {
}
}

for (const ref of ['main', 'v3']) {
for (const ref of ['main', 'v2.x']) {
test(`${ref} preserves its own history when the other branch advances`, () => {
const args = uploadArgs(ref);
assert.equal(args[args.indexOf('--branch') + 1], ref);
Expand Down
2 changes: 1 addition & 1 deletion .github/bench/report.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ test('CLI retains provenance, IDs and summary on success and early failure', ()
try {
const summary = path.join(cwd, 'summary.md');
const env = {
...process.env, BENCH_SUITE: 'window', BENCH_REF: 'v3',
...process.env, BENCH_SUITE: 'window', BENCH_REF: 'main',
BENCH_SHA: 'a'.repeat(40), WORKFLOW_SHA: 'b'.repeat(40),
BENCH_FILTER: '^window/', BENCH_THRESHOLD: '0.999',
BENCH_FILE: 'bench.txt', BENCHER_OUTCOME: 'success', GITHUB_STEP_SUMMARY: summary,
Expand Down
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,10 @@ updates:
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
# The 2.x maintenance line (#937). Without target-branch, Dependabot only
# updates the default branch.
- package-ecosystem: "cargo"
directory: "/"
target-branch: "v2.x"
schedule:
interval: "weekly"
Loading
Loading
0