25be530d84
Memind CI / Test, build, and release guards (push) Successful in 3m33s
A change to one run-release-gate script must not force every live and upgrade suite to rerun. Co-authored-by: Cursor <cursoragent@cursor.com>
108 lines
3.4 KiB
JavaScript
108 lines
3.4 KiB
JavaScript
import assert from 'node:assert/strict';
|
|
import test from 'node:test';
|
|
|
|
import {
|
|
carryForwardScenario,
|
|
commandFilesForSuite,
|
|
shouldRerunImpactSuite,
|
|
suiteInvalidatedByChanges,
|
|
} from './resume.mjs';
|
|
|
|
const chatSuite = {
|
|
id: 'chat-routing-contract',
|
|
mode: 'deterministic',
|
|
scenarios: ['CHAT-01', 'CHAT-02'],
|
|
command: [process.execPath, '--test', 'chat-router.test.mjs'],
|
|
};
|
|
|
|
const liveSuite = {
|
|
id: 'page-data-product-scenarios',
|
|
mode: 'scenarios',
|
|
scenarios: ['DATA-01', 'DATA-02'],
|
|
command: [process.execPath, 'scripts/run-release-gate-page-data-scenarios.mjs'],
|
|
};
|
|
|
|
const previousReport = {
|
|
mode: 'impact',
|
|
commit_sha: 'a'.repeat(40),
|
|
artifact_sha256: 'b'.repeat(64),
|
|
scenarios: [
|
|
{ id: 'CHAT-01', status: 'passed', evidence: ['suite=chat-routing-contract'] },
|
|
{ id: 'CHAT-02', status: 'passed', evidence: ['suite=chat-routing-contract'] },
|
|
{ id: 'DATA-01', status: 'failed', evidence: ['suite=page-data-product-scenarios'] },
|
|
{ id: 'DATA-02', status: 'passed', evidence: ['suite=page-data-product-scenarios'] },
|
|
],
|
|
};
|
|
|
|
test('commandFilesForSuite skips node and flags', () => {
|
|
assert.deepEqual(
|
|
commandFilesForSuite({ command: [process.execPath, '--test', 'chat-router.test.mjs'] }),
|
|
['chat-router.test.mjs'],
|
|
);
|
|
});
|
|
|
|
test('same commit and artifact skips passed suites and reruns failed live suites', () => {
|
|
const selectedIds = new Set(['CHAT-01', 'CHAT-02', 'DATA-01', 'DATA-02']);
|
|
assert.equal(shouldRerunImpactSuite({
|
|
suite: chatSuite,
|
|
selectedIds,
|
|
previousReport,
|
|
artifactSha256: previousReport.artifact_sha256,
|
|
commitSha: previousReport.commit_sha,
|
|
}), false);
|
|
assert.equal(shouldRerunImpactSuite({
|
|
suite: liveSuite,
|
|
selectedIds,
|
|
previousReport,
|
|
artifactSha256: previousReport.artifact_sha256,
|
|
commitSha: previousReport.commit_sha,
|
|
}), true);
|
|
});
|
|
|
|
test('artifact mismatch forces every selected suite to rerun', () => {
|
|
assert.equal(shouldRerunImpactSuite({
|
|
suite: chatSuite,
|
|
selectedIds: new Set(['CHAT-01', 'CHAT-02']),
|
|
previousReport,
|
|
artifactSha256: 'c'.repeat(64),
|
|
commitSha: previousReport.commit_sha,
|
|
}), true);
|
|
});
|
|
|
|
test('live suites rerun on a new commit even when previous cases passed', () => {
|
|
const passedLive = {
|
|
...previousReport,
|
|
scenarios: [
|
|
{ id: 'DATA-01', status: 'passed' },
|
|
{ id: 'DATA-02', status: 'passed' },
|
|
],
|
|
};
|
|
assert.equal(shouldRerunImpactSuite({
|
|
suite: liveSuite,
|
|
selectedIds: new Set(['DATA-01', 'DATA-02']),
|
|
previousReport: passedLive,
|
|
artifactSha256: passedLive.artifact_sha256,
|
|
commitSha: 'd'.repeat(40),
|
|
}), true);
|
|
});
|
|
|
|
test('changing a suite command file invalidates that suite', () => {
|
|
assert.equal(suiteInvalidatedByChanges(chatSuite, ['chat-router.test.mjs']), true);
|
|
assert.equal(suiteInvalidatedByChanges(chatSuite, ['wechat-mp.mjs']), false);
|
|
assert.equal(suiteInvalidatedByChanges(chatSuite, ['release-gate/coverage.mjs']), true);
|
|
assert.equal(
|
|
suiteInvalidatedByChanges(liveSuite, ['scripts/run-release-gate-runtime-container.mjs']),
|
|
false,
|
|
);
|
|
assert.equal(
|
|
suiteInvalidatedByChanges(liveSuite, ['scripts/run-release-gate-page-data-scenarios.mjs']),
|
|
true,
|
|
);
|
|
});
|
|
|
|
test('carryForwardScenario keeps prior evidence and marks reuse', () => {
|
|
const carried = carryForwardScenario({ id: 'CHAT-01', status: 'passed', evidence: ['old'] });
|
|
assert.equal(carried.status, 'passed');
|
|
assert.deepEqual(carried.evidence, ['old', 'carried_forward=true']);
|
|
});
|