-
-
Notifications
You must be signed in to change notification settings - Fork 47
231 lines (197 loc) · 6.2 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
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
# - Testing
# - Standard Rust integration and unit tests
# - Fuzz tests
# - 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/
jobs:
validity:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
- uses: actions/cache@v3
with:
path: ${{ env.CACHE_PATHS }}
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- uses: dorny/paths-filter@v2
id: changes
with:
filters: |
parser:
- 'parser/**'
checker:
- 'checker/**'
src:
- 'src/**'
- name: Check source is valid
run: cargo check --workspace
- name: Check binary
run: cargo check --bin ezno
- uses: brndnmtthws/rust-action-cargo-binstall@v1
if: steps.changes.outputs.src == 'true'
with:
packages: [email protected]
- name: Check WASM
if: steps.changes.outputs.src == 'true'
run: |
rustup target add wasm32-unknown-unknown
# Need to build to check that the JS builds
npm ci
npm run build
working-directory: src/js-cli-and-library
- name: Check parser without extras
if: steps.changes.outputs.parser == 'true'
run:
cargo check -p ezno-parser --no-default-features
- name: Check checker without default features
if: steps.changes.outputs.checker == 'true'
run:
cargo check -p ezno-checker --no-default-features
formating:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- 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: 30
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
- uses: actions/cache@v3
with:
path: ${{ env.CACHE_PATHS }}
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- uses: dorny/paths-filter@v2
id: changes
with:
filters: |
parser:
- 'parser/**'
checker:
- 'checker/**'
- name: Run parser tests
if: steps.changes.outputs.parser == 'true'
run: |
cargo test
# TODO test other big libraries
curl https://esm.sh/v128/[email protected]/es2022/react-dom.mjs > react.js
cargo run -p ezno-parser --example parse react.js > /dev/null
cargo test -p ezno-ast-generator
working-directory: parser
- name: Run checker specification
if: steps.changes.outputs.checker == 'true'
run: cargo test
working-directory: checker/specification
- name: Run checker tests
if: steps.changes.outputs.checker == 'true'
run: cargo test -F ezno-parser
working-directory: checker
- name: Run base tests
run: cargo test
- uses: brndnmtthws/rust-action-cargo-binstall@v1
with:
packages: [email protected]
- uses: denoland/setup-deno@v1
with:
deno-version: v1.x
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Build and test WASM
run: |
rustup target add wasm32-unknown-unknown
npm ci
npm run test
node ./dist/cli.cjs info
deno run -A ./dist/cli.mjs info
working-directory: src/js-cli-and-library
shell: bash
fuzzing:
needs: validity
runs-on: ubuntu-latest
timeout-minutes: 30
continue-on-error: true
strategy:
matrix:
fuzz-target: [module_roundtrip_naive, module_roundtrip_structured]
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
- uses: actions/cache@v3
with:
path: ${{ env.CACHE_PATHS }}
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- uses: dorny/paths-filter@v2
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
- uses: brndnmtthws/rust-action-cargo-binstall@v1
if: steps.changes.outputs.parser == 'true'
with:
packages: cargo-fuzz
- name: Run fuzzing
if: steps.changes.outputs.parser == 'true'
run: |
cargo fuzz run -s none ${{ matrix.fuzz-target }} -- -timeout=10 -max_total_time=120 -use_value_profile=1
working-directory: parser/fuzz
clippy:
needs: validity
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
- uses: actions/cache@v3
with:
path: ${{ env.CACHE_PATHS }}
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Lint code with clippy
run: cargo clippy
publish-ability:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
- name: Check that it will publish to crates
run: |
cargo metadata --offline --format-version 1 --no-deps | jq -r ".workspace_members[]" | while read -r _n _v pathInfo ; do
cd ${pathInfo:13:-1}
cargo publish --no-verify --dry-run
done
shell: bash