|
|
|
@@ -6,16 +6,16 @@ import { createRequire } from 'node:module';
|
|
|
|
|
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
|
|
|
import { packageSource } from './package-source.mjs';
|
|
|
|
|
import { verifyOfficialContracts } from './official-contract-check.mjs';
|
|
|
|
|
import { createCiRun, ciEnvironment, loggedCommand, unpackVerifiedSource, verifySourceInputs, builtFiles, tapTotals, requireCompleteTests, fileDigest, writeNewJson } from './ci-utils.mjs';
|
|
|
|
|
import { createCiRun, ciEnvironment, loggedCommand, unpackVerifiedSource, verifySourceInputs, builtFiles, tapTotals, requireCompleteTests, fileDigest, writeNewJson, binaryMirror } from './ci-utils.mjs';
|
|
|
|
|
|
|
|
|
|
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
|
|
|
|
const args = process.argv.slice(2), options = { profile: 'contract', outputRoot: path.join(root, '.qa/ci'), python: process.env.AGENT_WORKBENCH_TEST_PYTHON };
|
|
|
|
|
if (args.includes('--help')) {
|
|
|
|
|
console.log('node scripts/ci.mjs [--profile contract|windows] [--python ABSOLUTE_BASE_PYTHON] [--output-root DIRECTORY]\nExports committed Git source to a new directory; performs a real npm ci, official contract/build/test checks and Windows smoke. No current node_modules, data, keys or engine installation are reused. Each invocation preserves its own logs and failures.');
|
|
|
|
|
console.log('node scripts/ci.mjs [--profile contract|windows] [--python ABSOLUTE_BASE_PYTHON] [--output-root DIRECTORY] [--electron-mirror HTTPS_DIRECTORY]\nExports committed Git source to a new directory; performs a real npm ci, official contract/build/test checks and Windows smoke. No current node_modules, data, keys or engine installation are reused. Each invocation preserves its own logs and failures. An explicit binary mirror uses the same locked official checksums.');
|
|
|
|
|
process.exit(0);
|
|
|
|
|
}
|
|
|
|
|
for (let i=0;i<args.length;i++) {
|
|
|
|
|
const name = { '--profile':'profile', '--python':'python', '--output-root':'outputRoot' }[args[i]];
|
|
|
|
|
const name = { '--profile':'profile', '--python':'python', '--output-root':'outputRoot', '--electron-mirror':'electronMirror' }[args[i]];
|
|
|
|
|
if (!name || !args[i+1]) throw new Error('Unsupported CI argument; use --help');
|
|
|
|
|
options[name] = args[++i];
|
|
|
|
|
}
|
|
|
|
@@ -39,6 +39,7 @@ try {
|
|
|
|
|
assert.equal(git(['ls-files','--others','--exclude-standard','--',...inputPaths]), '', 'Untracked program or test inputs are not part of committed CI.');
|
|
|
|
|
const lock = JSON.parse(fs.readFileSync(path.join(root, 'scripts/ci-environment.json')));
|
|
|
|
|
assert.equal(lock.schemaVersion, 1); assert.equal(process.version, 'v'+lock.node, 'Use the pinned Node runtime');
|
|
|
|
|
const electronMirror = binaryMirror(options.electronMirror);
|
|
|
|
|
if (options.profile === 'windows') assert.ok(process.platform === 'win32' && process.arch === 'x64', 'Windows profile requires actual Windows x64');
|
|
|
|
|
const npmCli = path.join(path.dirname(process.execPath), 'node_modules/npm/bin/npm-cli.js');
|
|
|
|
|
assert.ok(fs.statSync(npmCli).isFile(), 'Use Node with its bundled npm');
|
|
|
|
@@ -46,7 +47,7 @@ try {
|
|
|
|
|
report.environment = { node: { version: process.version, executable: process.execPath, sha256: fileDigest(process.execPath) }, npm: { version: lock.npm, cli: npmCli, sha256: fileDigest(npmCli) }, platform: process.platform, arch: process.arch, ciLockSha256: fileDigest(path.join(root,'scripts/ci-environment.json')) };
|
|
|
|
|
if (options.profile === 'windows') {
|
|
|
|
|
assert.ok(options.python && path.isAbsolute(options.python) && fs.statSync(options.python).isFile(), '--python or AGENT_WORKBENCH_TEST_PYTHON must name the absolute base QA Python.');
|
|
|
|
|
await command('python-base', options.python, ['-I','-c','import sys,json; print(json.dumps({"version":sys.version.split()[0],"executable":sys.executable,"baseExecutable":sys._base_executable,"basePrefix":sys.base_prefix}))'], run.tmp);
|
|
|
|
|
await command('python-base', options.python, ['-I','-X','utf8','-c','import sys,json; print(json.dumps({"version":sys.version.split()[0],"executable":sys.executable,"baseExecutable":sys._base_executable,"basePrefix":sys.base_prefix}))'], run.tmp);
|
|
|
|
|
const python = JSON.parse(readOutput('python-base')); assert.equal(python.version, lock.python, 'Pinned base Python version required');
|
|
|
|
|
report.environment.pythonBase = { ...python, sha256: fileDigest(options.python) };
|
|
|
|
|
}
|
|
|
|
@@ -78,15 +79,21 @@ try {
|
|
|
|
|
if (options.profile === 'windows') {
|
|
|
|
|
stage = 'fresh-python-qa';
|
|
|
|
|
const venv = path.join(run.root,'python-qa');
|
|
|
|
|
await command('python-venv',options.python,['-I','-m','venv',venv],run.tmp);
|
|
|
|
|
await command('python-venv',options.python,['-I','-X','utf8','-m','venv',venv],run.tmp);
|
|
|
|
|
const python = path.join(venv,'Scripts/python.exe'); env.AGENT_WORKBENCH_TEST_PYTHON = python;
|
|
|
|
|
await command('python-install',python,['-I','-m','pip','--isolated','install','--disable-pip-version-check','--no-input','--require-hashes','--only-binary=:all:','--index-url','https://pypi.org/simple','--cache-dir',path.join(run.cache,'pip'),'-r',path.join(run.source,'scripts/ci-python-requirements.txt')],run.tmp);
|
|
|
|
|
await command('python-packages',python,['-I','-c','import sys,pytest,pip,json; print(json.dumps({"python":sys.version.split()[0],"pytest":pytest.__version__,"pip":pip.__version__,"executable":sys.executable,"prefix":sys.prefix,"basePrefix":sys.base_prefix}))'],run.tmp);
|
|
|
|
|
await command('python-install',python,['-I','-X','utf8','-m','pip','--isolated','install','--disable-pip-version-check','--no-input','--require-hashes','--only-binary=:all:','--index-url','https://pypi.org/simple','--cache-dir',path.join(run.cache,'pip'),'-r',path.join(run.source,'scripts/ci-python-requirements.txt')],run.tmp);
|
|
|
|
|
await command('python-packages',python,['-I','-X','utf8','-c','import sys,pytest,pip,json; print(json.dumps({"python":sys.version.split()[0],"pytest":pytest.__version__,"pip":pip.__version__,"executable":sys.executable,"prefix":sys.prefix,"basePrefix":sys.base_prefix}))'],run.tmp);
|
|
|
|
|
const pythonInfo = JSON.parse(readOutput('python-packages')); assert.equal(pythonInfo.python,lock.python); assert.equal(pythonInfo.pytest,lock.pytest); assert.equal(pythonInfo.pip,lock.pip); assert.notEqual(pythonInfo.prefix,pythonInfo.basePrefix);
|
|
|
|
|
report.environment.pythonQa = { ...pythonInfo, sha256: fileDigest(python), requirementsSha256: fileDigest(path.join(run.source,'scripts/ci-python-requirements.txt')) };
|
|
|
|
|
await command('python-pip-check',python,['-I','-m','pip','--isolated','check'],run.tmp);
|
|
|
|
|
await command('python-pip-check',python,['-I','-X','utf8','-m','pip','--isolated','check'],run.tmp);
|
|
|
|
|
stage = 'explicit-electron-install';
|
|
|
|
|
await nodeCommand('electron-install',['node_modules/electron/install.js']);
|
|
|
|
|
const electronEnv = {};
|
|
|
|
|
if (electronMirror) {
|
|
|
|
|
electronEnv.ELECTRON_MIRROR = electronMirror;
|
|
|
|
|
electronEnv.ELECTRON_CUSTOM_DIR = lock.electron;
|
|
|
|
|
report.environment.electronDownload = { mirror: electronMirror, directory: lock.electron, explicit: true, checksumSource: 'locked electron/checksums.json', checksumFileSha256: fileDigest(path.join(run.source,'node_modules/electron/checksums.json')) };
|
|
|
|
|
} else report.environment.electronDownload = { mirror: null, explicit: false, checksumSource: 'locked electron/checksums.json', checksumFileSha256: fileDigest(path.join(run.source,'node_modules/electron/checksums.json')) };
|
|
|
|
|
await nodeCommand('electron-install',['node_modules/electron/install.js'],run.source,electronEnv);
|
|
|
|
|
const require = createRequire(path.join(run.source,'package.json'));
|
|
|
|
|
const electron = require('electron'); assert.ok(fs.statSync(electron).isFile(), 'Actual Electron binary missing');
|
|
|
|
|
report.environment.electron = { executable: electron, sha256: fileDigest(electron) };
|
|
|
|
|