-
-
Notifications
You must be signed in to change notification settings - Fork 46
373 lines (318 loc) · 12 KB
/
rust.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
name: Rust
# Contains checks:
# - That the code compiles
# - That the code complies with formatting
# - Lints (using clippy) to find errors
# - That crates that are published are publish-able (works most of the time)
# - Testing
# - Standard Rust integration and unit tests
# - Fuzz tests (parser and checker)
# - WASM edition works tests
on:
push:
branches: [main]
pull_request:
branches: [main]
env:
CARGO_TERM_COLOR: always
CACHE_PATHS: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
checker/fuzz/target
parser/fuzz/target
jobs:
validity:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: actions/cache@v4
with:
path: ${{ env.CACHE_PATHS }}
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Check source is valid
run: cargo check --workspace
- name: Check binary
run: cargo check --bin ezno
formating:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Check Rust formatting with rustfmt
run: cargo fmt --all --check
- uses: brndnmtthws/rust-action-cargo-binstall@v1
with:
packages: taplo-cli
- name: Check TOML formatting with taplo
run: taplo fmt --check **/*/Cargo.toml
tests:
needs: validity
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: actions/cache@v4
with:
path: ${{ env.CACHE_PATHS }}
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- uses: dorny/paths-filter@v3
id: changes
with:
filters: |
parser:
- 'parser/**'
checker:
- 'checker/**'
- name: Run parser tests
if: steps.changes.outputs.parser == 'true' || github.ref_name == 'main'
run: |
cargo test
# TODO more
curl https://esm.sh/v128/[email protected]/es2022/react-dom.mjs > react.js
cargo run -p ezno-parser --example parse react.js
working-directory: parser
- name: Run checker specification
if: (steps.changes.outputs.checker == 'true' && github.event_name != 'pull_request') || github.ref_name == 'main'
run: cargo test -p ezno-checker-specification
- name: Run checker specification (w/ staging)
if: steps.changes.outputs.checker == 'true' && github.event_name == 'pull_request'
run: cargo test -F staging -p ezno-checker-specification
env:
EZNO_DEBUG: 1
- name: Run checker specification (just to implement)
continue-on-error: true
if: steps.changes.outputs.checker == 'true' && github.event_name == 'pull_request'
run: |
# Aim of this test is to catch anything that may have been fixed in this next commit or any bad regressions (stack overflows)
cargo test --no-default-features -F to_implement -p ezno-checker-specification
env:
EZNO_DEBUG: 1
- name: Run checker tests
if: steps.changes.outputs.checker == 'true' || github.ref_name == 'main'
run: |
# Test checker with the parser features
cargo test -F ezno-parser -p ezno-checker
- name: Run CLI and base tests
run: cargo test
extras:
runs-on: ubuntu-latest
needs: validity
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: actions/cache@v4
with:
path: ${{ env.CACHE_PATHS }}
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- uses: dorny/paths-filter@v3
id: changes
with:
filters: |
src:
- 'src/**'
parser:
- 'parser/**'
checker:
- 'checker/**'
- uses: denoland/setup-deno@v1
if: steps.changes.outputs.src == 'true' || github.ref_name == 'main'
with:
deno-version: v1.x
- uses: actions/setup-node@v4
if: steps.changes.outputs.src == 'true' || github.ref_name == 'main'
with:
node-version: 23
- name: Check parser without extras
if: steps.changes.outputs.parser == 'true'
# TODO want `continue-on-error: true` but doesn't report error
run:
cargo check -p ezno-parser --no-default-features
- name: Check parser generator
if: steps.changes.outputs.parser == 'true'
# TODO want `continue-on-error: true` but doesn't report error
run:
cargo test -p ezno-ast-generator
- name: Check checker without default features
if: steps.changes.outputs.checker == 'true'
# TODO want `continue-on-error: true` but doesn't report error
run:
cargo check -p ezno-checker --no-default-features
- name: Build and test WASM
if: steps.changes.outputs.src == 'true' || github.ref_name == 'main'
timeout-minutes: 5
run: |
# TODO `cargo check --target wasm32-unknown-unknown --lib` might be good enough
rustup target add wasm32-unknown-unknown
npm ci
npm run build
node ./dist/cli.cjs info
deno run -A ./dist/cli.mjs info
npm run run-tests
npx -p typescript tsc --strict --pretty ./build/ezno_lib.d.ts
echo "debug checked with TSC"
cargo run -p ezno-parser --example parse ./build/ezno_lib.d.ts --type-definition-module
# TODO temp as the types generated can be a bit unpredicatible
if ${{ contains(fromJSON('["main", "ast-typegen-direct"]'), github.ref_name ) }}; then
npm run build-release
npx -p typescript tsc --strict --pretty ./build/ezno_lib.d.ts
fi
working-directory: src/js-cli-and-library
shell: bash
# WIP
- uses: actions/upload-artifact@v4
if: steps.changes.outputs.src == 'true' || github.ref_name == 'main'
with:
name: wasm-build
path: src/js-cli-and-library/dist
retention-days: 3
fuzzing_parser:
if: ${{ github.ref == 'main' || !github.event.pull_request.draft || contains(github.event.pull_request.labels.*.name, 'fuzz-me') }}
needs: validity
runs-on: ubuntu-latest
timeout-minutes: 15
continue-on-error: true
strategy:
matrix:
fuzz-target: [module_roundtrip_naive, module_roundtrip_structured]
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: actions/cache@v4
with:
path: ${{ env.CACHE_PATHS }}
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- uses: dorny/paths-filter@v3
id: changes
with:
filters: |
parser:
- 'parser/**'
- name: Install latest nightly and set it as default
if: steps.changes.outputs.parser == 'true'
run: |
rustup install nightly
rustup default nightly
# Current `cargo-fuzz` is broken: https://github.com/kaleidawave/ezno/pull/158#issuecomment-2171431210
# However `cargo install --git ...` does work below
# - uses: brndnmtthws/rust-action-cargo-binstall@v1
# if: steps.changes.outputs.parser == 'true'
# with:
# packages: cargo-fuzz
- name: Install cargo-fuzz
if: steps.changes.outputs.parser == 'true'
run: cargo install --git https://github.com/rust-fuzz/cargo-fuzz.git
- name: Run fuzzing
env:
SHORT_CIRCUIT: true
if: steps.changes.outputs.parser == 'true'
run: |
if ${{ env.SHORT_CIRCUIT }}; then
CARGO_TARGET_DIR=../../target cargo fuzz run -s none ${{ matrix.fuzz-target }} -- -timeout=10 -use_value_profile=1 -max_total_time=120
else
CARGO_TARGET_DIR=../../target cargo fuzz run -s none ${{ matrix.fuzz-target }} -- -timeout=10 -use_value_profile=1 -max_total_time=300 -fork=1 -ignore_crashes=1
if test -d fuzz/artifacts; then
find fuzz/artifacts -type f -print -exec xxd {} \; -exec cargo fuzz fmt -s none module_roundtrip_structured {} \;; false;
fi
fi
working-directory: parser/fuzz
fuzzing_checker:
if: ${{ github.ref == 'main' || !github.event.pull_request.draft || contains(github.event.pull_request.labels.*.name, 'fuzz-me') }}
needs: validity
runs-on: ubuntu-latest
timeout-minutes: 15
continue-on-error: true
strategy:
matrix:
fuzz-target: [check_project_naive]
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: actions/cache@v4
with:
path: ${{ env.CACHE_PATHS }}
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- uses: dorny/paths-filter@v3
id: changes
with:
filters: |
checker:
- 'checker/**'
- name: Install latest nightly and set it as default
if: steps.changes.outputs.checker == 'true'
run: |
rustup install nightly
rustup default nightly
- name: Install cargo-fuzz
if: steps.changes.outputs.checker == 'true'
run: cargo install --git https://github.com/rust-fuzz/cargo-fuzz.git
- name: Run fuzzing
env:
SHORT_CIRCUIT: true
if: steps.changes.outputs.checker == 'true'
run: |
if ${{ env.SHORT_CIRCUIT }}; then
cargo fuzz run -s none ${{ matrix.fuzz-target }} -- -timeout=10 -use_value_profile=1 -max_total_time=120
else
cargo fuzz run -s none ${{ matrix.fuzz-target }} -- -timeout=10 -use_value_profile=1 -max_total_time=300 -fork=1 -ignore_crashes=1
# if test -d fuzz/artifacts; then
# find fuzz/artifacts -type f -print -exec xxd {} \; -exec cargo fuzz fmt -s none module_roundtrip_structured {} \;; false;
# fi
fi
ls .
ls target
working-directory: checker/fuzz
clippy:
needs: validity
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: actions/cache@v4
with:
path: ${{ env.CACHE_PATHS }}
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Lint code with clippy
run: cargo clippy
publish-ability:
# TODO only need to do for `.toml` file changes
runs-on: ubuntu-latest
# `publish --dry-run` reports too many false positives and doesn't catch actual errors. So disabling for now
if: false
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: dorny/paths-filter@v3
id: changes
with:
filters: |
manifests:
- '**/*.toml'
- name: Check that it will publish to crates.io
if: steps.changes.outputs.manifests == 'true'
run: |
cargo metadata --offline --format-version 1 --no-deps | jq -r ".workspace_members[]" | while read -r _n _v pathInfo ; do
if ! grep -q "publish = false" "${pathInfo:13:-1}/Cargo.toml"; then
cd ${pathInfo:13:-1}
cargo publish --no-verify --dry-run
fi
done
shell: bash
performance-and-size:
# WIP
runs-on: ubuntu-latest
needs: validity
steps:
- uses: actions/checkout@v4
- name: Kick off other workflow if the PR has a label
if: github.ref_name != 'main' && contains(github.event.pull_request.labels.*.name, 'compiler-performance')
run: gh workflow run performance-and-size.yml --ref "${{ github.head_ref }}"
env:
GH_TOKEN: ${{ github.token }}