Skip to content

Commit 35e48c6

Browse files
committed
Build all packages in 1 job
1 parent aa7efa2 commit 35e48c6

File tree

1 file changed

+85
-55
lines changed

1 file changed

+85
-55
lines changed

.github/workflows/ci.yml

Lines changed: 85 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -145,17 +145,68 @@ jobs:
145145
pnpm run test-browser
146146
pnpm build-browser-bundle --npmDir npm-dir
147147
148-
# Sharded because these tests are slow
149-
test-napi:
148+
# NAPI tests are slow, so we shard them into multiple jobs.
149+
# But we want to build all the packages together, so they share a single build cache.
150+
#
151+
# * `napi-build` - build all packages, and upload build files as an artifact.
152+
# * In parallel:
153+
# * `napi-test` (sharded - 1 job per package)
154+
# * `napi-test-e2e`
155+
# * `napi-cleanup` - deletes build files artifact
156+
napi-build:
157+
name: Build NAPI packages
158+
runs-on: ubuntu-latest
159+
steps:
160+
- uses: taiki-e/checkout-action@b13d20b7cda4e2f325ef19895128f7ff735c0b3d # v1.3.1
161+
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
162+
id: filter
163+
with:
164+
predicate-quantifier: "every"
165+
filters: |
166+
src:
167+
- '!crates/oxc_linter/**'
168+
- '!crates/oxc_language_server/**'
169+
- '!editors/**'
170+
- uses: oxc-project/setup-rust@cd82e1efec7fef815e2c23d296756f31c7cdc03d # v1.0.0
171+
if: steps.filter.outputs.src == 'true'
172+
with:
173+
cache-key: napi
174+
save-cache: ${{ github.ref_name == 'main' }}
175+
- uses: oxc-project/setup-node@f42e3bda950c7454575e78ee4eaac880a077700c # v1.0.0
176+
if: steps.filter.outputs.src == 'true'
177+
- name: Build
178+
if: steps.filter.outputs.src == 'true'
179+
run: |
180+
rustup target add wasm32-wasip1-threads
181+
pnpm run build-test
182+
- name: Check no uncommitted files
183+
if: steps.filter.outputs.src == 'true'
184+
run: |
185+
git diff --exit-code # Must commit everything
186+
- name: Upload build files
187+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
188+
with:
189+
if-no-files-found: error
190+
name: napi
191+
path: |
192+
napi/minify/*.node
193+
napi/oxlint2/dist/
194+
napi/parser/*.node
195+
napi/transform/*.node
196+
retention-days: 1
197+
198+
napi-test:
150199
name: Test NAPI
151200
runs-on: ubuntu-latest
201+
needs: napi-build
152202
strategy:
153203
fail-fast: true
154204
matrix:
155205
component:
206+
- minify
156207
- oxlint2
157208
- parser
158-
- playground
209+
- transform
159210
steps:
160211
- uses: taiki-e/checkout-action@b13d20b7cda4e2f325ef19895128f7ff735c0b3d # v1.3.1
161212
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
@@ -167,36 +218,28 @@ jobs:
167218
- '!crates/oxc_linter/**'
168219
- '!crates/oxc_language_server/**'
169220
- '!editors/**'
170-
- uses: ./.github/actions/clone-submodules
171-
if: steps.filter.outputs.src == 'true' && matrix.component == 'parser'
172-
- uses: oxc-project/setup-rust@cd82e1efec7fef815e2c23d296756f31c7cdc03d # v1.0.0
221+
- uses: oxc-project/setup-node@f42e3bda950c7454575e78ee4eaac880a077700c # v1.0.0
173222
if: steps.filter.outputs.src == 'true'
223+
- name: Download build files
224+
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
174225
with:
175-
cache-key: napi-${{ matrix.component }}
176-
save-cache: ${{ github.ref_name == 'main' }}
177-
- uses: oxc-project/setup-node@f42e3bda950c7454575e78ee4eaac880a077700c # v1.0.0
226+
name: napi
227+
pattern: napi/${{ matrix.component }}/**/*
228+
# Submodules only needed for parser tests
229+
- uses: ./.github/actions/clone-submodules
230+
if: steps.filter.outputs.src == 'true' && matrix.component == 'parser'
231+
- name: Run tests
178232
if: steps.filter.outputs.src == 'true'
179-
- if: steps.filter.outputs.src == 'true'
180-
name: Build
181-
working-directory: napi/${{ matrix.component }}
182-
run: |
183-
rustup target add wasm32-wasip1-threads
184-
pnpm run build-test
185-
- if: steps.filter.outputs.src == 'true' && matrix.component != 'playground'
186-
name: Run tests
187233
working-directory: napi/${{ matrix.component }}
188234
env:
189235
RUN_RAW_TESTS: "true"
190236
run: |
191237
pnpm run test
192-
- if: steps.filter.outputs.src == 'true'
193-
run: |
194-
git diff --exit-code # Must commit everything
195238
196-
# Includes transformer and minifier
197-
test-napi-e2e:
239+
napi-test-e2e:
198240
name: Test NAPI (e2e)
199241
runs-on: ubuntu-latest
242+
needs: napi-build
200243
steps:
201244
- uses: taiki-e/checkout-action@b13d20b7cda4e2f325ef19895128f7ff735c0b3d # v1.3.1
202245
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
@@ -208,46 +251,33 @@ jobs:
208251
- '!crates/oxc_linter/**'
209252
- '!crates/oxc_language_server/**'
210253
- '!editors/**'
211-
- uses: oxc-project/setup-rust@cd82e1efec7fef815e2c23d296756f31c7cdc03d # v1.0.0
254+
- uses: oxc-project/setup-node@f42e3bda950c7454575e78ee4eaac880a077700c # v1.0.0
212255
if: steps.filter.outputs.src == 'true'
256+
- name: Download build files
257+
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
213258
with:
214-
cache-key: napi-e2e
215-
save-cache: ${{ github.ref_name == 'main' }}
216-
- uses: oxc-project/setup-node@f42e3bda950c7454575e78ee4eaac880a077700c # v1.0.0
259+
name: napi
260+
pattern: napi/**/*.node
261+
- name: Install NPM packages
217262
if: steps.filter.outputs.src == 'true'
218-
- if: steps.filter.outputs.src == 'true'
219-
name: Install wasm32-wasip1-threads
220-
run: |
221-
rustup target add wasm32-wasip1-threads
222-
- if: steps.filter.outputs.src == 'true'
223-
name: Build transformer
224-
working-directory: napi/transform
225-
run: |
226-
pnpm run build-test
227-
- if: steps.filter.outputs.src == 'true'
228-
name: Run transformer tests
229-
working-directory: napi/transform
230-
run: |
231-
pnpm run test
232-
- if: steps.filter.outputs.src == 'true'
233-
name: Build minifier
234-
working-directory: napi/minify
235-
run: |
236-
pnpm run build-test
237-
- if: steps.filter.outputs.src == 'true'
238-
name: Run minifier tests
239-
working-directory: napi/minify
240-
run: |
241-
pnpm run test
242-
- if: steps.filter.outputs.src == 'true'
243-
name: Run e2e tests
244263
working-directory: tasks/e2e
245264
run: |
246265
pnpm install --frozen-lockfile
247-
pnpm run test
248-
- if: steps.filter.outputs.src == 'true'
266+
- name: Run tests
267+
if: steps.filter.outputs.src == 'true'
268+
working-directory: tasks/e2e
249269
run: |
250-
git diff --exit-code # Must commit everything
270+
pnpm run test
271+
272+
napi-cleanup:
273+
name: Delete NAPI build artifacts
274+
runs-on: ubuntu-latest
275+
needs: [napi-test, napi-test-e2e]
276+
steps:
277+
- uses: geekyeggo/delete-artifact@vf275313e70c08f6120db482d7a6b98377786765b # v5.1.0
278+
with:
279+
name: napi
280+
failOnError: false
251281

252282
typos:
253283
name: Spell Check

0 commit comments

Comments
 (0)