From 0b4f1de4395e42999ade74fdaa7869919db883b6 Mon Sep 17 00:00:00 2001 From: Agent Workbench Dev Date: Sat, 7 Nov 2026 22:03:18 +0800 Subject: [PATCH] fix(ci): log Electron setup and verify the product Edge runtime --- .gitea/workflows/ci.yml | 1 + docs/CI.md | 4 ++-- docs/M2-CI-PLAN.md | 4 ++++ progress.md | 6 ++++++ scripts/ci-desktop-smoke.mjs | 7 ++++--- scripts/ci-environment.json | 2 +- scripts/ci.mjs | 4 ++-- scripts/verify-ci-workflow.mjs | 2 +- tests/ci-pipeline.test.mjs | 2 ++ 9 files changed, 23 insertions(+), 9 deletions(-) diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 99469b38..0736d819 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -43,4 +43,5 @@ jobs: name: windows-source-ci path: .qa/ci/**/evidence/** if-no-files-found: error + include-hidden-files: true retention-days: 14 diff --git a/docs/CI.md b/docs/CI.md index f12beeeb..c5f28a9c 100644 --- a/docs/CI.md +++ b/docs/CI.md @@ -14,11 +14,11 @@ | 范围 | 实际执行与判定 | | --- | --- | | contract | 四来源清单原字节、注册表及请求默认版本/字段/弃用快照、14指定行为回归和 CI/源码包专项;完整应用构建。可在支持 Node 的平台执行,当前其他平台实测状态另列。 | -| windows | 上述来源/构建与全部 `.test.mjs`,实际 Edge 必需;本次安装 Chromium 后执行网页及隐藏 Electron 1280/390 冒烟。安装/回退相关回归使用自有隔离 fixture,不接触正式服务。 | +| windows | 上述来源/构建与全部 `.test.mjs`,实际产品 Edge 必需;固定 Playwright 使用实际 Edge 及隐藏 Electron 执行 1280/390 冒烟。安装/回退相关回归使用自有隔离 fixture,不接触正式服务。 | Node TAP 的失败、取消、跳过、todo、缺完整统计或零测试均不能判定通过,不能通过删 Python/浏览器测试掩盖环境缺项。每条命令保存所属 PID、完整 argv、真实 exit/signal、原 stdout/stderr 字节及 SHA;源码和全部编译工件在结束后再次核对。网页/Electron 原截图、DOM、错误与所属关闭状态另存。 -GitAtlas 工作流为 `.gitea/workflows/ci.yml`,push / pull_request / 手工触发。Gitea 1.26.2 与仓库 Actions 已公开核实;运行/runner API 匿名 401,**可用执行器及远端运行尚未确认**。工作流要求独立 Windows x64 runner 标签 `awb-windows-x64:host`、PowerShell、Git、Edge及 action 所需 Node 16/20 执行能力,随后 action 安装固定 Node/Python。不会在正式电脑自动安装持久 runner。Action 均固定完整 commit,Checkout 同 commit 使用 Gitea 官方镜像;原 GitHub 网络失败完整保留。证据上传使用 Gitea actions v3 固定契约,实际上传与远端执行需要真实 job 回执。 +GitAtlas 工作流为 `.gitea/workflows/ci.yml`,push / pull_request / 手工触发。Gitea 1.26.2 与仓库 Actions 已公开核实;运行/runner API 匿名 401,**可用执行器及远端运行尚未确认**。工作流要求独立 Windows x64 runner 标签 `awb-windows-x64:host`、PowerShell、Git、Edge及 action 所需 Node 16/20 执行能力,随后 action 安装固定 Node/Python。不会在正式电脑自动安装持久 runner。Action 均固定完整 commit,Checkout 同 commit 使用 Gitea 官方镜像;原 GitHub 网络失败完整保留。证据上传使用 Gitea actions v3 固定契约,明确包含 `.qa` 的隐藏证据路径,仅上传 evidence 白名单;实际上传与远端执行需要真实 job 回执。 官方更新先保留原响应/失败/SHA,修改注册表和对应行为回归,再生成新快照、审查差异并追加 `tests/fixtures/official-contracts/INDEX.json` 的 history;旧快照保留。`--freeze` 只冻结,不能当作通过。命令: diff --git a/docs/M2-CI-PLAN.md b/docs/M2-CI-PLAN.md index 317c9b0a..6e4941e5 100644 --- a/docs/M2-CI-PLAN.md +++ b/docs/M2-CI-PLAN.md @@ -25,3 +25,7 @@ - YAML依赖准备器首相对import多退一级,实收ERR_MODULE_NOT_FOUND;原脚本保持,第二轮正确import成功,只新增yaml和根依赖声明两个lock条目。 - 官方快照首准备器把已有受控同级fixture引用误判为逃逸;原helper保存,改为整个固定`tests/fixtures`范围,仍逐原字节SHA核对,未改原SOURCE.json或来源正文。 - 首专项11项为10过1失败:新源码ZIP fixture未声明workflow的LF,实际Git archive按全局属性导出CRLF。保留原11项日志/测试,只为自有fixture明确声明与产品一致的workflow LF,再单独补验该文件。来源索引检查首.gitattributes工作文本CRLF与Git LF不一致,原字节保存后只规范该文本,14暂存原字节再核对通过。 +- 源码提交首CI入口末尾空行被diff检查拒绝,随后误继续启动CI被未提交输入前置检查拒绝。原preflight失败完整保留,修空行后才af42b949提交并另起干净run,不把失败算通过。 +- 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`证据;新增反例断言,不将原工作流静态通过当实际上传通过。 diff --git a/progress.md b/progress.md index 2c73fe54..d09b93fc 100644 --- a/progress.md +++ b/progress.md @@ -1,5 +1,11 @@ # 统一执行进度 +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不动。 + +CI源码af42b949已限定提交20输入;来源a43262c1。首提交空行检查拒绝后误启动的preflight失败保持。干净run b499f71d已真正npm ci(38s)/锁依赖树/来源/工作流、Python3.11.15新venv及七wheel/pytest8.4.2/pip25.3全过;Electron路径getter触发隐式未独立记日志下载,已定位,下一显式过滤环境下载并另固定提交/新run。无模型/Key/正式操作,原11/11不代签新干净运行。 + I27/I28源码阶段最终专项11/11、官方四来源清单/26记录/14回归输入与workflow真正YAML检查通过;首10/11和两个来源辅助失败保持。工作流只打包精确ci.yml,不遍历.gitea其它配置。实现从已提交HEAD导出/新依赖/venv/原日志/源码及编译前后核对,缺环境/真实跳过非零退出,实际桌面冒烟已准备。限定提交后执行独立干净Windows全套,正式/真实模型/Key/旧工程不动。 I27/I28来源阶段本地提交完成:14输入逐Git/原字节与已知凭据签名核对,7官方CI来源/4 action ref/7 PyPI wheel固定。官方契约完整44来源/26记录/14回归文件首离线通过;快照首同级引用、原source-package LF与.gitattributes文本CRLF失败保持。新专项首10/11,9新CI/官方检查通过,源码ZIP fixture补明确LF后单独复验。统一入口和实际桌面/干净环境验证继续,尚未远端执行/发行/正式写入。 diff --git a/scripts/ci-desktop-smoke.mjs b/scripts/ci-desktop-smoke.mjs index ff1fc83f..15e2adb4 100644 --- a/scripts/ci-desktop-smoke.mjs +++ b/scripts/ci-desktop-smoke.mjs @@ -8,11 +8,12 @@ import { HostController } from '../src/core/desktop/host-controller.mjs'; import { observeWindowsProcess } from '../src/core/desktop/process-identity.mjs'; import { desktopExecutableIdentity } from '../src/core/desktop/app-installation.mjs'; import { projectEnvironment } from '../src/core/process-environment.mjs'; +import { browserInstallation } from '../src/core/browser/browser-driver.mjs'; import { openWorkbenchTool } from './ui-navigation.mjs'; import { fileDigest, writeNewJson } from './ci-utils.mjs'; const args=process.argv.slice(2); -if(args.includes('--help')) {console.log('node scripts/ci-desktop-smoke.mjs --evidence NEW_DIRECTORY — actual locked Chromium and hidden Electron against an owned new host/project. No model, external project, formal configuration or installation.');process.exit(0);} +if(args.includes('--help')) {console.log('node scripts/ci-desktop-smoke.mjs --evidence NEW_DIRECTORY — actual product Microsoft Edge and hidden Electron through locked Playwright against an owned new host/project. No model, external project, formal configuration or installation.');process.exit(0);} if(args.length!==2 || args[0]!=='--evidence')throw new Error('Use --help'); assert.equal(process.platform,'win32'); const appRoot=process.cwd(),evidence=path.resolve(args[1]);fs.mkdirSync(evidence); @@ -21,7 +22,7 @@ const original=Buffer.from('# Owned CI project\n\nSource retained while actual w fs.writeFileSync(path.join(projectRoot,'README.md'),original,{flag:'wx'}); const reservation=net.createServer();await new Promise(resolve=>reservation.listen(0,'127.0.0.1',resolve));const port=reservation.address().port;await new Promise(resolve=>reservation.close(resolve)); const controller=new HostController({appRoot,dataRoot,port,nodePath:process.execPath,timeoutMs:60000}); -const report={schemaVersion:1,passed:false,startedAt:new Date().toISOString(),ownedRoot,port,groups:[],screenshots:[],pageErrors:[],externalRequests:[],scope:'Actual isolated Chromium/Electron and owned source/data only; no model or formal installation.'}; +const report={schemaVersion:1,passed:false,startedAt:new Date().toISOString(),ownedRoot,port,groups:[],screenshots:[],pageErrors:[],externalRequests:[],scope:'Actual isolated product Microsoft Edge/Electron through locked Playwright and owned source/data only; no model or formal installation.'}; let browser,application,electronPid,hostIdentity,stage='host-start'; const record=(name,detail={})=>report.groups.push({name,passed:true,...detail}); const watch=(page)=>{page.on('pageerror',error=>report.pageErrors.push(error.message));page.on('request',request=>{const url=new URL(request.url());if(['http:','https:'].includes(url.protocol) && !(url.hostname==='127.0.0.1' && Number(url.port)===port))report.externalRequests.push(request.url());});}; @@ -53,7 +54,7 @@ try{ hostIdentity=(await controller.start()).identity;report.host={pid:hostIdentity.pid,createdAt:hostIdentity.createdAt}; const project=await controller.api('/projects',{method:'POST',input:{root:projectRoot}}),session=await controller.api('/sessions',{method:'POST',input:{projectId:project.id}}); record('owned new host/project/session',{projectId:project.id,sessionId:session.id}); - stage='chromium';browser=await chromium.launch({headless:true});report.chromiumVersion=browser.version(); + stage='product-edge';const edge=browserInstallation(appRoot);assert.equal(edge.status,'available','Product Microsoft Edge is required');report.edge=edge;browser=await chromium.launch({executablePath:edge.executable.path,headless:true});report.edgeVersion=browser.version(); const page=await browser.newPage({viewport:{width:1280,height:900}});watch(page);await page.goto(controller.url);await userPath(page,'web',project.id);await browser.close();browser=null; stage='electron';const executable=desktopExecutableIdentity(appRoot).path; application=await _electron.launch({executablePath:executable,args:[path.join(appRoot,'dist-desktop/main.cjs'),'--app-root',appRoot,'--data-root',dataRoot,'--node',process.execPath,'--port',String(port),'--hidden-window'],cwd:appRoot,env:projectEnvironment(),timeout:60000}); diff --git a/scripts/ci-environment.json b/scripts/ci-environment.json index b7f6e182..ce57a9a3 100644 --- a/scripts/ci-environment.json +++ b/scripts/ci-environment.json @@ -10,7 +10,7 @@ "runnerLabel": "awb-windows-x64", "profiles": { "contract": "Pinned official sources, registry/version/deprecation regressions and full application build. No Windows/real-provider claim.", - "windows": "Fresh locked dependencies, full source tests without skips, Microsoft Edge, actual Chromium/Electron smoke and owned installation regressions. No formal installation or model request." + "windows": "Fresh locked dependencies, full source tests without skips, actual product Microsoft Edge/Electron through locked Playwright and owned installation regressions. No formal installation or model request." }, "actions": { "checkout": "https://gitea.com/actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683", diff --git a/scripts/ci.mjs b/scripts/ci.mjs index 2b484eb5..9b8c924e 100644 --- a/scripts/ci.mjs +++ b/scripts/ci.mjs @@ -85,13 +85,13 @@ try { 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); + stage = 'explicit-electron-install'; + await nodeCommand('electron-install',['node_modules/electron/install.js']); 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) }; const { browserInstallation } = await import(pathToFileURL(path.join(run.source,'src/core/browser/browser-driver.mjs')).href); const edge = browserInstallation(run.source); assert.equal(edge.status,'available','Actual Microsoft Edge is required; do not skip browser tests.'); report.environment.edge = edge; - stage = 'chromium-install'; - await nodeCommand('chromium-install', ['node_modules/playwright/cli.js','install','chromium']); } stage = 'build'; await nodeCommand('build',[npmCli,'run','build']); report.build = builtFiles(run.source); writeNewJson(path.join(run.evidence,'build-inputs.json'),report.build); diff --git a/scripts/verify-ci-workflow.mjs b/scripts/verify-ci-workflow.mjs index 72fed7c6..00356727 100644 --- a/scripts/verify-ci-workflow.mjs +++ b/scripts/verify-ci-workflow.mjs @@ -21,7 +21,7 @@ export function verifyCiWorkflow(root) { const execution=job.steps.find(step=>step.run); assert.equal(execution.shell,'pwsh'); assert.match(execution.run,/scripts\/ci\.mjs --profile windows --python \$qaPython --output-root \.qa\/ci/); assert.match(execution.run,/exit \$LASTEXITCODE/); - const artifact=job.steps.at(-1); assert.equal(artifact.if,'always()'); assert.equal(artifact.with.path,'.qa/ci/**/evidence/**'); assert.equal(artifact.with['if-no-files-found'],'error'); + const artifact=job.steps.at(-1); assert.equal(artifact.if,'always()'); assert.equal(artifact.with.path,'.qa/ci/**/evidence/**'); assert.equal(artifact.with['if-no-files-found'],'error'); assert.equal(artifact.with['include-hidden-files'],true, 'The explicit .qa evidence directory must be uploaded'); return {passed:true,workflow:'.gitea/workflows/ci.yml',sha256:fileDigest(file),runnerLabel:lock.runnerLabel,actions:uses, scope:'Actual YAML parse, pinned action/Node/Python refs, error propagation and evidence upload contract. Does not assert runner availability or remote execution.'}; } diff --git a/tests/ci-pipeline.test.mjs b/tests/ci-pipeline.test.mjs index 989aed97..e3f0bbfb 100644 --- a/tests/ci-pipeline.test.mjs +++ b/tests/ci-pipeline.test.mjs @@ -49,6 +49,8 @@ test('actual YAML, immutable action refs and original failure upload are checked assert.throws(()=>verifyCiWorkflow(root)); document.jobs['windows-source'].steps.at(-1).if='always()';document.jobs['windows-source']['timeout-minutes']=30;fs.writeFileSync(path.join(root,'.gitea/workflows/ci.yml'),YAML.stringify(document)); assert.throws(()=>verifyCiWorkflow(root)); + delete document.jobs['windows-source']['timeout-minutes'];document.jobs['windows-source'].steps.at(-1).with['include-hidden-files']=false;fs.writeFileSync(path.join(root,'.gitea/workflows/ci.yml'),YAML.stringify(document)); + assert.throws(()=>verifyCiWorkflow(root)); }); test('a real committed source ZIP is verified before extraction and tampering cannot replace existing input',t=>{