|
6 | 6 | # 2. 新增 src/↔lib/ 一致性守门(scripts/check-sync.js,v0.7.9 引入的发布前校验前置到 CI)。 |
7 | 7 | # 3. Codecov 只在 ubuntu+node24 一个分片跑一次(覆盖率无需每个组合都传)。 |
8 | 8 | # 4. node_modules 缓存(cache-dependency-path 指向子目录的 lockfile)。 |
| 9 | +# 5. main 徽章对齐 job:把双 README 的 tests 徽章刷成最新全量 pass 数—— |
| 10 | +# 复用发版线的 badge:sync(脚本自带「测试不绿不刷徽章」),让数字不再 |
| 11 | +# 只在发版时才追平。仅 push 到 main 时跑(PR 上没有可写回的对象)。 |
9 | 12 | # ⚠️ 需要 package.json 配合一处小改(跨平台通配符): |
10 | 13 | # dsh-mneme/package.json 的 "test": "node --test test/*.test.js" 在 Windows 的 cmd 下 |
11 | 14 | # 不展开 glob。建议改为 "test": "node --test test/"(目录模式,全平台等价), |
|
63 | 66 | token: ${{ secrets.CODECOV_TOKEN }} |
64 | 67 | files: dsh-mneme/coverage/lcov.info |
65 | 68 | 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 |
0 commit comments