Skip to content

Commit 9089a71

Browse files
authored
ci: tests 徽章动态对齐——main 徽章 job 进 CI,本地刷 1176→1242 (#273)
- ci.yml 新增 badge job:push 到 main 时复用发版线的 badge:sync (脚本自带「测试不绿不刷徽章」),数字不再只在发版时追平 - 双 README 徽章手工跑一次 badge:sync:1176 → 1242(当前真实值)
1 parent 3ad0361 commit 9089a71

3 files changed

Lines changed: 46 additions & 4 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ 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. main 徽章对齐 job:把双 README 的 tests 徽章刷成最新全量 pass 数——
10+
# 复用发版线的 badge:sync(脚本自带「测试不绿不刷徽章」),让数字不再
11+
# 只在发版时才追平。仅 push 到 main 时跑(PR 上没有可写回的对象)。
912
# ⚠️ 需要 package.json 配合一处小改(跨平台通配符):
1013
# dsh-mneme/package.json 的 "test": "node --test test/*.test.js" 在 Windows 的 cmd 下
1114
# 不展开 glob。建议改为 "test": "node --test test/"(目录模式,全平台等价),
@@ -63,3 +66,42 @@ jobs:
6366
token: ${{ secrets.CODECOV_TOKEN }}
6467
files: dsh-mneme/coverage/lcov.info
6568
fail_ci_if_error: false
69+
70+
# 双 README 的 tests 徽章自动对齐最新全量 pass 数(复用发版线的 badge:sync,
71+
# 脚本自带「测试不绿不刷徽章」)。只在 push 到 main 时跑:PR 上跑也刷不回
72+
# 基分支,反而拖慢每个 PR;已同步时脚本零改动、job 零提交。
73+
badge:
74+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
75+
runs-on: ubuntu-latest
76+
permissions:
77+
contents: write
78+
steps:
79+
- uses: actions/checkout@v4
80+
with:
81+
ref: main
82+
83+
- uses: actions/setup-node@v4
84+
with:
85+
node-version: 24
86+
cache: npm
87+
cache-dependency-path: dsh-mneme/package-lock.json
88+
89+
- name: Install dependencies
90+
working-directory: dsh-mneme
91+
run: npm ci
92+
93+
- name: Sync test badge & counts (runs full suite)
94+
working-directory: dsh-mneme
95+
run: npm run badge:sync
96+
97+
- name: Commit & push if changed
98+
run: |
99+
if git diff --quiet; then
100+
echo "badge already in sync — nothing to commit"
101+
else
102+
git config user.name "github-actions[bot]"
103+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
104+
git add README.md dsh-mneme/README.md
105+
git commit -m "chore(readme): 测试徽章自动对齐(CI main,pass 数追平)"
106+
git push origin main
107+
fi

‎README.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-3E63DD?style=flat-square" alt="license"></a>
1111
<a href="https://github.com/slow-stack/dsh-mneme/actions"><img src="https://img.shields.io/github/actions/workflow/status/slow-stack/dsh-mneme/ci.yml?style=flat-square&label=CI" alt="CI"></a>
1212
<a href="https://nodejs.org"><img src="https://img.shields.io/badge/node-22%2B-3E63DD?style=flat-square&logo=nodedotjs&logoColor=white" alt="node"></a>
13-
<a href="https://github.com/slow-stack/dsh-mneme"><img src="https://img.shields.io/badge/tests-1176%20passed-3E63DD?style=flat-square" alt="tests"></a>
13+
<a href="https://github.com/slow-stack/dsh-mneme"><img src="https://img.shields.io/badge/tests-1242%20passed-3E63DD?style=flat-square" alt="tests"></a>
1414
<a href="https://codecov.io/gh/slow-stack/dsh-mneme"><img src="https://img.shields.io/codecov/c/github/slow-stack/dsh-mneme/main?style=flat-square" alt="coverage"></a>
1515
<a href="https://github.com/awesome-dsh-plugin/awesome-dsh-plugin"><img src="https://awesome-dsh-plugin.com/badge.svg" alt="Awesome"></a>
1616
</p>
@@ -161,7 +161,7 @@ dsh web
161161

162162
```bash
163163
cd dsh-mneme && npm install
164-
npm test # 1176 个测试
164+
npm test # 1242 个测试
165165
npm run stress # 三轴线压测
166166
npm run sync # src → lib 同步
167167
```
@@ -322,7 +322,7 @@ It works out of the box. To feel its value in five minutes:
322322

323323
```bash
324324
cd dsh-mneme && npm install
325-
npm test # 1176 tests
325+
npm test # 1242 tests
326326
npm run stress # three-axis stress test
327327
npm run sync # src → lib sync
328328
```

‎dsh-mneme/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
[![npm version](https://img.shields.io/npm/v/@modusensus/dsh-mneme?color=blue&label=npm)](https://www.npmjs.com/package/@modusensus/dsh-mneme)
66
[![license](https://img.shields.io/badge/license-MIT-green)](LICENSE)
77
[![Awesome](https://awesome-dsh-plugin.com/badge.svg)](https://github.com/awesome-dsh-plugin/awesome-dsh-plugin)
8-
[![tests](https://img.shields.io/badge/tests-1176%20passed-success)](https://github.com/slow-stack/dsh-mneme)
8+
[![tests](https://img.shields.io/badge/tests-1242%20passed-success)](https://github.com/slow-stack/dsh-mneme)
99
[![CI](https://img.shields.io/github/actions/workflow/status/slow-stack/dsh-mneme/ci.yml)](https://github.com/slow-stack/dsh-mneme/actions)
1010
[![node](https://img.shields.io/badge/node-22%2B-blue)](https://nodejs.org)
1111
[![npm downloads](https://img.shields.io/npm/d18m/@modusensus/dsh-mneme.svg?color=blue&label=downloads)](https://www.npmjs.com/package/@modusensus/dsh-mneme)

0 commit comments

Comments
 (0)