Skip to content

Commit 2c25c8c

Browse files
yokosznclaude
andcommitted
improvement(ci): parallelize audit+prepare, add caching, share build artifacts
- Extract `prepare` job: install → build:packages → generate → rebuild. Uploads compiled dist/ + .mercato/generated/ as a reusable artifact so downstream jobs skip the repeated build+generate work. - Extract `audit` job: runs in parallel with `prepare` rather than sequentially inside `test`, removing it from the critical path. - `test` job now downloads the artifact instead of rebuilding packages. - `ephemeral-integration` downloads the same artifact and skips install+build:packages×2+generate (was ~1m31s of duplicate work). - Add `cache: 'yarn'` to all setup-node@v4 steps (~45s saved per job on warm cache hits). - Add `actions/cache` for pip to avoid re-downloading markitdown on every run. Measured baseline (run 24178370484): test 7m12s, ephemeral-integration 48m47s, total wall ~55 min. Integration tests themselves account for 44m59s; sharding across 3 Playwright workers (--shard=N/3) is the next lever — see comment in the ephemeral-integration job for what that would require. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent f18f549 commit 2c25c8c

1 file changed

Lines changed: 93 additions & 16 deletions

File tree

.github/workflows/ci.yml

Lines changed: 93 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@ on:
1313
- develop
1414

1515
jobs:
16-
test:
16+
# ── Shared build ────────────────────────────────────────────────────────────
17+
# Installs deps, compiles all packages, and runs the code generator.
18+
# Uploads the compiled dist/ + generated .mercato/ as an artifact so every
19+
# downstream job can skip this work entirely.
20+
prepare:
1721
runs-on: ubuntu-latest
1822
steps:
1923
- name: Checkout repository
@@ -23,19 +27,14 @@ jobs:
2327
uses: actions/setup-node@v4
2428
with:
2529
node-version: 24
30+
cache: 'yarn'
2631

2732
- name: Enable Corepack
2833
run: corepack enable
2934

30-
- name: Install markitdown CLI
31-
run: python3 -m pip install --upgrade pip markitdown
32-
3335
- name: Install dependencies
3436
run: yarn install --immutable
3537

36-
- name: Audit dependencies for known CVEs
37-
run: yarn npm audit --all --recursive --severity high
38-
3938
- name: Build packages
4039
run: yarn build:packages
4140

@@ -45,6 +44,76 @@ jobs:
4544
- name: Rebuild packages with generated files
4645
run: yarn build:packages
4746

47+
- name: Upload build artifacts
48+
uses: actions/upload-artifact@v4
49+
with:
50+
name: build-artifacts
51+
path: |
52+
packages/*/dist/
53+
apps/mercato/.mercato/generated/
54+
retention-days: 1
55+
if-no-files-found: error
56+
57+
# ── Security audit ──────────────────────────────────────────────────────────
58+
# Runs in parallel with 'prepare' — only needs yarn install, not the full build.
59+
audit:
60+
runs-on: ubuntu-latest
61+
steps:
62+
- name: Checkout repository
63+
uses: actions/checkout@v4
64+
65+
- name: Setup Node.js
66+
uses: actions/setup-node@v4
67+
with:
68+
node-version: 24
69+
cache: 'yarn'
70+
71+
- name: Enable Corepack
72+
run: corepack enable
73+
74+
- name: Install dependencies
75+
run: yarn install --immutable
76+
77+
- name: Audit dependencies for known CVEs
78+
run: yarn npm audit --all --recursive --severity high
79+
80+
# ── Quality checks ──────────────────────────────────────────────────────────
81+
# Typechecking, unit tests, i18n sync, and the Next.js app build.
82+
# Blocked on both 'prepare' (needs compiled packages) and 'audit' (security gate).
83+
test:
84+
runs-on: ubuntu-latest
85+
needs: [prepare, audit]
86+
steps:
87+
- name: Checkout repository
88+
uses: actions/checkout@v4
89+
90+
- name: Setup Node.js
91+
uses: actions/setup-node@v4
92+
with:
93+
node-version: 24
94+
cache: 'yarn'
95+
96+
- name: Enable Corepack
97+
run: corepack enable
98+
99+
- name: Cache pip packages
100+
uses: actions/cache@v4
101+
with:
102+
path: ~/.cache/pip
103+
key: pip-markitdown-v1
104+
restore-keys: pip-markitdown-
105+
106+
- name: Install markitdown CLI
107+
run: python3 -m pip install --upgrade pip markitdown
108+
109+
- name: Install dependencies
110+
run: yarn install --immutable
111+
112+
- name: Download build artifacts
113+
uses: actions/download-artifact@v4
114+
with:
115+
name: build-artifacts
116+
48117
- name: Check dependency version conflicts
49118
run: yarn check:dep-versions
50119

@@ -64,6 +133,14 @@ jobs:
64133
- name: Build
65134
run: yarn build:app
66135

136+
# ── Integration tests ───────────────────────────────────────────────────────
137+
# Boots an ephemeral app server and runs the full Playwright suite.
138+
# Blocked on 'test' so integration only runs when unit tests are green.
139+
#
140+
# Performance note: at 311 spec files with workers: 1, this job accounts for
141+
# ~45 of the ~55 min total wall time. Playwright sharding across 3 parallel
142+
# runners (--shard=N/3) would cut this to ~16 min but requires each shard
143+
# to start its own ephemeral server and a final step to merge coverage JSON.
67144
ephemeral-integration:
68145
runs-on: ubuntu-latest
69146
needs: test
@@ -81,21 +158,18 @@ jobs:
81158
uses: actions/setup-node@v4
82159
with:
83160
node-version: 24
161+
cache: 'yarn'
84162

85163
- name: Enable Corepack
86164
run: corepack enable
87165

88166
- name: Install dependencies
89167
run: yarn install --immutable
90168

91-
- name: Build packages
92-
run: yarn build:packages
93-
94-
- name: Prepare generated modules
95-
run: yarn generate
96-
97-
- name: Rebuild packages with generated files
98-
run: yarn build:packages
169+
- name: Download build artifacts
170+
uses: actions/download-artifact@v4
171+
with:
172+
name: build-artifacts
99173

100174
- name: Build app
101175
run: yarn workspace @open-mercato/app build
@@ -149,7 +223,7 @@ jobs:
149223
\`| Functions | \${t.functions?.covered ?? 0}/\${t.functions?.total ?? 0} | \${t.functions?.pct ?? 0}% |\`,
150224
\`| Branches | \${t.branches?.covered ?? 0}/\${t.branches?.total ?? 0} | \${t.branches?.pct ?? 0}% |\`,
151225
'',
152-
'Source: `.ai/qa/test-results/coverage/code/coverage-summary.json`',
226+
'Source: \`.ai/qa/test-results/coverage/code/coverage-summary.json\`',
153227
'',
154228
].join('\n'));
155229
" "$SUMMARY_FILE"
@@ -165,6 +239,9 @@ jobs:
165239
.ai/qa/test-results/results.json
166240
if-no-files-found: ignore
167241

242+
# ── Docker image builds ──────────────────────────────────────────────────────
243+
# Validates all Dockerfiles build cleanly. Runs in parallel with
244+
# 'ephemeral-integration' (both need test), so it does not add to wall time.
168245
docker-build:
169246
runs-on: ubuntu-latest
170247
needs: test

0 commit comments

Comments
 (0)