fix(ci): keep binary source explicit and Python logs in UTF-8

This commit is contained in:
Agent Workbench Dev
2026-11-07 22:17:31 +08:00
parent 0b4f1de439
commit 36c6be4ff8
6 changed files with 37 additions and 10 deletions
+2
View File
@@ -11,6 +11,8 @@
其他开发机使用自身已核对的相同版本 Node 路径。npm 入口为 `npm run ci:contract` / `npm run ci:windows -- --python ...`。默认输出 `.qa/ci/run-.../evidence/report.json`,可用 `--output-root` 指定;每次新建目录,旧失败/日志不覆盖。数据/依赖/缓存位于同 run 的独立目录,不作为发布源码或 CI 证据上传。
默认 Electron 从官方 GitHub 发行地址下载。环境访问异常时可显式加 `--electron-mirror https://npmmirror.com/mirrors/electron/`,报告记录该公共镜像和官方锁定 `electron/checksums.json` 的 SHA;不继承电脑的镜像/代理/凭据配置,也不关闭校验。原官方失败仍单独保留。Python 命令明确 UTF-8,中文路径的原日志可直接核对。
| 范围 | 实际执行与判定 |
| --- | --- |
| contract | 四来源清单原字节、注册表及请求默认版本/字段/弃用快照、14指定行为回归和 CI/源码包专项;完整应用构建。可在支持 Node 的平台执行,当前其他平台实测状态另列。 |
+3
View File
@@ -29,3 +29,6 @@
- af42b949独立npm/Python/来源/工作流已通过;Electron包读取路径会spawnSync隐式下载,缺独立日志,随后实际成功并继续受记录的Chromium安装。保留原运行/进程观察,根源码改为在过滤环境内显式electron-install命令,后续另run;当前原run继续验证其自身冻结源码,不复写/冒签新入口。
- af42b949的Chromium下载正文持续0字节;只读HEAD为307→storage200但不证明正文成功。按pid62420/父64192/命令行核对后结束自有下载子树,原run非零失败保留。实际产品浏览器契约只要求Edge;改CI按实际Edge与Electron通过固定Playwright运行,不省略浏览器检查,缺Edge仍失败。
- 上传action默认不包含隐藏文件,复核发现需显式`include-hidden-files:true`才能保留白名单`.qa`证据;新增反例断言,不将原工作流静态通过当实际上传通过。
- 自有Chromium结束首条件误要求相对CLI命令带绝对工作目录、第二次JSON日期经Parse丢UTC类型导致误差8小时,均安全拒绝未结束进程。第三次从原JSON字符串精确解析UTC,pid/父/程序/参数/启动时点差0.003436秒一致后才结束;原run exit1、625374ms原下载日志保留(记录interrupted=false仅是外部taskkill未经过runner信号处理,不能解读为自然网络失败)。
- 0b4f1de4第二干净run在过滤环境下官方Electron下载暂存0字节,552652ms后经原PID/父/UTC身份核对主动结束,自有命令exit1/原日志保持。公共HEAD/首1024字节与完整响应首块探测成功只证明这些范围,未当成完整下载。新增显式公共二进制镜像选择(版本目录/原官方checksums不变)、Python UTF-8和URL不得携带凭据的边界,后续新run;不继承真实API或电脑下载配置。
- Mnemo记忆桥第一次源SHA实读一致,后来准备封存时已被并发更新为763d796b;校验即拒绝,当前新原文与旧观察分开保存,未采用新版本/接入服务/发模型/回复来源线程。
+4
View File
@@ -1,5 +1,9 @@
# 统一执行进度
0b4f1de4第二干净run止于官方Electron暂存0字节,552652ms后原pid3284/父60820/程序/UTC核对后主动结束,exit1与interrupted=false原字段保持;所有已过npm/venv/来源/工作流不冒称全套通过。公共官方及镜像HEAD/首范围确可读,完整下载仍待。显式公共镜像/官方checksum、Python UTF8及URL凭据拒绝已补,下一新run。Mnemo并发SHA变更被拒绝,本地只读反馈另存/不接入,主任务CI继续。
CI下载/上传修复0b4f1de4限定提交9输入,更新pipeline5/5。原Chromium实际625374ms/0正文,先两次身份条件安全拒绝,后从原JSON UTC与真实pid/父/参数/0.003436秒创建差核对才结束自有子树;原runner exit1和interrupted=false字段照存,另标外部人为结束,不能归成网络自然退出。新962be523从0b4f1de4再次真正干净npm/venv/显式Electron/Edge/全套运行中,正式和旧封存不动。
af42b949首干净run止于非产品必需Chromium正文0字节,HEAD成功不代替下载。自有62420/64192身份核对后结束下载子树,原npm/Python通过和Chromium失败分别保存;后续改为产品真实Edge/隐藏Electron实测,缺浏览器仍失败。显式Electron过滤环境/原日志与隐藏证据上传补强一起另提交。产品src与历史fixture未修改,不重复旧实验或正式操作。
af42b949干净run的隐式Electron实际已成功,正在独立cache下载Chromium197.5MiB;原run按自身冻结输入继续。ROOT显式electron-install改动未传入原run,需另提交/新run验证,不补造原下载PID/日志。仅源码stat脏标.gitattributes无实际diff;刷新索引另核对,未还原内容。下一关注编译/全套实际失败及两端冒烟,历史unknown不动。
+6
View File
@@ -8,6 +8,12 @@ import { readSourceZip } from './package-source.mjs';
export const digest = bytes => createHash('sha256').update(bytes).digest('hex');
export const fileDigest = file => digest(fs.readFileSync(file));
export const writeNewJson = (file, value) => fs.writeFileSync(file, JSON.stringify(value, null, 2) + '\n', { flag: 'wx' });
export function binaryMirror(value) {
if (!value) return null;
const url = new URL(value);
assert.ok(url.protocol === 'https:' && !url.username && !url.password && !url.search && !url.hash && url.pathname.endsWith('/'), 'Binary mirror must be an explicit HTTPS directory without credentials.');
return url.href;
}
export function createCiRun(outputRoot, profile) {
assert.ok(['contract', 'windows'].includes(profile), 'Unknown CI profile');
const root = path.resolve(outputRoot), run = path.join(root, `run-${profile}-${Date.now().toString(36)}-${randomUUID().slice(0,8)}`);
+16 -9
View File
@@ -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) };
+6 -1
View File
@@ -6,7 +6,7 @@ import path from 'node:path';
import { execFileSync } from 'node:child_process';
import { fileURLToPath } from 'node:url';
import YAML from 'yaml';
import { createCiRun, ciEnvironment, loggedCommand, tapTotals, requireCompleteTests, unpackVerifiedSource, fileDigest } from '../scripts/ci-utils.mjs';
import { createCiRun, ciEnvironment, loggedCommand, tapTotals, requireCompleteTests, unpackVerifiedSource, fileDigest, binaryMirror } from '../scripts/ci-utils.mjs';
import { packageSource } from '../scripts/package-source.mjs';
import { verifyCiWorkflow } from '../scripts/verify-ci-workflow.mjs';
@@ -23,6 +23,11 @@ test('fresh output runs are separate and excluded credential getters are never r
assert.equal(fs.readFileSync(env.npm_config_userconfig,'utf8'),''); assert.notEqual(env.npm_config_userconfig,env.npm_config_globalconfig);
});
test('a download mirror is an explicit public HTTPS directory and cannot carry credentials in URL or query',()=>{
assert.equal(binaryMirror(undefined),null);assert.equal(binaryMirror('https://npmmirror.com/mirrors/electron/'),'https://npmmirror.com/mirrors/electron/');
for(const value of ['http://example.invalid/electron/','https://owned:credential@example.invalid/','https://example.invalid/?token=owned','https://example.invalid/electron/#owned','https://example.invalid/file.zip'])assert.throws(()=>binaryMirror(value));
});
test('actual nonzero command, original stdout/stderr and spawn failure survive without replay or log overwrite',async t=>{
const run=createCiRun(owned(t),'contract'),env=ciEnvironment(run);
const result=await loggedCommand({id:'original-failure',executable:process.execPath,args:['-e',"process.stdout.write('original\\n');process.stderr.write('failure\\n');process.exitCode=7"],cwd:run.source,env,evidence:run.evidence,check:false});