Skip to content

Commit 27ee9ff

Browse files
committed
ci: 加宿主版本兼容腿,把 peer 声明的 0.1.x 两段真跑一遍
peerDependencies 声明覆盖三段(0.1.0-rc.6+ / 0.1.5-rc.0+ / 0.2.0-rc.0+),但 CI 只用 lockfile 里那一版(当前 0.2 线)——「声明支持却从没人验证」正是 #344 的由来。 新增 test-host-legacy,把 0.1.0-rc.8 与 0.1.7-rc.2 各跑一遍全量测试。 为什么另开作业、而不是给 test 加一个 matrix 维度:test 的四个作业名 (test (os, node))是分支保护的 required status checks,加维度会让名字变成 test (os, node, host)、原名消失 → 所有 PR 立刻卡死无法合并。另开作业完全不碰那 四个必需检查;若要让这条腿也阻断合并,去 Settings → Branches 把 test-host-legacy (*) 加进 required 即可。 实现要点: - 换掉四个宿主 devDeps 后必须删掉 lockfile 重新解析:带着 0.2 的锁降级会被 peer 链拦死(dsh-tools 的 peer 要求同版本的 dsh-agent,而锁里是 0.2.x)。因此这条腿 的树是全新解析的,它只回答宿主 API 面是否兼容;依赖版本一致性仍由 test 腿的 npm ci 负责。 - 解析与安装分成两步(先 --package-lock-only 再 npm ci):解析失败与下载失败能 区分开,且安装结果严格等于解析出的锁。 - 新增断言步骤:目标版本没真正装上就响亮失败,避免出现「其实测的是别的版本」的 假绿。 - 全新解析会把运行时闭包也换成当前最新,而 runtime-manifest.json 由 lockfile 生成 → 先重建清单再跑测试,否则那条「清单与 lockfile 一致」的用例必红,且与 本腿要问的问题无关。 - 只跑 ubuntu + node 24 单分片:这条腿问的是宿主 API 面,与 OS / Node 无关(那些 由 test 腿的四个分片覆盖),单分片足够且最省。 - 顺带同步 AGENTS.md 闸门清单里对 CI 矩阵的描述。
1 parent f7b7df7 commit 27ee9ff

2 files changed

Lines changed: 86 additions & 1 deletion

File tree

‎.github/workflows/ci.yml‎

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ name: CI
66
# 2. 新增 src/↔lib/ 一致性守门(scripts/check-sync.js,v0.7.9 引入的发布前校验前置到 CI)。
77
# 3. Codecov 只在 ubuntu+node24 一个分片跑一次(覆盖率无需每个组合都传)。
88
# 4. node_modules 缓存(cache-dependency-path 指向子目录的 lockfile)。
9+
# 5. 宿主版本兼容腿 test-host-legacy:peer 声明的 0.1.x 两段各真跑一遍(见该作业注释)。
910
# ⚠️ 需要 package.json 配合一处小改(跨平台通配符):
1011
# dsh-mneme/package.json 的 "test": "node --test test/*.test.js" 在 Windows 的 cmd 下
1112
# 不展开 glob。建议改为 "test": "node --test test/"(目录模式,全平台等价),
@@ -63,3 +64,87 @@ jobs:
6364
token: ${{ secrets.CODECOV_TOKEN }}
6465
files: dsh-mneme/coverage/lcov.info
6566
fail_ci_if_error: false
67+
68+
# ── 宿主版本兼容腿:0.1.x 老内核 ───────────────────────────────────────────
69+
# peerDependencies 声明覆盖三段(0.1.0-rc.6+ / 0.1.5-rc.0+ / 0.2.0-rc.0+),而
70+
# test 腿只用 lockfile 里那一版(当前 0.2 线)——「声明支持却从没验证」正是 #344
71+
# 的由来。这条腿把 0.1.x 的两段也真跑一遍。
72+
#
73+
# 为什么另开作业、而不是给 test 加一个 matrix 维度:test 的四个作业名
74+
# (test (os, node))是分支保护的 required status checks,加维度会让名字变成
75+
# test (os, node, host)、原名消失 → 所有 PR 立刻被卡住无法合并。另开作业完全不
76+
# 碰那四个必需检查;若要让这条腿也阻断合并,去 Settings → Branches 把
77+
# test-host-legacy (*) 加进 required 即可。
78+
#
79+
# 为什么只跑 ubuntu + node 24 单分片:这条腿问的是「宿主 API 面是否还兼容」,
80+
# 与 OS / Node 无关(那些由 test 腿的四个分片覆盖),单分片足够且最省。
81+
test-host-legacy:
82+
strategy:
83+
fail-fast: false
84+
matrix:
85+
# 两个值分别落在 peer 范围的两段上:
86+
# 0.1.0-rc.8 —— #344 之前本仓库实际开发/测试的那一版(0.1.0 段)
87+
# 0.1.7-rc.2 —— 0.1 线最新(老桌面端 2.0.14 内置的 0.1.7-rc.1 属同一段)
88+
host: ["0.1.0-rc.8", "0.1.7-rc.2"]
89+
runs-on: ubuntu-latest
90+
defaults:
91+
run:
92+
working-directory: dsh-mneme
93+
steps:
94+
- uses: actions/checkout@v4
95+
96+
- uses: actions/setup-node@v4
97+
with:
98+
node-version: 24
99+
cache: npm
100+
cache-dependency-path: dsh-mneme/package-lock.json
101+
102+
# 换掉那四个宿主 devDeps 再重新解析。必须删掉 lockfile:带着 0.2 的锁降级
103+
# 会被 peer 链拦死(dsh-tools 的 peer 要求同版本的 dsh-agent,而锁里是 0.2.x)。
104+
# 因此这条腿的树是「全新解析」的——它只回答宿主 API 面是否兼容,不回答依赖
105+
# 版本一致性(那由 test 腿的 npm ci 负责)。解析与安装分两步:解析失败
106+
# (网络/元数据)与下载失败能区分开,且安装结果严格等于解析出的锁。
107+
- name: Pin host packages to ${{ matrix.host }}
108+
run: |
109+
node -e '
110+
const fs = require("fs");
111+
const names = [
112+
"@deepseek-ai/dsh-host-webserver",
113+
"@deepseek-ai/dsh-llm",
114+
"@deepseek-ai/dsh-system-prompt",
115+
"@deepseek-ai/dsh-tools"
116+
];
117+
const pkg = JSON.parse(fs.readFileSync("package.json", "utf8"));
118+
for (const name of names) pkg.devDependencies[name] = process.argv[1];
119+
fs.writeFileSync("package.json", JSON.stringify(pkg, null, 2) + "\n");
120+
' "${{ matrix.host }}"
121+
rm -f package-lock.json
122+
npm install --package-lock-only
123+
npm ci
124+
125+
# 断言目标版本真的装上了。解析漂移要在这里响亮地失败,而不是让后面的用例
126+
# 给出一个「其实测的是别的版本」的假绿。
127+
- name: Assert the legacy host actually landed
128+
run: |
129+
node -e '
130+
const fs = require("fs");
131+
const want = process.argv[1];
132+
const names = ["dsh-host-webserver", "dsh-llm", "dsh-system-prompt", "dsh-tools"];
133+
let bad = 0;
134+
for (const name of names) {
135+
const path = "node_modules/@deepseek-ai/" + name + "/package.json";
136+
const got = JSON.parse(fs.readFileSync(path, "utf8")).version;
137+
if (got !== want) { console.error("✖ " + name + " 装成了 " + got + ",期望 " + want); bad = 1; }
138+
}
139+
if (bad) process.exit(1);
140+
console.log("✓ 四个宿主包都是 " + want);
141+
' "${{ matrix.host }}"
142+
143+
# 全新解析会把运行时闭包也换成当前最新,而 runtime-manifest.json 是从 lockfile
144+
# 生成的 → 不重建的话「清单与 lockfile 一致」那条用例必红,且与本腿要问的问题
145+
# 无关。清单一致性由 test 腿的 npm ci 负责。
146+
- name: Rebuild runtime manifest for the synthetic tree
147+
run: node scripts/build-runtime-manifest.mjs
148+
149+
- name: Run full tests
150+
run: npm test

‎AGENTS.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ dsh-mneme 是 DSH 宿主的记忆插件(蒸馏 / 注入 / 检索 / 巩固 / sc
6363

6464
## 闸门清单
6565

66-
- `npm test`(CI 矩阵:ubuntu + windows × node 22/24)
66+
- `npm test`(CI 矩阵:ubuntu + windows × node 22/24;另有一条宿主兼容腿 `test-host-legacy`,把 peer 声明的 0.1.x 两段也真跑一遍)
6767
- check-sync(src ↔ lib 平价)
6868
- CodeRabbit 自动评审(每个 PR)
6969
- codecov 补丁覆盖率

0 commit comments

Comments
 (0)