Skip to content

Commit 73d3996

Browse files
authored
Merge branch 'main' into feat/chorography-m0
2 parents 7192f3f + 53dd27a commit 73d3996

6 files changed

Lines changed: 167 additions & 37 deletions

File tree

‎.github/dependabot.yml‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# 依赖巡查只管 GitHub Actions:四个工作流里 uses 的动作与 reusable workflow
2+
# 靠人记版本会积灰(2026-11 清点时 checkout / setup-node 已落后三个大版本),
3+
# 每周让 dependabot 报一次升级 PR,不再攒成一次手工大跳。
4+
version: 2
5+
updates:
6+
- package-ecosystem: github-actions
7+
directory: /
8+
schedule:
9+
interval: weekly
10+
# 冷却窗口:不追刚发布的版本,给「发布即翻车 / 供应链投毒」留出暴露期
11+
# (zizmor dependabot-cooldown 审计的要求;7 天与周检节奏正好对齐)
12+
cooldown:
13+
default-days: 7
14+
15+
# npm 生态刻意不纳入:dsh-mneme 的 devDependencies 里 @deepseek-ai/dsh-* 四件是
16+
# 宿主线的刻意钉子(升级节奏跟宿主发版走,老线兼容由 CI 的 test-host-legacy 腿
17+
# 真跑验证),其余依赖的面很小且有全量回归兜底——自动 bump 只会造噪音。

‎.github/workflows/ci.yml‎

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ on:
2323
permissions:
2424
contents: read
2525

26+
# PR 连推多个 commit 时取消同分支的旧 run(实测整轮 3-6.5 分钟,堆叠纯烧分钟)。
27+
# push / workflow_dispatch 事件没有 head_ref,组名落到 run_id(每次运行唯一)
28+
# → main 基线永不取消,required checks 口径不受影响。
29+
concurrency:
30+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
31+
cancel-in-progress: true
32+
2633
jobs:
2734
test:
2835
strategy:
@@ -31,13 +38,18 @@ jobs:
3138
os: [ubuntu-latest, windows-latest]
3239
node-version: [22, 24]
3340
runs-on: ${{ matrix.os }}
41+
# 实测最长腿 ~6.5 分钟(windows 冷缓存);20 分钟只兜真挂死——不设的话默认 360 分钟
42+
timeout-minutes: 20
3443
defaults:
3544
run:
3645
working-directory: dsh-mneme
3746
steps:
38-
- uses: actions/checkout@v4
47+
# 全程不 push,token 不留在 runner 的 git 配置里(zizmor artipacked)
48+
- uses: actions/checkout@v7
49+
with:
50+
persist-credentials: false
3951

40-
- uses: actions/setup-node@v4
52+
- uses: actions/setup-node@v7
4153
with:
4254
node-version: ${{ matrix.node-version }}
4355
cache: npm
@@ -67,18 +79,18 @@ jobs:
6779
if: matrix.os == 'ubuntu-latest' && matrix.node-version == 24
6880
run: npm run test:coverage
6981

70-
# v5:codecov-action v4 的引导期(下载/连接 codecov.io)TLS 失败不受
82+
# v5 起(现 v7):codecov-action v4 的引导期(下载/连接 codecov.io)TLS 失败不受
7183
# fail_ci_if_error 约束,会把整条腿判死(2026-10-05 ubuntu+node24 连挂三次,
72-
# 测试与覆盖率本身 fail 0)。v5 走新 CLI 且带 retry_count,引导/上传的
73-
# 网络抖动可在步内消化——上报失败仍不应挡 merge。
84+
# 测试与覆盖率本身 fail 0)。v7 已删掉 retry_count 输入——传了被静默忽略还挂
85+
# warning(2026-11-05 首跑实测),网络抖动的兜底就是下面的 fail_ci_if_error:
86+
# false:上报失败仍不应挡 merge。
7487
- name: Upload coverage to Codecov
7588
if: matrix.os == 'ubuntu-latest' && matrix.node-version == 24
76-
uses: codecov/codecov-action@v5
89+
uses: codecov/codecov-action@303a32d7a59b442fa8d48b6a1cc6825c09c847a5 # v7.1.1
7790
with:
7891
token: ${{ secrets.CODECOV_TOKEN }}
7992
files: dsh-mneme/coverage/lcov.info
8093
fail_ci_if_error: false
81-
retry_count: 3
8294

8395
# ── 宿主版本兼容腿:0.1.x 老内核 ───────────────────────────────────────────
8496
# peerDependencies 声明覆盖三段(0.1.0-rc.6+ / 0.1.5-rc.0+ / 0.2.0-rc.0+),而
@@ -102,13 +114,16 @@ jobs:
102114
# 0.1.7-rc.2 —— 0.1 线最新(老桌面端 2.0.14 内置的 0.1.7-rc.1 属同一段)
103115
host: ["0.1.0-rc.8", "0.1.7-rc.2"]
104116
runs-on: ubuntu-latest
117+
timeout-minutes: 10
105118
defaults:
106119
run:
107120
working-directory: dsh-mneme
108121
steps:
109-
- uses: actions/checkout@v4
122+
- uses: actions/checkout@v7
123+
with:
124+
persist-credentials: false
110125

111-
- uses: actions/setup-node@v4
126+
- uses: actions/setup-node@v7
112127
with:
113128
node-version: 24
114129
cache: npm

‎.github/workflows/release-prep.yml‎

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ permissions:
2929
jobs:
3030
prep:
3131
runs-on: ubuntu-latest
32+
timeout-minutes: 20
3233
steps:
3334
- name: Validate version format
3435
env:
@@ -39,9 +40,10 @@ jobs:
3940
exit 1
4041
fi
4142
42-
- uses: actions/checkout@v4
43+
# 本工作流要推分支、开 PR,默认凭据必须留下——artipacked 在此是唯一合理豁免
44+
- uses: actions/checkout@v7 # zizmor: ignore[artipacked]
4345

44-
- uses: actions/setup-node@v4
46+
- uses: actions/setup-node@v7
4547
with:
4648
node-version: 24
4749
cache: npm
@@ -64,7 +66,13 @@ jobs:
6466
echo "count=$COUNT" >> "$GITHUB_OUTPUT"
6567
6668
- name: Run release-prep (version bump + badge + placeholder rows)
67-
run: node scripts/release-prep.mjs "${{ inputs.version }}" "${{ steps.tests.outputs.count }}"
69+
env:
70+
# inputs / steps.outputs 内插进 run 都是 zizmor 的 template-injection 反模式
71+
# (与下面 VERSION 走 env 同一个理由):env 注入的值在 shell 里是普通变量,
72+
# 不重解析。version 虽有上一步的正则卡格式,仍走 env 让扫描器零推理。
73+
VERSION: ${{ inputs.version }}
74+
TEST_COUNT: ${{ steps.tests.outputs.count }}
75+
run: node scripts/release-prep.mjs "$VERSION" "$TEST_COUNT"
6876

6977
- name: Create release-prep branch + PR
7078
env:
@@ -126,7 +134,9 @@ jobs:
126134
echo "- [ ] 跨 minor 时把 SECURITY.md 中英两张支持版本表挪一格(活跃开发 / 尽力维护 / 不支持三段一起挪,含停止维护那段通知)"
127135
} > commit-msg.txt
128136
git commit -F commit-msg.txt
129-
git push origin "HEAD:refs/heads/$BRANCH" $FORCE
137+
# ${FORCE:+"$FORCE"}:FORCE 为空 → 不产生参数;非空 → 单个整体参数。
138+
# 写 $FORCE 裸引用会被 shellcheck SC2086 拦(workflow-hygiene 联动检查)
139+
git push origin "HEAD:refs/heads/$BRANCH" ${FORCE:+"$FORCE"}
130140
# PR 正文走 --body-file:多行中文塞进 --body 需要一堆 $'\n' 转义,
131141
# 读的人看不懂、改的人不敢动。写成文件既好读也不受 shell 引号规则摆布。
132142
{

‎.github/workflows/release.yml‎

Lines changed: 56 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ name: Release
1717
# - tag 必须与 dsh-mneme/package.json version 完全一致(vX.Y.Z ↔ X.Y.Z),否则直接失败;
1818
# - tag 对应版本必须在 dsh-mneme/CHANGELOG.md 里有小节(文档先行,发布时自动抽取作 Release 说明)。
1919
#
20-
# 手动触发(workflow_dispatch)支持 dry_run:只跑 verify + test,不发布不建 Release。
20+
# 手动触发(workflow_dispatch)默认干跑(dry_run 默认 true):只跑 verify + test,
21+
# 不发布不建 Release。发布正路是推 v* tag——手点 Run workflow 的误触不应该能直接
22+
# publish(verify 只查 CHANGELOG 有节,不查 tag);确要走手动发布,显式取消勾选。
2123

2224
on:
2325
push:
@@ -28,7 +30,7 @@ on:
2830
dry_run:
2931
description: '只验证 + 测试,不发布(dry run)'
3032
type: boolean
31-
default: false
33+
default: true
3234

3335
# 权限按 job 发放,工作流级一律只读:
3436
# publish → id-token: write(npm provenance 走 OIDC,不需要长期 token)
@@ -38,18 +40,33 @@ on:
3840
permissions:
3941
contents: read
4042

43+
# 发布链全局单飞:两个 tag 挨得近时排队而非并行——npm 侧有 skip-if-exists 兜底,
44+
# gh release create/edit 没有等价守卫,并行会竞态。cancel-in-progress 刻意为
45+
# false:取消跑到一半的 publish 比排队等它更糟。
46+
concurrency:
47+
group: release
48+
cancel-in-progress: false
49+
4150
jobs:
4251
# ── 1. 版本号管理:tag ↔ package.json ↔ CHANGELOG 三方一致 ──────────────
4352
verify:
4453
runs-on: ubuntu-latest
54+
timeout-minutes: 10
4555
outputs:
4656
version: ${{ steps.ver.outputs.version }}
4757
steps:
48-
- uses: actions/checkout@v4
58+
- uses: actions/checkout@v7
59+
with:
60+
persist-credentials: false
4961

50-
- uses: actions/setup-node@v4
62+
- uses: actions/setup-node@v7
5163
with:
5264
node-version: 24
65+
# 发布链不吃任何包管理器缓存(zizmor cache-poisoning):setup-node v4.1 起
66+
# 默认开 npm 缓存,必须显式关——tag 触发的流水线直接产出 npm 包,缓存命中
67+
# 路径一旦被污染没有 PR 阶段的复核兜底。同一棵树在 PR 的 CI(带缓存)已
68+
# 全量绿过,这里多花的一两分钟买的是发布面干净。
69+
package-manager-cache: false
5370

5471
- name: Resolve version (tag push or package.json)
5572
id: ver
@@ -69,13 +86,16 @@ jobs:
6986
7087
# 文档更新守门:CHANGELOG 缺该版本小节 → 说明发布说明没写,阻断并提示
7188
- name: CHANGELOG has a section for this version
89+
env:
90+
# version 的来源(tag 名 / package.json)都是维护者可控,zizmor 只记
91+
# informational,但本工作流统一走 env 注入让扫描器零推理
92+
VERSION: ${{ steps.ver.outputs.version }}
7293
run: |
73-
V="${{ steps.ver.outputs.version }}"
74-
if ! grep -qE "^## \[${V}\]" dsh-mneme/CHANGELOG.md; then
75-
echo "::error::dsh-mneme/CHANGELOG.md 缺少 ## [${V}] 小节——请先补发布说明"
94+
if ! grep -qE "^## \[${VERSION}\]" dsh-mneme/CHANGELOG.md; then
95+
echo "::error::dsh-mneme/CHANGELOG.md 缺少 ## [${VERSION}] 小节——请先补发布说明"
7696
exit 1
7797
fi
78-
echo "CHANGELOG section found for ${V}"
98+
echo "CHANGELOG section found for ${VERSION}"
7999
80100
# ── 2. 双平台全量测试(Windows + Linux × Node 22/24,与 CI 同矩阵)────────
81101
test:
@@ -86,17 +106,19 @@ jobs:
86106
os: [ubuntu-latest, windows-latest]
87107
node-version: [22, 24]
88108
runs-on: ${{ matrix.os }}
109+
timeout-minutes: 20
89110
defaults:
90111
run:
91112
working-directory: dsh-mneme
92113
steps:
93-
- uses: actions/checkout@v4
114+
- uses: actions/checkout@v7
115+
with:
116+
persist-credentials: false
94117

95-
- uses: actions/setup-node@v4
118+
- uses: actions/setup-node@v7
96119
with:
97120
node-version: ${{ matrix.node-version }}
98-
cache: npm
99-
cache-dependency-path: dsh-mneme/package-lock.json
121+
package-manager-cache: false # 发布链不吃缓存,理由见 verify 同款配置
100122

101123
- name: Install dependencies
102124
run: npm ci
@@ -112,18 +134,22 @@ jobs:
112134
needs: [verify, test]
113135
if: github.event_name == 'push' || inputs.dry_run != true
114136
runs-on: ubuntu-latest
137+
timeout-minutes: 20
115138
# npm provenance 用 OIDC 而不是长期 token 签名:--provenance 需要 id-token。
116139
# 挂在 job 上而不是 workflow 上,别的 job 拿不到这个能力。
117140
permissions:
118141
contents: read
119142
id-token: write
120143
steps:
121-
- uses: actions/checkout@v4
144+
- uses: actions/checkout@v7
145+
with:
146+
persist-credentials: false
122147

123-
- uses: actions/setup-node@v4
148+
- uses: actions/setup-node@v7
124149
with:
125150
node-version: 24
126151
registry-url: https://registry.npmjs.org/
152+
package-manager-cache: false # 发布链不吃缓存,理由见 verify 同款配置
127153

128154
- name: Registry current state (diagnostic)
129155
run: |
@@ -135,7 +161,7 @@ jobs:
135161
- name: Publish @modusensus/dsh-mneme (skip if exists)
136162
working-directory: dsh-mneme
137163
run: |
138-
V="${{ needs.verify.outputs.version }}"
164+
V="$VERSION"
139165
if npm view "@modusensus/dsh-mneme@${V}" version >/dev/null 2>&1; then
140166
echo "v${V} already published on registry — skipping"
141167
else
@@ -145,6 +171,7 @@ jobs:
145171
fi
146172
env:
147173
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
174+
VERSION: ${{ needs.verify.outputs.version }} # 统一 env 注入,理由见 verify 的 CHANGELOG 步
148175

149176
# 真闸门:拿不到这个版本就非零退出,让 job 变红。
150177
# 原先这里是 `echo "Published: $(npm view "@modusensus/dsh-mneme@${V}" version)"` —— 命令
@@ -154,7 +181,9 @@ jobs:
154181
# 轮询而不是一次性查询:registry 有传播延迟(v0.8.16 实测 publish→可见约 4.5 分钟),
155182
# 一次性查询只有假绿或假红两种结局;幂等跳过路径首次探测即通过,不付等待成本。
156183
- name: Verify published version (blocking gate)
157-
run: node dsh-mneme/scripts/publish-gate.mjs "${{ needs.verify.outputs.version }}"
184+
env:
185+
VERSION: ${{ needs.verify.outputs.version }} # 统一 env 注入,理由见 verify 的 CHANGELOG 步
186+
run: node dsh-mneme/scripts/publish-gate.mjs "$VERSION"
158187

159188
# ── 4. GitHub Release(按 v0.7.9 / v0.7.10 的既定格式,说明自动取自 CHANGELOG)──
160189
# needs 里必须带 publish:Release 是对外的「这个版本已发布」声明,registry 才是唯一事实。
@@ -167,19 +196,24 @@ jobs:
167196
needs: [verify, test, publish]
168197
if: github.event_name == 'push' || inputs.dry_run != true
169198
runs-on: ubuntu-latest
199+
timeout-minutes: 10
170200
# 建/改 GitHub Release 要写权限,只有这个 job 需要。
171201
permissions:
172202
contents: write
173203
steps:
174-
- uses: actions/checkout@v4
204+
- uses: actions/checkout@v7
205+
with:
206+
persist-credentials: false
175207

176208
# Release 正文的渲染搬进了 dsh-mneme/scripts/release-notes.mjs(原先这段是内联 node -e)。
177209
# 搬出去的理由不是「代码要短」:Release 正文的排版会被反复调整,内联脚本改一次就要动工作流
178210
# 本体、还没法写测试。现在渲染有单测(test/release-notes.test.js),本地也能先预览再发。
179211
# 渲染是分层而不是截断:标题 + 一句导语默认可见,剩余正文折进 details —— CHANGELOG 本体
180212
# 一个字不动(那是含决策理由的完整记录),压缩只发生在对外渲染这一步。
181213
- name: Extract release notes from CHANGELOG
182-
run: node dsh-mneme/scripts/release-notes.mjs "${{ needs.verify.outputs.version }}"
214+
env:
215+
VERSION: ${{ needs.verify.outputs.version }} # 统一 env 注入,理由见 verify 的 CHANGELOG 步
216+
run: node dsh-mneme/scripts/release-notes.mjs "$VERSION"
183217

184218
- name: Create / update GitHub Release
185219
env:
@@ -204,11 +238,14 @@ jobs:
204238
needs: [verify, test, publish, release]
205239
if: always()
206240
runs-on: ubuntu-latest
241+
timeout-minutes: 5
207242
steps:
208243
- name: Job summary
244+
env:
245+
VERSION: ${{ needs.verify.outputs.version }}
209246
run: |
210247
{
211-
echo "## Release pipeline — ${{ needs.verify.outputs.version }}"
248+
echo "## Release pipeline — $VERSION"
212249
echo ""
213250
echo "| job | result |"
214251
echo "|-----|--------|"

0 commit comments

Comments
 (0)