AGC macOS universal 随包 Node 双架构运行时(修复 Mac 管线 #7 起连续失败) #445

Closed
suzmii wants to merge 3 commits from feat/agc-macos-universal-node-runtime into master
Member

问题

Genarrative-Agc-MacOS-Build 从 build #7 起连续失败(#7 8 分钟、#8~#10 2 分钟):#439 引入随包 Node 运行时 staging 后,runTauriBuild 默认按宿主平台取材(darwin/arm64),而发布目标是 Windows,直接抛「Node 运行时平台/架构与发布目标不一致」。更关键的是:Mac 管线一直按 universal-apple-darwin 构建,而 staging 根本不认识 universal——stageNodeRuntime('universal-apple-darwin') 会抛「Node 运行时不支持发布目标」,即使跳过测试也是死路;此前 build #6 之所以成功,是因为它检出的 commit 早于 #439。

方案(方案 A)

真正实现 universal 的随包 Node 支持:按架构各带一份官方运行时,而不是让 Mac 包少带或不带。

  • stage-node-runtime.mjs
    • 新增 targetRuntimesuniversal-apple-darwin 展开为 aarch64-apple-darwin + x86_64-apple-darwin,其余目标仍是一份。
    • 新增 runtimeSourceForTarget:宿主架构取当前构建 Node(process.execPath),非宿主架构必须由构建节点用 AGC_NODE_RUNTIME_<PLATFORM>_<ARCH>_PATH 显式提供,缺失即失败关闭——不静默跳过、不回退系统 Node、不从项目或相对 PATH 借运行时。
    • stageNodeRuntime 拆成 inspectRuntimeSource(只读校验)+ writeRuntimeBundle(落盘),stageNodeRuntimeForTarget 先校验全部来源再逐个落盘:缺一份、架构不符、两套版本不一致都在写出任何资源目录之前失败,不留下半套运行时冒充发布内容。
    • 单架构目标仍写扁平 node-runtime/(行为不变),universal 写 node-runtime/<platform>-<arch>/,与捆绑 Codex 的分架构目录同形态。
  • build-release.mjs:默认 stageRuntime 改为按发布目标 stage。
  • environment_check.rsresolve_at 在既有扁平目录之后按当前运行架构查找 <platform>-<arch> 子目录;两个候选都要过清单的平台/架构校验,存在但损坏一律失败关闭,绝不退回系统 Node。单架构包与开发态行为不变。
  • check-macos-bundle.mjs:两份切片的清单完整性、文件集合、许可、lipo -archs 架构与目录名一致性全部核对;只执行与当次 smoke 架构一致的那一份(另一份由另一次 smoke 覆盖);资源扫描放行两种 node_modules 布局。
  • Jenkinsfile:AGC_NODE_RUNTIME_DARWIN_X64_HOME(默认 ~/Library/Jenkins/node/darwin-x64)声明另一架构来源,Toolchain 阶段在编译前核对存在性与同版本,Package 阶段导出 ..._PATH / ..._LICENSE_PATH
  • 文档:开发运维文档记录节点前置(官方 darwin-x64 发行版安装 + SHASUMS256 校验 + lipo/arch 核对命令)、同版本要求、按架构布局、Rust 侧选择规则与约 260 MB 解包体积代价;实施计划与更新检查方案同步该契约。

验证

  • node --test apps/ai-game-creator-shell/scripts/*.test.mjs → 95/95(新增 3 个:双架构 staging 与清单、缺非宿主运行时失败关闭且不留半成品、两套版本不一致报错且不落盘)。
  • TMPDIR=/private/tmp cargo test --locked --manifest-path apps/ai-game-creator-shell/src-tauri/Cargo.toml --bin genarrative-ai-game-creator-shell environment_check:: → 16 passed(含新增用例:按运行架构解析 universal 目录、另一架构目录损坏/缺失都不影响本架构选择)。
  • 真机 staging 实测(本机 arm64 宿主 + 官方 darwin-x64 发行版):两份切片均生成 v22.23.2 / npm 10.9.8 的独立清单。
  • npm run check:encoding / check:doc-index / check:production-ops / check:rustfmt、prettier、eslint、git diff --check 全部通过。
  • 端到端 universal 构建(含双架构 smoke 与 DMG)由 Jenkins 干跑验证。

依赖

本分支基于 fix/agc-test-node-runtime-stub(#444,同一原因的另一半:非 Windows 主机上发布测试未 stub staging)。#444 合并后本 PR 的 diff 只剩双架构运行时改造;即使 #444 未合并,本分支自身也包含该修复,不依赖外部合并顺序。

不做

Windows 侧不改(本机 CI 缺 CMake 是既存问题,与本次改动无关);Apple 签名与公证仍缺,本次不涉及。

## 问题 `Genarrative-Agc-MacOS-Build` 从 build #7 起连续失败(#7 8 分钟、#8~#10 2 分钟):#439 引入随包 Node 运行时 staging 后,`runTauriBuild` 默认按**宿主平台**取材(darwin/arm64),而发布目标是 Windows,直接抛「Node 运行时平台/架构与发布目标不一致」。更关键的是:Mac 管线一直按 `universal-apple-darwin` 构建,而 staging 根本不认识 universal——`stageNodeRuntime('universal-apple-darwin')` 会抛「Node 运行时不支持发布目标」,即使跳过测试也是死路;此前 build #6 之所以成功,是因为它检出的 commit 早于 #439。 ## 方案(方案 A) 真正实现 universal 的随包 Node 支持:按架构各带一份官方运行时,而不是让 Mac 包少带或不带。 - `stage-node-runtime.mjs` - 新增 `targetRuntimes`:`universal-apple-darwin` 展开为 `aarch64-apple-darwin` + `x86_64-apple-darwin`,其余目标仍是一份。 - 新增 `runtimeSourceForTarget`:宿主架构取当前构建 Node(`process.execPath`),**非宿主架构必须由构建节点用 `AGC_NODE_RUNTIME_<PLATFORM>_<ARCH>_PATH` 显式提供**,缺失即失败关闭——不静默跳过、不回退系统 Node、不从项目或相对 PATH 借运行时。 - 把 `stageNodeRuntime` 拆成 `inspectRuntimeSource`(只读校验)+ `writeRuntimeBundle`(落盘),`stageNodeRuntimeForTarget` **先校验全部来源再逐个落盘**:缺一份、架构不符、两套版本不一致都在写出任何资源目录之前失败,不留下半套运行时冒充发布内容。 - 单架构目标仍写扁平 `node-runtime/`(行为不变),universal 写 `node-runtime/<platform>-<arch>/`,与捆绑 Codex 的分架构目录同形态。 - `build-release.mjs`:默认 `stageRuntime` 改为按发布目标 stage。 - `environment_check.rs`:`resolve_at` 在既有扁平目录之后按**当前运行架构**查找 `<platform>-<arch>` 子目录;两个候选都要过清单的平台/架构校验,存在但损坏一律失败关闭,绝不退回系统 Node。单架构包与开发态行为不变。 - `check-macos-bundle.mjs`:两份切片的清单完整性、文件集合、许可、`lipo -archs` 架构与目录名一致性全部核对;只执行与当次 smoke 架构一致的那一份(另一份由另一次 smoke 覆盖);资源扫描放行两种 node_modules 布局。 - Jenkinsfile:`AGC_NODE_RUNTIME_DARWIN_X64_HOME`(默认 `~/Library/Jenkins/node/darwin-x64`)声明另一架构来源,Toolchain 阶段在编译前核对存在性与**同版本**,Package 阶段导出 `..._PATH` / `..._LICENSE_PATH`。 - 文档:开发运维文档记录节点前置(官方 darwin-x64 发行版安装 + SHASUMS256 校验 + `lipo`/`arch` 核对命令)、同版本要求、按架构布局、Rust 侧选择规则与约 260 MB 解包体积代价;实施计划与更新检查方案同步该契约。 ## 验证 - `node --test apps/ai-game-creator-shell/scripts/*.test.mjs` → 95/95(新增 3 个:双架构 staging 与清单、缺非宿主运行时失败关闭且不留半成品、两套版本不一致报错且不落盘)。 - `TMPDIR=/private/tmp cargo test --locked --manifest-path apps/ai-game-creator-shell/src-tauri/Cargo.toml --bin genarrative-ai-game-creator-shell environment_check::` → 16 passed(含新增用例:按运行架构解析 universal 目录、另一架构目录损坏/缺失都不影响本架构选择)。 - 真机 staging 实测(本机 arm64 宿主 + 官方 darwin-x64 发行版):两份切片均生成 `v22.23.2` / npm `10.9.8` 的独立清单。 - `npm run check:encoding` / `check:doc-index` / `check:production-ops` / `check:rustfmt`、prettier、eslint、`git diff --check` 全部通过。 - 端到端 universal 构建(含双架构 smoke 与 DMG)由 Jenkins 干跑验证。 ## 依赖 本分支基于 `fix/agc-test-node-runtime-stub`(#444,同一原因的另一半:非 Windows 主机上发布测试未 stub staging)。#444 合并后本 PR 的 diff 只剩双架构运行时改造;即使 #444 未合并,本分支自身也包含该修复,不依赖外部合并顺序。 ## 不做 Windows 侧不改(本机 CI 缺 CMake 是既存问题,与本次改动无关);Apple 签名与公证仍缺,本次不涉及。
suzmii added 3 commits 2026-09-21 11:58:52 +08:00
修复非Windows主机上AGC发布测试未stub Node运行时staging
Project CI / AI game creator shell Rust smoke (pull_request) Successful in 2m9s
Project CI / Backend tests (pull_request) Failing after 10s
Project CI / AI game creator shell Rust crates (pull_request) Successful in 1m10s
Project CI / AI game creator shell Rust lane 1/2 (pull_request) Failing after 6m19s
Project CI / Repository checks (pull_request) Failing after 10s
Project CI / AI game creator shell Rust lane 2/2 (pull_request) Failing after 7m16s
Project CI / AI game creator shell web tests (pull_request) Successful in 7m2s
Project CI / Frontend tests (pull_request) Successful in 9m46s
Project CI / Native shell tests (pull_request) Successful in 11m46s
9f15c1c572
build-release.test.mjs的渠道注入用例漏注入stageRuntime,真实staging会用宿主平台与默认Windows目标做一致性校验
该缺陷在macOS主机上必然失败,卡住macOS渠道构建的测试阶段
补上stageRuntime stub,本机(darwin/arm64)验证37项全通过
- stage-node-runtime 新增 targetRuntimes:universal 展开为 aarch64/x86_64 两份单架构运行时
- 新增 runtimeSourceForTarget:宿主架构取当前构建 Node,其它架构必须由 AGC_NODE_RUNTIME_<PLATFORM>_<ARCH>_PATH 显式提供,缺失即失败关闭
- 把 stageNodeRuntime 拆成 inspectRuntimeSource(只读校验)+ writeRuntimeBundle(落盘),universal 在写出任何目录前完成全部来源校验与版本一致性核对
- stageNodeRuntimeForTarget 单架构仍写扁平 node-runtime/,universal 按架构写 node-runtime/<platform>-<arch>/
- build-release 默认按发布目标 stage,universal 构建不再只带宿主架构的运行时
- environment_check resolve_at 在扁平目录之后按当前运行架构查找 <platform>-<arch> 子目录,两份候选都要过清单校验,存在但损坏则失败关闭
- 覆盖双架构 staging、缺非宿主运行时、版本不一致、按运行架构解析等用例
macOS universal 管线接入双架构 Node 运行时前置
Project CI / Frontend tests (pull_request) Has been cancelled
Project CI / AI game creator shell Rust lane 1/2 (pull_request) Has been cancelled
Project CI / AI game creator shell Rust lane 2/2 (pull_request) Has been cancelled
Project CI / AI game creator shell Rust smoke (pull_request) Has been cancelled
Project CI / AI game creator shell Rust crates (pull_request) Has been cancelled
Project CI / Backend tests (pull_request) Has been cancelled
Project CI / Native shell tests (pull_request) Has been cancelled
Project CI / Repository checks (pull_request) Has been cancelled
Project CI / AI game creator shell web tests (pull_request) Has been cancelled
91f1554ac7
- Jenkinsfile.ai-game-creator-shell-macos-build 增加 AGC_NODE_RUNTIME_DARWIN_X64_HOME,并在 Toolchain 阶段编译前核对 x86_64 发行版存在且与构建 Node 同版本
- Package 阶段导出 AGC_NODE_RUNTIME_DARWIN_X64_PATH / _LICENSE_PATH,供 universal staging 取另一架构来源
- 开发运维文档记录节点前置:官方 darwin-x64 发行版安装与校验命令、同版本要求、按架构并列的资源布局、Rust 侧按运行架构选择、约 260 MB 解包体积代价,以及本机跨架构诊断构建的取值方式
- 实施计划与更新检查方案文档同步 universal 携带两套架构运行时的契约
suzmii added 1 commit 2026-09-21 12:07:06 +08:00
另一架构切片不得借用宿主 npm
Project CI / AI game creator shell Rust smoke (pull_request) Successful in 3m55s
Project CI / Backend tests (pull_request) Failing after 16s
Project CI / AI game creator shell Rust crates (pull_request) Successful in 1m17s
Project CI / AI game creator shell Rust lane 2/2 (pull_request) Failing after 6m48s
Project CI / Repository checks (pull_request) Failing after 15s
Project CI / AI game creator shell Rust lane 1/2 (pull_request) Failing after 7m43s
Project CI / AI game creator shell web tests (pull_request) Successful in 5m28s
Project CI / Frontend tests (pull_request) Successful in 8m34s
Project CI / Native shell tests (pull_request) Successful in 12m47s
92c05428ec
- runtimeSourceForTarget 对非宿主架构返回 npmCli: null,明令按该发行版自己的安装目录查找 npm
- 覆盖经 npm run 触发(npm_execpath 指向宿主 npm)时两份切片仍各带自己那份 npm 的用例
suzmii closed this pull request 2026-09-21 12:31:21 +08:00
Some checks are pending
Project CI / AI game creator shell Rust smoke (pull_request) Successful in 3m55s
Project CI / Backend tests (pull_request) Failing after 16s
Project CI / AI game creator shell Rust crates (pull_request) Successful in 1m17s
Project CI / AI game creator shell Rust lane 2/2 (pull_request) Failing after 6m48s
Project CI / Repository checks (pull_request) Failing after 15s
Project CI / AI game creator shell Rust lane 1/2 (pull_request) Failing after 7m43s
Project CI / AI game creator shell web tests (pull_request) Successful in 5m28s
Project CI / Frontend tests (pull_request) Successful in 8m34s
Project CI / Native shell tests (pull_request) Successful in 12m47s

Pull request closed

Sign in to join this conversation.