Repository navigation
feat: hermetic local npm registry e2e infra — real self-update chain coverage (#1153) - #1161
Conversation
📦 Built Package ArtifactBranch: Option A — Install from npm PR tag (recommended)npm install -g billion-context@pr-1161Each push to this PR publishes a new version under the Option B — Download artifact
tar xzf billion-context-pr1161.tgz
npm install -g packageInstall instructions are refreshed on each push. |
[bot] 🏷 开始 review。本 PR 是 agent 完成的工作(无重做),按规范执行:核对代码 → 回归审查( |
5cafbaf to
77414b6
Compare
[bot] 🏷 Review 完成:可以合并。 全部检查在 rebase 后的新 head Diff 整洁度(第一道关)— 干净10 个文件全部与本 PR 目的相关;+4544/-173 中 ~4238 行是 verdaccio devDep 的 lockfile 树(已披露, 回归审查(
|
| 既有行为 | 结论 |
|---|---|
REGISTRY_BASE(L41)默认解析 → registryUrlFor(L50) |
保持。unset/空串/纯空白 → https://registry.npmjs.org,与改前字节级一致;现有 tests/update-channel.test.ts 的默认 URL 断言在 unset 下继续通过(隐式回归护栏) |
CHECK_INTERVAL_MS(L52-60)→ throttle(L545)、日志(L899)、timer(L905) |
保持。unset → Number(undefined)=NaN → 回退 180000ms;≤0/非数值同样回退。三处消费点逐一核对 |
| dist-tag 文档/tarball 下载路径 | 未触碰。tarball URL 来自 registry doc 自身(绝对地址),不经 REGISTRY_BASE 拼接 |
| 测试断言真实性 | 三条 [update] 日志正则逐一对上 src/update.ts:574/624/635 的真实字符串;BILI_CLIENT_BIN(plugin-install.ts:761)、"plugin present"(plugin-install.ts:984)均存在;seed 用 plugins(复数)正确——fake opencode 报 2.4.0,pickPluginKey(plugin-install.ts:750)对 major≥2 返回 "plugins",子测试 3 测的是真幂等路径而非空转 |
| CI workflow | ubuntu-latest、零 secret、回环 only;artifact 收集只匹配 tmp/e2e-registry-*,与新 suite 的 mkdtemp 前缀一致 |
Reviewer 直接修的(已补 commit 到分支并 force-push)
- Rebase 到当前 master(原 base
9c01dbe落后 e28fdfa 约 25 个 commit,含 v0.1.138 release)——零冲突,符合 §7.2「rebase 后重新全量验证」。 - 小问题:
BILI_UPDATE_REGISTRY尾斜杠——原实现trim() || default不处理尾斜杠,设成http://host:port/会拼出//pkg/latest。npm 自身对 registry URL 做同样的归一化,所以提取为导出纯函数normalizeRegistryBase()(与normalizeUpdateTag同模式)+ 7 条单测覆盖 unset/空/多斜杠。默认行为不变(unset 路径字节级一致)。
Pre-flight 证据(全部我在 rebased head 实跑,非引用 PR 描述)
npm ci(380 包含 verdaccio 树)✓ /npm run typecheck✓npm test:2246 pass / 0 fail / 2 skipped ✓npm run build✓- Gated suite:
ACP_TEST_REGISTRY=1→ 4/4 绿,~14s(真 verdaccio publish/download/sha512 verify/install);无 env → 1 skipped ✓(修完尾斜杠后又重跑一次,仍 4/4) - GitHub CI @
77414b6:9/9 全绿,包括新的hermetic registry e2ejob 首跑即过 + 四平台 test 矩阵 + version-guard/build-artifact/codex 两 job
§5 no-op release 问题(PR 作者请你拍板)
我的判断与作者一致:本 PR 可走普通 release。理由:两个 seam 在 unset 下字节级等价(上面逐项核过),不存在「坏 updater 锁死升级路径」的风险面——no-op 流程防的是 updater 代码本身的行为变更,而这里没有任何生产路径行为变化。CI 矩阵(含真实 bili update 决策路径的单测)全绿进一步佐证。#1143 的 updater 改动届时单独走 no-op 流程,与本 PR 无关。此点最终由你确认。
中文一句话:搭好了自带 verdaccio 的 hermetic e2e 基建并跑通自更新全链路最小验收场景,review 确认 src/update.ts 仅加两个默认值不变的 env seam(逐项核对无生产行为漂移),已在分支上补了 rebase 和尾斜杠归一化修复,本地+CI 全绿,可以合并。
def6d9e to
d0c17c2
Compare
|
Rebased onto current master (head 92dce5e, was 142 commits behind). Conflict resolution + review notes: Conflicts resolved
Review of the seams (src/update.ts, the load-bearing file)
Gates on the merged tree
Merge once its own |
[bot] 🏷 CI 条件已满足,但合并我执行不了:
我对新 head
|
Closes #1153
What
Test infra for the self-update chain that previously had zero coverage (all existing update tests inject fake
fetch/resolveVersion, so only "decisions" were testable, never the real chain):tests/e2e/registry-fixture.ts— brings its own verdaccio instance: random loopback port vialisten(0)readback (fix: emit /acp panel as persistent custom message and strip it from the proxy model context (#359) #360), isolated storage/config/HOME, local user + token (verdaccio$anonymouspublish is anonymous-only → authenticated npm CLI gets 403; fixture uses$all), readiness polled viaGET /-/ping, crash-safe teardown (SIGTERM → SIGKILL fallback).tests/e2e/e2e-registry.test.ts— gated byACP_TEST_REGISTRY=1(skips by default; thenpm testglob doesn't covertests/e2e/anyway). Republishes this repo's own files at synthetic OLD/NEW versions, extracts OLD under<work>/global/node_modules/<pkg>, then runs the REAL chain in a child process with fully isolated HOME/XDG_*: dist-tag resolve → tarball download → sha512 verify → staged extract → in-place install → disk flip. Asserts the real[update]log lines, on-disk version flip, no staging/backup leftovers, lock release; then post-updateplugin install opencode(master semantics: bare-name entry stays idempotent).src/update.ts(default-invariant, documented):BILI_UPDATE_REGISTRY(registry base URL override) andBILI_UPDATE_CHECK_INTERVAL_MS(check period override)..github/workflows/ci-registry.yml: ubuntu-latest, every PR, zero secrets, zero tokens —npm ci+ build + gated suite.Why
#1153: the full self-update chain (
src/update.ts— explicitly load-bearing per §7.4) had no end-to-end coverage. Real npm can't be touched (no publish / no dist-tag rm) and CI must not carry external tokens, so per the issue spec the fixture brings its own registry instance and never depends on any external (even internal) service.Pre-flight
npm run typecheck✓npm test✓ (2162 pass / 0 fail / 2 skipped)npm run build✓ACP_TEST_REGISTRY=1 node --import tsx --test tests/e2e/e2e-registry.test.ts→ 4/4 green in ~12s (real registry doc fetch, real tarball download + integrity verify + install)Behavior-change disclosure (Deliverables #4)
None in production. Both new env vars are default-invariant when unset:⚠️
REGISTRY_BASEstill resolves tohttps://registry.npmjs.organd the check period stays 180000ms. No wire / config / persistence changes.src/update.tsis load-bearing (§7.4/§5): this change is test seams only, but flagging for the owner's call on whether the no-op-release dance applies before it ships (my read: no behavior delta under defaults ⇒ regular release is fine; PR #1143's updater changes will need the no-op flow separately).Scope notes
bili update) instead of waiting an interval; the interval seam exists for future auto-path assertions.TODO(#1143)(pinned-entry semantics don't exist on master yet); issue scenarios 2–4 (zero registry round-trip, npm packument 膨胀:per-PR 发布累计 1078 版本/511 个 pr-* dist-tags(1MB+ 元数据),需历史清理 + 结构性止血 #1149 tag-cleanup regression) are follow-ups on this infra.