-
-
Notifications
You must be signed in to change notification settings - Fork 594
472 lines (420 loc) · 14.6 KB
/
ci.yml
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
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
name: CI
on:
merge_group:
types: [checks_requested]
workflow_dispatch:
inputs:
debug_enabled:
type: boolean
description: "Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)"
required: false
default: false
pull_request:
types: [opened, synchronize]
push:
branches:
- main
paths-ignore:
- "**/*.md"
- "website/**"
tags-ignore:
- "**"
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: ${{ github.ref_name != 'main' }}
jobs:
get-runner-labels:
name: Get Runner Labels
uses: ./.github/workflows/get-runner-labels.yml
check-changed:
runs-on: ubuntu-latest
name: Check Source Changed
outputs:
changed: ${{ steps.filter.outputs.changed == 'true' }}
document_changed: ${{ steps.document_filter.outputs.changed == 'true' }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: filter
with:
predicate-quantifier: "every"
filters: |
changed:
- "!**/*.md"
- "!**/*.mdx"
- "!website/**"
- uses: dorny/paths-filter@v3
id: document_filter
with:
predicate-quantifier: "every"
filters: |
changed:
- "website/**"
test-linux:
name: Test Linux
needs: [get-runner-labels, check-changed]
uses: ./.github/workflows/reusable-build.yml
with:
target: x86_64-unknown-linux-gnu
profile: "debug"
native: ${{ needs.get-runner-labels.outputs.LINUX_RUNNER_LABELS == '"ubuntu-22.04"' }}
runner: ${{ needs.get-runner-labels.outputs.LINUX_RUNNER_LABELS }}
skipable: ${{ needs.check-changed.outputs.changed != 'true' }}
test-release-linux:
name: Test Release Linux
needs: [get-runner-labels]
if: contains(github.event.pull_request.title, '!linux')
uses: ./.github/workflows/reusable-build.yml
strategy:
fail-fast: false # Build and test everything so we can look at all the errors
matrix:
array:
- target: x86_64-unknown-linux-gnu
- target: aarch64-unknown-linux-gnu
- target: x86_64-unknown-linux-musl
- target: aarch64-unknown-linux-musl
with:
target: ${{ matrix.array.target }}
runner: ${{ needs.get-runner-labels.outputs.LINUX_RUNNER_LABELS }}
test-windows:
name: Test Windows
needs: [get-runner-labels, check-changed]
uses: ./.github/workflows/reusable-build.yml
with:
target: x86_64-pc-windows-msvc
profile: "debug"
runner: ${{ needs.get-runner-labels.outputs.WINDOWS_RUNNER_LABELS }}
skipable: ${{ needs.check-changed.outputs.changed != 'true' }}
test-release-windows:
name: Test Release Windows
needs: [get-runner-labels]
if: contains(github.event.pull_request.title, '!windows')
uses: ./.github/workflows/reusable-build.yml
strategy:
fail-fast: false # Build and test everything so we can look at all the errors
matrix:
array:
- target: i686-pc-windows-msvc
- target: x86_64-pc-windows-msvc
- target: aarch64-pc-windows-msvc
with:
target: ${{ matrix.array.target }}
runner: ${{ needs.get-runner-labels.outputs.WINDOWS_RUNNER_LABELS }}
test-mac:
name: Test Mac
needs: [get-runner-labels, check-changed]
if: github.ref_name == 'main' || contains(github.event.pull_request.title, '!macos')
uses: ./.github/workflows/reusable-build.yml
with:
target: x86_64-apple-darwin
profile: "debug"
runner: ${{ needs.get-runner-labels.outputs.MACOS_RUNNER_LABELS }}
skipable: ${{ needs.check-changed.outputs.changed != 'true' }}
test-release-mac:
name: Test Release Mac
needs: [get-runner-labels]
if: contains(github.event.pull_request.title, '!macos')
uses: ./.github/workflows/reusable-build.yml
strategy:
fail-fast: false # Build and test everything so we can look at all the errors
matrix:
array:
- target: x86_64-apple-darwin
- target: aarch64-apple-darwin
with:
target: ${{ matrix.array.target }}
runner: ${{ needs.get-runner-labels.outputs.MACOS_RUNNER_LABELS }}
cargo-deny:
name: Check license of dependencies
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
src:
- 'Cargo.lock'
- name: Install cargo-deny
if: steps.filter.outputs.src == 'true'
uses: taiki-e/install-action@v2
with:
tool: [email protected]
- name: Check licenses
if: steps.filter.outputs.src == 'true'
run: cargo deny check license
spell:
name: Spell check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: crate-ci/[email protected]
with:
files: .
lint:
name: Lint and format code
runs-on: ubuntu-latest
needs: [check-changed]
if: ${{ needs.check-changed.outputs.changed == 'true' }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: changes
with:
filters: |
src:
- pnpm-lock.yaml
- '**/*.{ts,js,mjs,tsx,jsx}'
- name: Pnpm Cache
uses: ./.github/actions/pnpm-cache
- name: Lint js
if: steps.changes.outputs.src == 'true'
run: pnpm run lint-ci:js
- name: Prettier
if: steps.changes.outputs.src == 'true'
run: pnpm run format-ci:js
- name: Check Dependency Version
if: steps.changes.outputs.src == 'true'
run: pnpm run check-dependency-version
lint-website:
name: Lint and format website
runs-on: ubuntu-latest
needs: [check-changed]
if: ${{ needs.check-changed.outputs.document_changed == 'true' }}
steps:
- uses: actions/checkout@v4
- name: Pnpm Cache
uses: ./.github/actions/pnpm-cache
- name: Run
run: |
cd website
pnpm install
pnpm run check:ci
rust_changes:
name: Rust Changes
runs-on: ubuntu-latest
needs: [check-changed]
if: ${{ needs.check-changed.outputs.changed == 'true' }}
outputs:
changed: ${{ steps.filter.outputs.changed }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
changed:
- '.github/workflows/ci.yml'
- 'crates/**'
- 'Cargo.lock'
- 'Cargo.toml'
- 'rust-toolchain.toml'
pnpm_lockfile_check:
name: Pnpm Lockfile Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Pnpm Cache # Required by some tests
uses: ./.github/actions/pnpm-cache
with:
frozen-lockfile: true
rust_check:
name: Rust check
needs: [get-runner-labels, rust_changes]
if: ${{ needs.rust_changes.outputs.changed == 'true' }}
runs-on: ${{ fromJSON(needs.get-runner-labels.outputs.LINUX_RUNNER_LABELS) }}
steps:
- uses: actions/checkout@v4
- name: Install Rust Toolchain
uses: ./.github/actions/rustup
with:
clippy: true
fmt: true
shared-key: check
- name: Pnpm Cache # Required by some tests
uses: ./.github/actions/pnpm-cache
- name: Run Cargo Check
run: cargo check --workspace --all-targets --locked # Not using --release because it uses too much cache, and is also slow.
- name: Run Clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: --workspace --all-targets --tests -- -D warnings
- name: Run rustfmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
- name: Run toml format check
run: pnpm run format-ci:toml
rust_unused_dependencies:
name: Check Rust Unused Dependencies
needs: [get-runner-labels, rust_changes]
if: ${{ needs.rust_changes.outputs.changed == 'true' }}
runs-on: ${{ fromJSON(needs.get-runner-labels.outputs.LINUX_RUNNER_LABELS) }}
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/rustup
with:
shared-key: check
- uses: cargo-bins/[email protected]
- run: cargo binstall --no-confirm cargo-shear
- run: cargo shear
rust_test:
name: Rust test
needs: [get-runner-labels, rust_changes]
if: ${{ needs.rust_changes.outputs.changed == 'true' }}
runs-on: ${{ fromJSON(needs.get-runner-labels.outputs.LINUX_RUNNER_LABELS) }}
steps:
- uses: actions/checkout@v4
- name: Pnpm Cache # Required by some tests
uses: ./.github/actions/pnpm-cache
- name: Install Rust Toolchain
uses: ./.github/actions/rustup
with:
save-cache: ${{ github.ref_name == 'main' }}
shared-key: check
# Compile test without debug info for reducing the CI cache size
- name: Change profile.test
shell: bash
run: |
echo '[profile.test]' >> Cargo.toml
echo 'debug = false' >> Cargo.toml
- name: Run test
# reason for excluding https://github.com/napi-rs/napi-rs/issues/2200
run: cargo test --workspace --exclude rspack_node -- --nocapture
rust_test_miri:
name: Rust test miri
needs: [get-runner-labels, rust_changes]
# TODO: enable it after self hosted runners are ready
# if: needs.rust_changes.outputs.changed == 'true' && github.ref_name == 'main' && github.repository_owner == 'web-infra-dev'
if: false
runs-on: ${{ fromJSON(needs.get-runner-labels.outputs.LINUX_RUNNER_LABELS) }}
steps:
- uses: actions/checkout@v4
- name: Pnpm Cache # Required by some tests
uses: ./.github/actions/pnpm-cache
- name: Install Rust Toolchain
uses: ./.github/actions/rustup
with:
save-cache: ${{ github.ref_name == 'main' }}
shared-key: check
miri: true
# Compile test without debug info for reducing the CI cache size
- name: Change profile.test
shell: bash
run: |
echo '[profile.test]' >> Cargo.toml
echo 'debug = false' >> Cargo.toml
- name: Run test
env:
MIRIFLAGS: -Zmiri-tree-borrows -Zmiri-disable-isolation
# reason for excluding https://github.com/napi-rs/napi-rs/issues/2200
run: cargo miri test --workspace --exclude rspack_node -- --nocapture
run_rust_benchmark:
name: Run rust benchmark
runs-on: ubuntu-latest
needs: [rust_changes, rust_check, rust_test]
steps:
- uses: actions/checkout@v4
- name: Pnpm Cache # Required by some tests
uses: ./.github/actions/pnpm-cache
- name: Install Rust Toolchain
uses: ./.github/actions/rustup
with:
save-cache: ${{ github.ref_name == 'main' }}
shared-key: check
- name: Install Tools
uses: taiki-e/install-action@v2
with:
tool: cargo-codspeed
- name: Build Benchmark
run: cargo codspeed build -p rspack_benchmark --features codspeed
- name: Run benchmark
uses: CodSpeedHQ/action@v3
timeout-minutes: 30
with:
run: cargo codspeed run
token: ${{ secrets.CODSPEED_TOKEN }}
run_benchmark:
name: Run benchmark
runs-on: ubuntu-latest
# TODO: enable it after security tokens are added
# if: github.ref_name == 'main' && github.repository_owner == 'web-infra-dev'
if: false
steps:
- name: Run Benchmark
uses: convictional/[email protected]
with:
owner: ${{ github.repository_owner }}
repo: "rspack-ecosystem-benchmark"
workflow_file_name: "bench_rspack_commit.yml"
github_token: ${{ secrets.RSPACK_ACCESS_TOKEN }}
ref: "main"
client_payload: '{"commit_sha":"${{ github.sha }}"}'
run_ecosystem_ci:
name: Run Ecosystem CI
runs-on: ubuntu-latest
# TODO: enable it after security tokens are added
# if: github.ref_name == 'main' && github.repository_owner == 'web-infra-dev'
if: false
steps:
- name: Run Ecosystem CI
id: eco_ci
continue-on-error: true
uses: convictional/[email protected]
with:
owner: "rspack-contrib"
repo: "rspack-ecosystem-ci"
workflow_file_name: "ecosystem-ci-from-commit.yml"
github_token: ${{ secrets.RSPACK_ACCESS_TOKEN }}
ref: "main"
client_payload: '{"commitSHA":"${{ github.sha }}","repo":"web-infra-dev/rspack","suite":"-","suiteRefType":"precoded","suiteRef":"precoded"}'
- if: steps.eco_ci.outcome == 'failure'
uses: actions/checkout@v4
- if: steps.eco_ci.outcome == 'failure'
uses: actions/setup-node@v4
with:
node-version: 20
- name: Send Failure Notification
if: steps.eco_ci.outcome == 'failure'
shell: bash
run: ./scripts/alert/lark.js
env:
TITLE: Ecosystem CI failed on main branch
DESCRIPTION: |
commitID: [${{github.sha}}](${{github.server_url}}/${{github.repository}}/commit/${{github.sha}})
URL: ${{github.server_url}}/${{github.repository}}/actions/runs/${{github.run_id}}
LARK_WEBHOOK_URL: ${{secrets.LARK_WEBHOOK_URL}}
failure_notification:
name: Failure Notification
needs:
[test-linux, test-windows, test-mac, rust_check, rust_test, run_benchmark]
if: ${{ failure() && !cancelled() && github.ref_name == 'main' && github.repository_owner == 'web-infra-dev' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- shell: bash
run: ./scripts/alert/lark.js
env:
TITLE: CI failed on main branch
DESCRIPTION: |
commitID: [${{github.sha}}](${{github.server_url}}/${{github.repository}}/commit/${{github.sha}})
URL: ${{github.server_url}}/${{github.repository}}/actions/runs/${{github.run_id}}
LARK_WEBHOOK_URL: ${{secrets.LARK_WEBHOOK_URL}}
# TODO: enable it after self hosted runners are ready
# pkg-preview:
# name: Pkg Preview
# needs:
# - test-linux
# - test-windows
# - cargo-deny
# - lint
# - rust_check
# - rust_test
# # after merged to main branch
# if: ${{ !failure() && github.event_name == 'push' }}
# uses: ./.github/workflows/preview-commit.yml