@@ -145,17 +145,68 @@ jobs:
145
145
pnpm run test-browser
146
146
pnpm build-browser-bundle --npmDir npm-dir
147
147
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 :
150
199
name : Test NAPI
151
200
runs-on : ubuntu-latest
201
+ needs : napi-build
152
202
strategy :
153
203
fail-fast : true
154
204
matrix :
155
205
component :
206
+ - minify
156
207
- oxlint2
157
208
- parser
158
- - playground
209
+ - transform
159
210
steps :
160
211
- uses : taiki-e/checkout-action@b13d20b7cda4e2f325ef19895128f7ff735c0b3d # v1.3.1
161
212
- uses : dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
@@ -167,36 +218,28 @@ jobs:
167
218
- '!crates/oxc_linter/**'
168
219
- '!crates/oxc_language_server/**'
169
220
- '!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
173
222
if : steps.filter.outputs.src == 'true'
223
+ - name : Download build files
224
+ uses : actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
174
225
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
178
232
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
187
233
working-directory : napi/${{ matrix.component }}
188
234
env :
189
235
RUN_RAW_TESTS : " true"
190
236
run : |
191
237
pnpm run test
192
- - if : steps.filter.outputs.src == 'true'
193
- run : |
194
- git diff --exit-code # Must commit everything
195
238
196
- # Includes transformer and minifier
197
- test-napi-e2e :
239
+ napi-test-e2e :
198
240
name : Test NAPI (e2e)
199
241
runs-on : ubuntu-latest
242
+ needs : napi-build
200
243
steps :
201
244
- uses : taiki-e/checkout-action@b13d20b7cda4e2f325ef19895128f7ff735c0b3d # v1.3.1
202
245
- uses : dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
@@ -208,46 +251,33 @@ jobs:
208
251
- '!crates/oxc_linter/**'
209
252
- '!crates/oxc_language_server/**'
210
253
- '!editors/**'
211
- - uses : oxc-project/setup-rust@cd82e1efec7fef815e2c23d296756f31c7cdc03d # v1.0.0
254
+ - uses : oxc-project/setup-node@f42e3bda950c7454575e78ee4eaac880a077700c # v1.0.0
212
255
if : steps.filter.outputs.src == 'true'
256
+ - name : Download build files
257
+ uses : actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
213
258
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
217
262
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
244
263
working-directory : tasks/e2e
245
264
run : |
246
265
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
249
269
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
251
281
252
282
typos :
253
283
name : Spell Check
0 commit comments