-
-
Notifications
You must be signed in to change notification settings - Fork 905
432 lines (394 loc) · 16.7 KB
/
ci.yml
File metadata and controls
432 lines (394 loc) · 16.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
name: CI
permissions: {}
on:
workflow_dispatch:
pull_request:
types: [opened, synchronize]
branches-ignore:
- "**/graphite-base/**"
push:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: ${{ github.ref_name != 'main' }}
jobs:
test-ubuntu:
name: Test Linux
runs-on: ubuntu-latest
steps:
- uses: taiki-e/checkout-action@83ed61bfbe2b8abbb3c66e8b65b1335484c70009 # v1.4.1
- uses: oxc-project/setup-node@8958a8e040102244b619c4a94fccb657a44b1c21 # v1.0.6
- uses: oxc-project/setup-rust@4f86b5d871ae7d24bc420e578be68964ab09e5cc # v1.0.15
with:
save-cache: ${{ github.ref_name == 'main' }}
cache-key: warm
- run: cargo ck
- run: cargo test --all-features
- run: git diff --exit-code # Must commit everything
test-ubuntu-aarch64:
if: ${{ github.ref_name == 'main' }}
name: Test Linux ARM64
runs-on: ubuntu-24.04-arm
steps:
- uses: taiki-e/checkout-action@83ed61bfbe2b8abbb3c66e8b65b1335484c70009 # v1.4.1
- uses: oxc-project/setup-node@8958a8e040102244b619c4a94fccb657a44b1c21 # v1.0.6
- uses: oxc-project/setup-rust@4f86b5d871ae7d24bc420e578be68964ab09e5cc # v1.0.15
with:
save-cache: ${{ github.ref_name == 'main' }}
cache-key: warm-aarch64
- run: cargo ck
- run: cargo test --all-features
- run: git diff --exit-code # Must commit everything
test-mac: # Separate job to save a job on PRs
if: ${{ github.ref_name == 'main' }}
name: Test Mac
runs-on: macos-latest
steps:
- uses: taiki-e/checkout-action@83ed61bfbe2b8abbb3c66e8b65b1335484c70009 # v1.4.1
- uses: oxc-project/setup-node@8958a8e040102244b619c4a94fccb657a44b1c21 # v1.0.6
- uses: oxc-project/setup-rust@4f86b5d871ae7d24bc420e578be68964ab09e5cc # v1.0.15
with:
save-cache: ${{ github.ref_name == 'main' }}
cache-key: warm
- run: cargo ck
- run: cargo test --all-features
- run: git diff --exit-code # Must commit everything
test-windows:
if: ${{ github.ref_name == 'main' }}
name: Test Windows
runs-on: windows-latest
steps:
- run: git config --system core.longpaths true
- uses: taiki-e/checkout-action@83ed61bfbe2b8abbb3c66e8b65b1335484c70009 # v1.4.1
# Unsung heroes of the internet, who led me here to speed up Windows' slowness:
# https://github.com/actions/cache/issues/752#issuecomment-1847036770
# https://github.com/astral-sh/uv/blob/502e04200d52de30d3159894833b3db4f0d6644d/.github/workflows/ci.yml#L158
- uses: oxc-project/setup-node@8958a8e040102244b619c4a94fccb657a44b1c21 # v1.0.6
- uses: samypr100/setup-dev-drive@30f0f98ae5636b2b6501e181dfb3631b9974818d # v4.0.0
with:
workspace-copy: true
drive-size: 12GB
drive-format: ReFS
env-mapping: |
CARGO_HOME,{{ DEV_DRIVE }}/.cargo
RUSTUP_HOME,{{ DEV_DRIVE }}/.rustup
- name: Install Rust
working-directory: ${{ env.DEV_DRIVE_WORKSPACE }}
shell: bash
run: |
# This `awk` command will find the value of our Minimum Supported Rust Version and store it as `MSRV`.
# NOTE: this will fail if there are any other items named `rust-version`. We assume there is only one in our `Cargo.toml`.
MSRV=$(awk -F'=' '/rust-version/ {gsub(/[" ]/, "", $2); printf "%s", ($2 + "")}' Cargo.toml)
# Set profile to minimal and channel to our Minimum Supported Rust Version.
# Running our tests on this channel ensures that our code uses APIs that are supported in our `MSRV`.
sed -i -e 's/profile = "default"/profile = "minimal"/g' -e "s/channel = .*/channel = \"$MSRV\"/g" rust-toolchain.toml
rustup set profile minimal
rustup show
git restore .
- uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2
with:
workspaces: ${{ env.DEV_DRIVE_WORKSPACE }}
save-if: ${{ github.ref_name == 'main' }}
shared-key: windows-latest
- name: Run tests
# No need for `cargo ck` because it's already checked in linux
# Run `website` tests separately to avoid feature unification problems with `oxlint`
run: cargo test --all-features
working-directory: ${{ env.DEV_DRIVE_WORKSPACE }}
shell: bash
test-big-endian:
if: ${{ github.ref_name == 'main' }}
name: Test big-endian # s390x-unknown-linux-gnu is a big-endian
runs-on: ubuntu-latest
steps:
- uses: taiki-e/checkout-action@83ed61bfbe2b8abbb3c66e8b65b1335484c70009 # v1.4.1
- uses: oxc-project/setup-node@8958a8e040102244b619c4a94fccb657a44b1c21 # v1.0.6
- uses: oxc-project/setup-rust@4f86b5d871ae7d24bc420e578be68964ab09e5cc # v1.0.15
with:
save-cache: ${{ github.ref_name == 'main' }}
cache-key: s390x-unknown-linux-gnu
tools: cross
# `--lib --bins --tests` to skip doctests which are very slow to run via `cross`.
# https://github.com/cross-rs/cross/issues/1703
- run: cross test --lib --bins --tests --all-features --target s390x-unknown-linux-gnu
test-32bit:
if: ${{ github.ref_name == 'main' }}
name: Test 32-bit # armv7-unknown-linux-gnueabihf is a 32-bit target
runs-on: ubuntu-latest
steps:
- uses: taiki-e/checkout-action@83ed61bfbe2b8abbb3c66e8b65b1335484c70009 # v1.4.1
- uses: oxc-project/setup-rust@4f86b5d871ae7d24bc420e578be68964ab09e5cc # v1.0.15
with:
save-cache: ${{ github.ref_name == 'main' }}
cache-key: armv7-unknown-linux-gnueabihf
tools: cross
# `--lib --bins --tests` to skip doctests which are very slow to run via `cross`.
# https://github.com/cross-rs/cross/issues/1703
- run: cross test --workspace --lib --bins --tests --all-features --exclude oxc_language_server --exclude oxc_linter --exclude oxlint --target armv7-unknown-linux-gnueabihf
test-wasm32-wasip1-threads:
name: Test wasm32-wasip1-threads
runs-on: ubuntu-latest
steps:
- uses: taiki-e/checkout-action@83ed61bfbe2b8abbb3c66e8b65b1335484c70009 # v1.4.1
- uses: ./.github/actions/check-changes
id: filter
with:
exclude: oxc_linter
paths: napi/,npm/,apps/,pnpm-lock.yaml,package.json
token: ${{ secrets.GITHUB_TOKEN }}
pr-number: ${{ github.event.pull_request.number }}
- uses: oxc-project/setup-rust@4f86b5d871ae7d24bc420e578be68964ab09e5cc # v1.0.15
if: steps.filter.outputs.changed == 'true'
with:
cache-key: wasi
save-cache: ${{ github.ref_name == 'main' }}
- uses: oxc-project/setup-node@8958a8e040102244b619c4a94fccb657a44b1c21 # v1.0.6
if: steps.filter.outputs.changed == 'true'
- name: Build
if: steps.filter.outputs.changed == 'true'
run: |
rustup target add wasm32-wasip1-threads
pnpm run build-wasm-dev
git diff --exit-code # Must commit everything
- name: Test wasi in browser
if: steps.filter.outputs.changed == 'true'
working-directory: napi/parser
run: |
rm -rf *.wasm
pnpm exec playwright install chromium
pnpm run build-wasi
pnpm run build-wasm-dev
pnpm run build-npm-dir
pnpm run test-browser
pnpm build-browser-bundle --npmDir npm-dir
test-napi:
name: Test NAPI
runs-on: ubuntu-latest
steps:
- uses: taiki-e/checkout-action@83ed61bfbe2b8abbb3c66e8b65b1335484c70009 # v1.4.1
- uses: ./.github/actions/check-changes
id: filter
with:
exclude: oxc_linter,oxc_language_server
paths: napi/,npm/,apps/,tasks/e2e/,pnpm-lock.yaml,package.json,editors/
token: ${{ secrets.GITHUB_TOKEN }}
pr-number: ${{ github.event.pull_request.number }}
- uses: oxc-project/setup-rust@4f86b5d871ae7d24bc420e578be68964ab09e5cc # v1.0.15
if: steps.filter.outputs.changed == 'true'
with:
cache-key: napi
save-cache: ${{ github.ref_name == 'main' }}
- uses: oxc-project/setup-node@8958a8e040102244b619c4a94fccb657a44b1c21 # v1.0.6
if: steps.filter.outputs.changed == 'true'
- uses: ./.github/actions/clone-submodules
if: steps.filter.outputs.changed == 'true'
with:
babel: false
prettier: false
- if: steps.filter.outputs.changed == 'true'
name: Run tests in workspace
env:
RUN_RAW_RANGE_TESTS: "true"
RUN_RAW_TOKENS_TESTS: "true"
run: |
rustup target add wasm32-wasip1-threads
pnpm run build-test
pnpm run test
- if: steps.filter.outputs.changed == 'true'
name: Run e2e tests
working-directory: tasks/e2e
run: pnpm run test
- if: steps.filter.outputs.changed == 'true'
run: |
git diff --exit-code # Must commit everything
test-napi-windows:
name: Test NAPI (windows)
runs-on: windows-latest
if: ${{ github.ref_name == 'main' }}
steps:
- name: Enable long paths on Windows
run: git config --system core.longpaths true
- uses: taiki-e/checkout-action@83ed61bfbe2b8abbb3c66e8b65b1335484c70009 # v1.4.1
- uses: ./.github/actions/check-changes
id: filter
with:
exclude: oxc_linter,oxc_language_server
paths: napi/,npm/,apps/,tasks/e2e/,pnpm-lock.yaml,package.json,editors/
token: ${{ secrets.GITHUB_TOKEN }}
pr-number: ${{ github.event.pull_request.number }}
- uses: oxc-project/setup-rust@4f86b5d871ae7d24bc420e578be68964ab09e5cc # v1.0.15
if: steps.filter.outputs.changed == 'true'
with:
cache-key: napi
save-cache: ${{ github.ref_name == 'main' }}
- uses: oxc-project/setup-node@8958a8e040102244b619c4a94fccb657a44b1c21 # v1.0.6
if: steps.filter.outputs.changed == 'true'
- uses: ./.github/actions/clone-submodules
if: steps.filter.outputs.changed == 'true'
with:
babel: false
prettier: false
- if: steps.filter.outputs.changed == 'true'
name: Run tests in workspace
env:
RUN_RAW_RANGE_TESTS: "true"
run: |
rustup target add wasm32-wasip1-threads
pnpm run build-test
pnpm run test
- if: steps.filter.outputs.changed == 'true'
name: Run e2e tests
run: |
pnpm install --frozen-lockfile
pnpm run test
working-directory: tasks/e2e
- if: steps.filter.outputs.changed == 'true'
run: |
git diff --exit-code # Must commit everything
typos:
name: Spell Check
runs-on: ubuntu-slim
steps:
- uses: taiki-e/checkout-action@83ed61bfbe2b8abbb3c66e8b65b1335484c70009 # v1.4.1
- uses: crate-ci/typos@631208b7aac2daa8b707f55e7331f9112b0e062d # v1.44.0
with:
files: .
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: taiki-e/checkout-action@83ed61bfbe2b8abbb3c66e8b65b1335484c70009 # v1.4.1
- uses: oxc-project/setup-node@8958a8e040102244b619c4a94fccb657a44b1c21 # v1.0.6
- uses: oxc-project/setup-rust@4f86b5d871ae7d24bc420e578be68964ab09e5cc # v1.0.15
with:
save-cache: ${{ github.ref_name == 'main' }}
cache-key: clippy
components: clippy rust-docs
- run: cargo lint -- -D warnings
- run: cargo lint --profile dev-no-debug-assertions -- -D warnings
- run: RUSTDOCFLAGS='-D warnings' cargo doc --no-deps --document-private-items
- run: pnpm --filter oxlint-app build-js
- run: pnpm --filter oxfmt-app build-js
- run: node --run lint
conformance:
name: Conformance
runs-on: ubuntu-latest
steps:
- uses: taiki-e/checkout-action@83ed61bfbe2b8abbb3c66e8b65b1335484c70009 # v1.4.1
- name: Check if conformance should run
id: filter
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
SHOULD_RUN=$(node .github/scripts/check-conformance-changes.js)
echo "src=$SHOULD_RUN" >> $GITHUB_OUTPUT
- uses: ./.github/actions/clone-submodules
if: steps.filter.outputs.src == 'true'
- uses: oxc-project/setup-node@8958a8e040102244b619c4a94fccb657a44b1c21 # v1.0.6
if: steps.filter.outputs.src == 'true'
- uses: oxc-project/setup-rust@4f86b5d871ae7d24bc420e578be68964ab09e5cc # v1.0.15
if: steps.filter.outputs.src == 'true'
with:
cache-key: conformance
save-cache: ${{ github.ref_name == 'main' }}
tools: just
- name: Check Conformance
if: steps.filter.outputs.src == 'true'
run: |
just update-transformer-fixtures
just coverage
git diff --exit-code
minification:
name: Minification Size
runs-on: ubuntu-latest
steps:
- uses: taiki-e/checkout-action@83ed61bfbe2b8abbb3c66e8b65b1335484c70009 # v1.4.1
- uses: ./.github/actions/check-changes
id: filter
with:
packages: oxc_minsize
paths: .github/workflows/ci.yml
token: ${{ secrets.GITHUB_TOKEN }}
pr-number: ${{ github.event.pull_request.number }}
- uses: oxc-project/setup-rust@4f86b5d871ae7d24bc420e578be68964ab09e5cc # v1.0.15
if: steps.filter.outputs.changed == 'true'
with:
cache-key: minsize
save-cache: ${{ github.ref_name == 'main' }}
- name: Check minification size
if: steps.filter.outputs.changed == 'true'
run: |
cargo minsize
git diff --exit-code
allocs:
name: Allocations
runs-on: ubuntu-latest
steps:
- uses: taiki-e/checkout-action@83ed61bfbe2b8abbb3c66e8b65b1335484c70009 # v1.4.1
- uses: ./.github/actions/check-changes
id: filter
with:
packages: oxc_track_memory_allocations
paths: .github/workflows/ci.yml
token: ${{ secrets.GITHUB_TOKEN }}
pr-number: ${{ github.event.pull_request.number }}
- uses: oxc-project/setup-rust@4f86b5d871ae7d24bc420e578be68964ab09e5cc # v1.0.15
if: steps.filter.outputs.changed == 'true'
with:
cache-key: allocs
save-cache: ${{ github.ref_name == 'main' }}
- name: Check allocations
if: steps.filter.outputs.changed == 'true'
run: |
cargo allocs
git diff --exit-code ||
(echo 'Allocations have changed. Run the `cargo allocs` command to update the allocation snapshot, otherwise please fix the regression.' && exit 1)
ast_changes:
name: AST Changes
runs-on: ubuntu-latest
steps:
- uses: taiki-e/checkout-action@83ed61bfbe2b8abbb3c66e8b65b1335484c70009 # v1.4.1
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
id: filter
with:
filters: ".github/generated/ast_changes_watch_list.yml"
- uses: oxc-project/setup-rust@4f86b5d871ae7d24bc420e578be68964ab09e5cc # v1.0.15
if: steps.filter.outputs.src == 'true'
with:
components: rustfmt
cache-key: ast_changes
save-cache: ${{ github.ref_name == 'main' }}
- uses: oxc-project/setup-node@8958a8e040102244b619c4a94fccb657a44b1c21 # v1.0.6
if: steps.filter.outputs.src == 'true'
- name: Check AST Changes
if: steps.filter.outputs.src == 'true'
run: |
cargo run -p oxc_ast_tools
git diff --exit-code ||
(echo 'AST changes caused the "generated" code to get outdated. Have you forgotten to run the `just ast` command and/or commit generated codes?' && exit 1)
lintgen:
name: Linter changes
runs-on: ubuntu-latest
steps:
- uses: taiki-e/checkout-action@83ed61bfbe2b8abbb3c66e8b65b1335484c70009 # v1.4.1
- uses: ./.github/actions/check-changes
id: filter
with:
packages: oxc_linter
paths: tasks/linter_codegen/,.github/workflows/ci.yml
token: ${{ secrets.GITHUB_TOKEN }}
pr-number: ${{ github.event.pull_request.number }}
- uses: oxc-project/setup-rust@4f86b5d871ae7d24bc420e578be68964ab09e5cc # v1.0.15
if: steps.filter.outputs.changed == 'true'
with:
components: rustfmt
cache-key: lintgen
save-cache: ${{ github.ref_name == 'main' }}
- name: Check linter changes
if: steps.filter.outputs.changed == 'true'
run: |
cargo lintgen
git diff --exit-code ||
(echo 'Linter codegen has changed. Run the `cargo lintgen` command to update the linter code generated and commit it.' && exit 1)