Repository navigation
fix(ci): 安装步骤加有界网络重试,跳过用不到的 electron 二进制下载 - #3199
Merged
Merged
Conversation
#3193 两处现场都是 GitHub release 下载 504:electron postinstall 一次不重试, setup-bun 只有 10s/18s 三次短重试。 - scripts/ci-net-retry.mjs:包住安装命令,最多 5 次、间隔 10/20/40/80s,只重试 网络/网关类失败;lockfile 漂移、依赖解析失败、404/401/403、完整性校验失败首次即红。 - .github/actions/setup-bun:从 npm registry 的 @oven/bun-<platform> 取 Bun,下载走重试, actions/cache 缓存;替换所有 oven-sh/setup-bun。 - 所有 workflow 与容器脚本里的 bun / npm / pnpm 安装改经 ci-net-retry.mjs。 - 装依赖的 workflow 顶层设 ELECTRON_SKIP_BINARY_DOWNLOAD=1,musl / glibc 容器也传入。 Closes #3193 Co-Authored-By: Claude Opus 5.5 <[email protected]>
deepcoldy
requested review from
47seek,
LucasIcarus,
xiaoxueSunn and
xiongz-c
as code owners
November 8, 2026 10:09
v4 跑在已弃用的 Node.js 20 上,runner 会打警告;v6 是 node24。 Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Nov 8, 2026
This was referenced Nov 8, 2026
|
🚀 Released in v3.59.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #3193
根因
两处现场都是 GitHub release 下载 504,而抓到 504 的那一环自己的重试太短:
bun install触发 electron 的 postinstall,下载electron-v37.x-linux-x64.zip拿到HTTPError: Response code 504 (Gateway Time-out)。postinstall 只请求一次、不重试(本地故障注入实测:服务端只收到 1 个请求就退出 1)。oven-sh/setup-bun从 GitHub release 下载 bun zip,tool-cache 内置重试 3 次、间隔 10s/18s,现场日志 09:19:58 → 09:20:26,28 秒内打完,不可配置。bun install自己对 504 / 连接断开是约 1 秒内连发 6 次,同样扛不住持续一两分钟的网关抖动。改动
1. electron 二进制:没有 job 需要,全部跳过。
CI 里没有任何一步启动 electron:桌面端代码由 esbuild 打包、electron 设为 external;
desktop:runtime不碰 electron;desktop:smoke不在任何 workflow 里。release 的 desktop job 由 electron-builder 自己下载 electron(electron-builder.yml没有electronDist),它不读ELECTRON_SKIP_BINARY_DOWNLOAD,仓库里只有electron/install.js读这个变量。所以所有装依赖的 workflow 都在顶层设ELECTRON_SKIP_BINARY_DOWNLOAD: "1",musl / glibc 容器用-e传入。2.
scripts/ci-net-retry.mjs:包在安装命令外面的有界重试。EAI_AGAIN、curl 的连接类退出码。匹配的是 bun / npm / pnpm / electron / curl 各自的报错原文。ENOTFOUND等)也不重试。3.
.github/actions/setup-bun:替换所有oven-sh/setup-bun@v2。Bun 改从 npm registry 上 Bun 官方发布的平台包
@oven/bun-<platform>取,用npm pack下载(会按 registry 元数据校验完整性),外面包ci-net-retry.mjs。下载后校验版本号,用actions/cache缓存,放在~/.bun/bin并加入 PATH,和原 action 一致。不再从 GitHub release 下载的原因:github.com/oven-sh/bun/releases/download/bun-v1.4.4/bun-linux-x64.zip从本机持续返回真实的 504(响应头带x-github-request-id、x-github-edge-region: sea);bun install本来就离不开 npm registry,musl / glibc 容器也一直是npm i -g [email protected]从 npm 装的 Bun。这样 job 少依赖一条外部链路。各处的
bun-version: 1.4.4字面量保留,版本一致性护栏照常生效。4. 覆盖到每个装依赖的 workflow / job
bun installnpm i -g bun+bun install,electron skip 传入bun installbun installbun install+npm installminimax CLIbun install;feishu 的 CLInpm install -g/bun add -gbun install、容器内安装、npm install -g [email protected]npm install -g pnpm、pnpm installtest/ci-net-retry.test.ts的 K4 护栏守住三件事:所有 workflow 和 glibc 脚本里的 bun / npm / pnpm 安装都从ci-net-retry.mjs启动;没有任何地方直接uses: oven-sh/setup-bun;装依赖的 workflow 和容器都带 electron skip。不在本 PR 范围
actions/checkout等 action 自身的下载、playwright 浏览器下载、midscene 里curl | bash的 Kimi / Grok 安装脚本。它们不是依赖安装命令,失败模式各不相同,没有套这层重试。影响评估
actions/cache。验证
单测与护栏
test/ci-net-retry.test.ts共 44 条:runWithRetry注入假的 spawn 和 sleep,断言尝试次数和等待序列。护栏变异检查。逐一退回以下六处改动,每次都恰好 1 条用例变红:
bun install;oven-sh/setup-bun;-e ELECTRON_SKIP_BINARY_DOWNLOAD=1;npm install -g bun;故障注入(真实等待,不打桩)
本地起一个按计划返回 504 / 404 / 断开连接的假 registry(Node http server)。用例是只依赖
[email protected]的工程,bun.lock 指向这个 registry。下表是node scripts/ci-net-retry.mjs <cmd>的实测结果:bun install --frozen-lockfile,始终 504bun install,前 12 个请求 504,之后正常bun install --frozen-lockfile,lockfile 漂移bun install,404curl --fail …,504、504、200curl --fail …,404node node_modules/electron/install.js,先 504 后 404ELECTRON_SKIP_BINARY_DOWNLOAD=1npm pack [email protected](action 的下载路径),504 一次后正常npm pack,404E9 / E10 加了
--fetch-retries=0,用来单独观察包装脚本的行为;CI 里 npm 自己的重试仍然有效。E1 的关键输出:
E2 的请求时刻:第 1 轮 10:04:33–35 打了 6 个 504;第 2 轮 10:04:45–46 打了 6 个 504;10:05:07 第 13 个请求成功。
对真实 GitHub 504 耗尽重试
最初版本的 action 仍从 GitHub release 下载。本机实跑时赶上真实的 504:5 次
curl: (22) The requested URL returned error: 504,间隔 10/20/40/80s,154 秒后以退出码 22 失败。这就是改从 npm 取 Bun 的直接依据。新 action 的安装步骤本地实跑
从
action.yml原样取出脚本运行,环境为空 HOME、RUNNER_OS=Linux、RUNNER_ARCH=X64,连真实 npm registry:不发版、不打 tag、不部署。
🤖 Generated with Claude Code