60 lines
2.0 KiB
JavaScript
60 lines
2.0 KiB
JavaScript
import { execFileSync } from 'node:child_process';
|
|
import fs from 'node:fs';
|
|
import path from 'node:path';
|
|
|
|
const tasks = [
|
|
['TASK-WP5-03', 'origin/codex/wp5-03'],
|
|
['TASK-WP5-04', 'origin/codex/wp5-04'],
|
|
['TASK-WP5-05', 'origin/codex/wp5-05'],
|
|
['TASK-WP5-06', 'origin/codex/wp5-06'],
|
|
['TASK-WP5-07', 'origin/codex/wp5-07'],
|
|
];
|
|
|
|
function sha(ref) {
|
|
return execFileSync('git', ['rev-parse', ref], { encoding: 'utf8' }).trim();
|
|
}
|
|
|
|
function isAncestor(ref) {
|
|
try {
|
|
execFileSync('git', ['merge-base', '--is-ancestor', ref, 'HEAD'], { stdio: 'ignore' });
|
|
return true;
|
|
} catch {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
function run(command, args) {
|
|
try {
|
|
const executable = process.platform === 'win32' && command === 'pnpm' ? 'pnpm.cmd' : command;
|
|
execFileSync(executable, args, { stdio: 'pipe', encoding: 'utf8', shell: process.platform === 'win32' });
|
|
return { status: 'passed' };
|
|
} catch (error) {
|
|
return { status: 'failed', exit_code: error.status ?? 1 };
|
|
}
|
|
}
|
|
|
|
const checks = tasks.map(([task, ref]) => ({ task, ref, sha: sha(ref), ancestor: isAncestor(ref) }));
|
|
const regression = {
|
|
'TASK-WP5-06': run('node', ['scripts/run-wp5-06-validation.mjs']),
|
|
'TASK-WP5-07': run('node', ['scripts/run-wp5-07-validation.mjs']),
|
|
};
|
|
const status = checks.every((check) => check.ancestor)
|
|
&& Object.values(regression).every((check) => check.status === 'passed')
|
|
? 'ready_for_wp4_07'
|
|
: 'externally_blocked';
|
|
|
|
const output = {
|
|
schema_version: '1.0',
|
|
task: 'TASK-WP5-LINEAGE',
|
|
status,
|
|
checks,
|
|
regression,
|
|
note: 'This gate proves ancestry and targeted regressions only; it does not replace per-task UI/resource evidence.',
|
|
};
|
|
const runId = `wp5-lineage-${new Date().toISOString().replace(/[^0-9]/g, '')}`;
|
|
const outputDirectory = path.join('artifacts', 'tdd', runId);
|
|
fs.mkdirSync(outputDirectory, { recursive: true });
|
|
fs.writeFileSync(path.join(outputDirectory, 'lineage.json'), `${JSON.stringify(output, null, 2)}\n`, 'utf8');
|
|
console.log(JSON.stringify(output));
|
|
process.exitCode = status === 'ready_for_wp4_07' ? 0 : 3;
|