test: finish 1.11 archive and source package validation

This commit is contained in:
Agent Workbench Dev
2026-10-30 14:17:33 +08:00
parent 20691139f0
commit 4516f66ab6
6 changed files with 68 additions and 10 deletions
+6 -2
View File
@@ -9,15 +9,19 @@ const evidence = JSON.parse(fs.readFileSync('.qa/archives-validation.json', 'utf
assert.equal(evidence.success, true);
assert.ok(evidence.extractionRoot, 'Run python scripts/verify-archives.py --extract-source first.');
const sourceRoot = fs.realpathSync.native(evidence.extractionRoot);
assert.ok(sourceRoot.startsWith(path.resolve('.qa') + path.sep));
const archiveQaRoot = path.resolve(process.env.AGENT_WORKBENCH_ARCHIVE_QA_ROOT || '.qa');
assert.ok(sourceRoot.startsWith(archiveQaRoot + path.sep));
const npmCli = path.join(path.dirname(process.execPath), 'node_modules/npm/bin/npm-cli.js');
assert.ok(fs.existsSync(npmCli), 'Use Node with its bundled npm.');
const files = (root, relative = '') => fs.readdirSync(path.join(root, relative), { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))
.flatMap(entry => entry.isDirectory() ? files(root, path.join(relative, entry.name)) : [path.join(relative, entry.name)]);
const digest = file => createHash('sha256').update(fs.readFileSync(file)).digest('hex');
const expected = Object.fromEntries(['dist-client', 'dist-server'].flatMap(folder => files(path.join(workspace, folder)).map(relative => [path.join(folder, relative), digest(path.join(workspace, folder, relative))])));
const allowedEnv = /^(path|pathext|systemroot|systemdrive|windir|comspec|temp|tmp|userprofile|homedrive|homepath|home|appdata|localappdata|programfiles(?:\(x86\))?|commonprogramfiles(?:\(x86\))?|lang|lc_all|AGENT_WORKBENCH_TEST_PYTHON)$/i;
const allowedEnv = /^(path|pathext|systemroot|systemdrive|windir|comspec|temp|tmp|userprofile|homedrive|homepath|home|appdata|localappdata|programfiles(?:\(x86\))?|commonprogramfiles(?:\(x86\))?|lang|lc_all|AGENT_WORKBENCH_TEST_PYTHON|AGENT_WORKBENCH_DEEPSEEK_ROOT)$/i;
const env = Object.fromEntries(Object.entries(process.env).filter(([key]) => allowedEnv.test(key)));
const inheritedPath = Object.entries(env).find(([key]) => key.toLowerCase() === 'path')?.[1] || '';
for (const key of Object.keys(env)) if (key.toLowerCase() === 'path') delete env[key];
env.PATH = [path.dirname(process.execPath), inheritedPath].filter(Boolean).join(path.delimiter);
let stage = 'install';
const resultFile = path.join(workspace, '.qa/source-package-validation.json');