Skip to content

Commit 46e83bb

Browse files
killaguclaude
andcommitted
ci: single-leg coverage and cached utoo package store
Two independent levers to cut CI wall time without adding matrix jobs. Task A — collect coverage on one matrix leg only: - add a `coverage` matrix axis (default false) and enable it on a single ubuntu/node-24 leg via include; an explicit exclude of the base ubuntu/24/coverage:false combo is required because `include` cannot overwrite an existing matrix dimension and would otherwise *duplicate* the ubuntu/24 leg (7 legs instead of 6). - split "Run tests" into two guarded steps: `ut run ci` (with --coverage) on the coverage leg, `ut run test` on the other 5. Both reach the same pretest prep (clean-dist + workspace pretest); only --coverage differs. - gate the codecov upload on `matrix.coverage` instead of OS, so exactly one leg uploads. Applied to test, test-egg-bin and test-egg-scripts. Leg counts are unchanged (6 / 2 / 2); the `done` gate is unaffected. Task B — cache the utoo package download store: - `ut install --from pnpm` clones from a content-addressable store (default `$HOME/.cache/nm`, redirectable via `UTOO_CACHE_DIR`). Pin it to `${{ runner.temp }}/utoo-store` for a deterministic cross-OS path and restore/save it with actions/cache before install in every installing job (typecheck, test, test-egg-bin, test-egg-scripts). - the repo commits no lockfile (versions live in pnpm-workspace.yaml's catalog + package.json files), so the cache key hashes those rather than a non-existent pnpm-lock.yaml; restore-keys fall back to the latest per-OS store so it warms even on a key miss. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 22d5585 commit 46e83bb

1 file changed

Lines changed: 100 additions & 12 deletions

File tree

.github/workflows/ci.yml

Lines changed: 100 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,17 @@ jobs:
3636
with:
3737
node-version: '24'
3838

39+
- name: Cache utoo package store
40+
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
41+
with:
42+
path: ${{ runner.temp }}/utoo-store
43+
key: pkgstore-${{ runner.os }}-${{ hashFiles('pnpm-workspace.yaml', '**/package.json') }}
44+
restore-keys: |
45+
pkgstore-${{ runner.os }}-
46+
3947
- name: Install dependencies
48+
env:
49+
UTOO_CACHE_DIR: ${{ runner.temp }}/utoo-store
4050
run: ut install --from pnpm
4151

4252
- name: Run lint
@@ -60,6 +70,18 @@ jobs:
6070
matrix:
6171
os: ['ubuntu-latest', 'macos-latest', 'windows-latest']
6272
node: ['22', '24']
73+
coverage: [false]
74+
# Replace (not duplicate) the ubuntu/24 leg with a coverage-enabled one.
75+
# `include` cannot overwrite an existing matrix dimension, so the base
76+
# coverage:false combo must be excluded first or ubuntu/24 would run twice.
77+
exclude:
78+
- os: 'ubuntu-latest'
79+
node: '24'
80+
coverage: false
81+
include:
82+
- os: 'ubuntu-latest'
83+
node: '24'
84+
coverage: true
6385

6486
name: Test (${{ matrix.os }}, ${{ matrix.node }})
6587
runs-on: ${{ matrix.os }}
@@ -159,17 +181,33 @@ jobs:
159181
with:
160182
node-version: ${{ matrix.node }}
161183

184+
- name: Cache utoo package store
185+
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
186+
with:
187+
path: ${{ runner.temp }}/utoo-store
188+
key: pkgstore-${{ runner.os }}-${{ hashFiles('pnpm-workspace.yaml', '**/package.json') }}
189+
restore-keys: |
190+
pkgstore-${{ runner.os }}-
191+
162192
- name: Install dependencies
193+
env:
194+
UTOO_CACHE_DIR: ${{ runner.temp }}/utoo-store
163195
run: ut install --from pnpm
164196

165-
- name: Run tests
197+
- name: Run tests (with coverage)
198+
if: ${{ matrix.coverage }}
166199
run: ut run ci
167200

201+
- name: Run tests
202+
if: ${{ !matrix.coverage }}
203+
run: ut run test
204+
168205
# Summarize how parallel the full-isolate-off suite actually ran. The gating
169-
# `ut run ci` run above emits Vitest JSON (vitest.config.ts, CI only); this step
170-
# turns it into avg/peak concurrency + efficiency metrics in the job summary. It
171-
# is informational only (always() so failures still surface metrics) and never
172-
# changes the gate — `ut run ci` already set the job's pass/fail above.
206+
# test run above (`ut run ci` on the coverage leg, `ut run test` on the rest)
207+
# emits Vitest JSON (vitest.config.ts, CI only); this step turns it into
208+
# avg/peak concurrency + efficiency metrics in the job summary. It is
209+
# informational only (always() so failures still surface metrics) and never
210+
# changes the gate — the test run above already set the job's pass/fail.
173211
- name: Report parallelism metrics
174212
if: always()
175213
# Call node directly: `ut run <script> -- ...` re-serializes forwarded args into
@@ -182,8 +220,7 @@ jobs:
182220
ut run example:test:all
183221
184222
- name: Code Coverage
185-
# skip on windows, it will hangup on codecov
186-
if: ${{ matrix.os != 'windows-latest' }}
223+
if: ${{ matrix.coverage }}
187224
uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5
188225
with:
189226
use_oidc: true
@@ -194,6 +231,15 @@ jobs:
194231
matrix:
195232
os: ['ubuntu-latest', 'windows-latest']
196233
node: ['24']
234+
coverage: [false]
235+
exclude:
236+
- os: 'ubuntu-latest'
237+
node: '24'
238+
coverage: false
239+
include:
240+
- os: 'ubuntu-latest'
241+
node: '24'
242+
coverage: true
197243

198244
name: Test bin (${{ matrix.os }}, ${{ matrix.node }})
199245
runs-on: ${{ matrix.os }}
@@ -214,17 +260,33 @@ jobs:
214260
with:
215261
node-version: ${{ matrix.node }}
216262

263+
- name: Cache utoo package store
264+
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
265+
with:
266+
path: ${{ runner.temp }}/utoo-store
267+
key: pkgstore-${{ runner.os }}-${{ hashFiles('pnpm-workspace.yaml', '**/package.json') }}
268+
restore-keys: |
269+
pkgstore-${{ runner.os }}-
270+
217271
- name: Install dependencies
272+
env:
273+
UTOO_CACHE_DIR: ${{ runner.temp }}/utoo-store
218274
run: ut install --from pnpm
219275

220-
- name: Run tests
276+
- name: Run tests (with coverage)
277+
if: ${{ matrix.coverage }}
221278
run: |
222279
ut run build -- --workspace ./tools/egg-bin
223280
ut run ci --workspace @eggjs/bin
224281
282+
- name: Run tests
283+
if: ${{ !matrix.coverage }}
284+
run: |
285+
ut run build -- --workspace ./tools/egg-bin
286+
ut run test --workspace @eggjs/bin
287+
225288
- name: Code Coverage
226-
# skip on windows, it will hangup on codecov https://github.com/codecov/codecov-action/issues/1787
227-
if: ${{ matrix.os != 'windows-latest' }}
289+
if: ${{ matrix.coverage }}
228290
uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5
229291
with:
230292
use_oidc: true
@@ -235,6 +297,15 @@ jobs:
235297
matrix:
236298
os: ['ubuntu-latest']
237299
node: ['22', '24']
300+
coverage: [false]
301+
exclude:
302+
- os: 'ubuntu-latest'
303+
node: '24'
304+
coverage: false
305+
include:
306+
- os: 'ubuntu-latest'
307+
node: '24'
308+
coverage: true
238309

239310
name: Test scripts (${{ matrix.os }}, ${{ matrix.node }})
240311
runs-on: ${{ matrix.os }}
@@ -255,16 +326,33 @@ jobs:
255326
with:
256327
node-version: ${{ matrix.node }}
257328

329+
- name: Cache utoo package store
330+
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
331+
with:
332+
path: ${{ runner.temp }}/utoo-store
333+
key: pkgstore-${{ runner.os }}-${{ hashFiles('pnpm-workspace.yaml', '**/package.json') }}
334+
restore-keys: |
335+
pkgstore-${{ runner.os }}-
336+
258337
- name: Install dependencies
338+
env:
339+
UTOO_CACHE_DIR: ${{ runner.temp }}/utoo-store
259340
run: ut install --from pnpm
260341

261-
- name: Run tests
342+
- name: Run tests (with coverage)
343+
if: ${{ matrix.coverage }}
262344
run: |
263345
ut run build -- --workspace ./tools/scripts
264346
ut run ci --workspace tools/scripts
265347
348+
- name: Run tests
349+
if: ${{ !matrix.coverage }}
350+
run: |
351+
ut run build -- --workspace ./tools/scripts
352+
ut run test --workspace tools/scripts
353+
266354
- name: Code Coverage
267-
if: ${{ matrix.os != 'windows-latest' }}
355+
if: ${{ matrix.coverage }}
268356
uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5
269357
with:
270358
use_oidc: true

0 commit comments

Comments
 (0)