fix: isolate artifact rebuild from release suites
Memind CI / Test, build, and release guards (push) Has been cancelled

This commit is contained in:
john
2026-07-26 15:19:30 +08:00
parent b1577a16e9
commit ea07f6f250
3 changed files with 50 additions and 2 deletions
+3
View File
@@ -2,6 +2,9 @@ export const AUTOMATION_SUITES = Object.freeze([
{
id: 'runtime-reproducibility',
mode: 'upgrade',
// Rebuilds .runtime/portal in place. Keep this suite isolated from all
// suites that boot or inspect the shared candidate runtime.
exclusive: true,
scenarios: ['REL-03'],
cases: {
'REL-03': ['candidate plus two clean rebuilds produce the same sorted runtime tree SHA256'],
+25 -1
View File
@@ -72,6 +72,30 @@ export async function runWithConcurrency(items, concurrency, worker) {
return results;
}
// Some suites intentionally mutate the shared candidate artifact. Run those
// suites before the parallel batch so they cannot race suites that boot the
// same runtime while it is being rebuilt.
export async function runSuitesWithConcurrency(items, concurrency, worker) {
const results = new Array(items.length);
const parallel = [];
for (let index = 0; index < items.length; index += 1) {
if (items[index].exclusive) {
results[index] = await worker(items[index], index);
} else {
parallel.push({ item: items[index], index });
}
}
const parallelResults = await runWithConcurrency(
parallel,
concurrency,
({ item, index }) => worker(item, index),
);
for (let index = 0; index < parallel.length; index += 1) {
results[parallel[index].index] = parallelResults[index];
}
return results;
}
export async function runCommand(command, args, {
cwd = ROOT,
timeoutMs = 15 * 60 * 1000,
@@ -220,7 +244,7 @@ export async function executeReleaseGate(options) {
);
const suites = AUTOMATION_SUITES.filter((candidate) => suiteIsInMode(candidate, options.mode));
const executions = await runWithConcurrency(
const executions = await runSuitesWithConcurrency(
suites,
options.suiteConcurrency,
(suite) => runSuite(suite, outputDir, options.timeoutMs),
+22 -1
View File
@@ -1,7 +1,7 @@
import assert from 'node:assert/strict';
import test from 'node:test';
import { parseRunnerArgs, runWithConcurrency } from './runner.mjs';
import { parseRunnerArgs, runSuitesWithConcurrency, runWithConcurrency } from './runner.mjs';
test('runner accepts a bounded suite concurrency and rejects unsafe values', () => {
assert.equal(
@@ -31,3 +31,24 @@ test('runWithConcurrency preserves result order and never exceeds its worker bud
assert.deepEqual(results, ['result-0', 'result-1', 'result-2', 'result-3']);
assert.equal(peak, 2);
});
test('exclusive suites finish before parallel suites start', async () => {
const events = [];
const results = await runSuitesWithConcurrency(
[
{ id: 'mutating', exclusive: true },
{ id: 'parallel-a' },
{ id: 'parallel-b' },
],
2,
async (suite) => {
events.push(`start:${suite.id}`);
await new Promise((resolve) => setTimeout(resolve, 5));
events.push(`end:${suite.id}`);
return suite.id;
},
);
assert.deepEqual(results, ['mutating', 'parallel-a', 'parallel-b']);
assert.ok(events.indexOf('end:mutating') < events.indexOf('start:parallel-a'));
assert.ok(events.indexOf('end:mutating') < events.indexOf('start:parallel-b'));
});