-
-
Notifications
You must be signed in to change notification settings - Fork 579
232 lines (202 loc) · 6.29 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
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]
paths-ignore:
- "**/*.md"
branches-ignore:
- "release-**"
push:
branches:
- main
paths-ignore:
- "**/*.md"
tags-ignore:
- "**"
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.ref_name != 'main' }}
jobs:
get-runner-labels:
name: Get Runner Labels
uses: ./.github/workflows/get-runner-labels.yml
test-linux:
name: Test Linux
needs: [get-runner-labels]
uses: ./.github/workflows/reusable-build.yml
with:
target: x86_64-unknown-linux-gnu
profile: "debug"
runner: ${{ needs.get-runner-labels.outputs.LINUX_RUNNER_LABELS }}
test-diff: true
test-windows:
name: Test Windows
needs: [get-runner-labels]
if: github.ref_name == 'main'
uses: ./.github/workflows/reusable-build.yml
with:
target: x86_64-pc-windows-msvc
profile: "debug"
runner: ${{ needs.get-runner-labels.outputs.WINDOWS_RUNNER_LABELS }}
test-diff: true
test-mac:
name: Test Mac
needs: [get-runner-labels]
if: github.ref_name == 'main'
uses: ./.github/workflows/reusable-build.yml
with:
target: x86_64-apple-darwin
profile: "debug"
runner: ${{ needs.get-runner-labels.outputs.MACOS_RUNNER_LABELS }}
test-diff: true
cargo-deny:
name: Check license of dependencies
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install cargo-deny
uses: baptiste0928/cargo-install@v2
with:
crate: cargo-deny
version: "0.11.3"
- name: Check licenses
run: |
cargo deny check license
spell:
name: Spell check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: crate-ci/typos@master
with:
files: .
oxlint:
name: Lint JS
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dorny/paths-filter@v2
id: changes
with:
filters: |
src:
- '**/*.{ts,js,mjs}'
- name: Pnpm Cache
if: steps.changes.outputs.src == 'true'
uses: ./.github/actions/pnpm-cache
- name: oxlint
if: steps.changes.outputs.src == 'true'
run: pnpm run lint:js
rust_changes:
name: Rust Changes
runs-on: ubuntu-latest
outputs:
changed: ${{ steps.filter.outputs.changed }}
steps:
- uses: actions/checkout@v3
- uses: dorny/paths-filter@v2
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@v3
- 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@v3
- name: Install Rust Toolchain
uses: ./.github/actions/rustup
with:
clippy: true
fmt: true
shared-key: check
- 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 -- -D warnings
- name: Run rustfmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
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@v3
- 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
run: cargo test --workspace -- --nocapture
run_benchmark:
runs-on: ubuntu-latest
if: github.ref_name == 'main'
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_BOT_ACCESS_TOKEN }}
ref: 'main'
client_payload: '{"commit_sha":"${{ github.sha }}"}'
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@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- 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}}