修复macOS主机上AGC发布测试未stub Node运行时staging #444

Merged
suzmii merged 1 commits from fix/agc-test-node-runtime-stub into master 2026-09-21 12:23:53 +08:00
Member

现象

macOS 渠道构建自 #439 合入后每一轮都在测试阶段失败(#7 之后 #8/#9/#10 全部 2 分钟内 FAILURE):

error: 'Node 运行时平台/架构与发布目标不一致:darwin/arm64 → x86_64-pc-windows-msvc'
  at stageNodeRuntime (stage-node-runtime.mjs:243)
  at runTauriBuild (build-release.mjs:472)
  at build-release.test.mjs:213

为什么之前能过、现在不能

同一条测试,检出内容不同:

构建 检出提交 结果
Mac #6 1655a2eab(#419,02:02) 成功并发布 0.1.86
485ed50b2(#439,02:29)合入
Mac #7 485ed50b2 测试阶段失败

#6 的检出里不含 #439:那时 runTauriBuild 还没有 stageRuntime,用例自然通过。#439 之后,runTauriBuild 默认调用真实的 stageNodeRuntime(target),而渠道注入用例只注入了 spawn、没注入 stageRuntime,于是真实 staging 被执行:它拿宿主 Node 的 platform/arch 去比对发布目标,在非 Windows 主机上必然不匹配(macOS 节点是 darwin/arm64,用例的目标是默认的 windows/x64),直接抛错。Windows 主机上宿主与目标一致,所以该缺陷在 Windows 侧不可见。

改动

apps/ai-game-creator-shell/scripts/build-release.test.mjs 的渠道注入用例补上 stageRuntime: () => {},并注明原因。单文件、3 行。

验证

  • 本机(macOS / darwin-arm64,正是暴露该缺陷的环境)复现到与 Jenkins 完全相同的报错;修复后 build-release.test.mjs 37/37 通过
  • 该目录全部脚本测试 node --test apps/ai-game-creator-shell/scripts/*.test.mjs92/92 通过(确认没有其它同类跨平台缺陷)。
  • prettier --checknpm run check:encodinggit diff --check 通过。

本 PR 未解决、需要单独决策的后续阻塞

修完测试阶段后,macOS 构建会在同一条链路的下一个环节失败:

Error: Node 运行时不支持发布目标:universal-apple-darwin

原因:stage-node-runtime.mjstargetRuntime 只支持 x86_64-pc-windows-msvc / aarch64-apple-darwin / x86_64-apple-darwin;而 macOS 渠道按既定方案构建 universal-apple-darwin。同时 stageNodeRuntime 只从当前运行的 Nodeprocess.execPath)取材,无法产出另一种架构的运行时;Rust 侧 resolve_atallow_developmentcfg!(debug_assertions)release 构建没有系统 Node 回退,且代码注释明确禁止「随包缺失就静默用系统 Node」。

因此 macOS 要恢复发布,必须真正实现 universal 支持:两份架构运行时(含 x64 Node 分发来源与完整性校验)+ Rust 侧按运行架构选择 + 构建期资源映射调整。这涉及安装包体积增加(Node 单架构约数十 MB,双架构接近翻倍)与分发来源选择,属于 #439 能力范围的设计决策,不在本 PR 内擅自实现。

在它落地之前,macOS 渠道构建仍会在构建阶段失败;本 PR 只把失败点从「测试阶段」推进到真实的该阻塞点,并顺带修掉一个在非 Windows 主机上必然复现的测试缺陷。

## 现象 macOS 渠道构建自 #439 合入后每一轮都在**测试阶段**失败(#7 之后 #8/#9/#10 全部 2 分钟内 FAILURE): ``` error: 'Node 运行时平台/架构与发布目标不一致:darwin/arm64 → x86_64-pc-windows-msvc' at stageNodeRuntime (stage-node-runtime.mjs:243) at runTauriBuild (build-release.mjs:472) at build-release.test.mjs:213 ``` ## 为什么之前能过、现在不能 同一条测试,检出内容不同: | 构建 | 检出提交 | 结果 | | --- | --- | --- | | Mac #6 | `1655a2eab`(#419,02:02) | 成功并发布 0.1.86 | | — | `485ed50b2`(#439,02:29)合入 | — | | Mac #7 | `485ed50b2` | 测试阶段失败 | #6 的检出里**不含** #439:那时 `runTauriBuild` 还没有 `stageRuntime`,用例自然通过。#439 之后,`runTauriBuild` 默认调用真实的 `stageNodeRuntime(target)`,而渠道注入用例只注入了 `spawn`、没注入 `stageRuntime`,于是真实 staging 被执行:它拿**宿主** Node 的 `platform/arch` 去比对**发布目标**,在非 Windows 主机上必然不匹配(macOS 节点是 darwin/arm64,用例的目标是默认的 windows/x64),直接抛错。Windows 主机上宿主与目标一致,所以该缺陷在 Windows 侧不可见。 ## 改动 `apps/ai-game-creator-shell/scripts/build-release.test.mjs` 的渠道注入用例补上 `stageRuntime: () => {}`,并注明原因。单文件、3 行。 ## 验证 - 本机(macOS / darwin-arm64,正是暴露该缺陷的环境)复现到与 Jenkins 完全相同的报错;修复后 `build-release.test.mjs` **37/37 通过**。 - 该目录全部脚本测试 `node --test apps/ai-game-creator-shell/scripts/*.test.mjs`:**92/92 通过**(确认没有其它同类跨平台缺陷)。 - `prettier --check`、`npm run check:encoding`、`git diff --check` 通过。 ## 本 PR 未解决、需要单独决策的后续阻塞 修完测试阶段后,macOS 构建会在同一条链路的下一个环节失败: ``` Error: Node 运行时不支持发布目标:universal-apple-darwin ``` 原因:`stage-node-runtime.mjs` 的 `targetRuntime` 只支持 `x86_64-pc-windows-msvc` / `aarch64-apple-darwin` / `x86_64-apple-darwin`;而 macOS 渠道按既定方案构建 `universal-apple-darwin`。同时 `stageNodeRuntime` 只从**当前运行的 Node**(`process.execPath`)取材,无法产出另一种架构的运行时;Rust 侧 `resolve_at` 的 `allow_development` 为 `cfg!(debug_assertions)`,**release 构建没有系统 Node 回退**,且代码注释明确禁止「随包缺失就静默用系统 Node」。 因此 macOS 要恢复发布,必须真正实现 universal 支持:两份架构运行时(含 x64 Node 分发来源与完整性校验)+ Rust 侧按运行架构选择 + 构建期资源映射调整。这涉及安装包体积增加(Node 单架构约数十 MB,双架构接近翻倍)与分发来源选择,属于 #439 能力范围的设计决策,不在本 PR 内擅自实现。 在它落地之前,macOS 渠道构建仍会在构建阶段失败;本 PR 只把失败点从「测试阶段」推进到真实的该阻塞点,并顺带修掉一个在非 Windows 主机上必然复现的测试缺陷。
suzmii added 1 commit 2026-09-21 11:01:38 +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项全通过
suzmii merged commit a5ee06a4c7 into master 2026-09-21 12:23:53 +08:00
suzmii deleted branch fix/agc-test-node-runtime-stub 2026-09-21 12:23:53 +08:00
Sign in to join this conversation.