-
Notifications
You must be signed in to change notification settings - Fork 248
456 lines (368 loc) · 14.8 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
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
name: Rust
on:
push:
# Run jobs when commits are pushed to
# master or release-like branches:
branches:
- master
pull_request:
# Run jobs for any external PR that wants
# to merge to master, too:
branches:
- master
concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
# Increase wasm test timeout from 20 seconds (default) to 1 minute.
WASM_BINDGEN_TEST_TIMEOUT: 60
jobs:
fmt:
name: Cargo fmt
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Install Rust nightly toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
components: rustfmt
- name: Rust Cache
uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3
- name: Cargo fmt
uses: actions-rs/cargo@v1.0.3
with:
command: fmt
args: --all -- --check
- if: "failure()"
uses: "andymckay/cancel-action@a955d435292c0d409d104b57d8e78435a93a6ef1" # v0.5
machete:
name: "Check unused dependencies"
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Use substrate and polkadot node binaries
uses: ./.github/workflows/actions/use-nodes
- name: Install Rust stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Rust Cache
uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3
- name: Install cargo-machete
run: cargo install cargo-machete
- name: Check unused dependencies
uses: actions-rs/cargo@v1.0.3
with:
command: machete
- if: "failure()"
uses: "andymckay/cancel-action@a955d435292c0d409d104b57d8e78435a93a6ef1" # v0.5
clippy:
name: Cargo clippy
runs-on: ubuntu-latest
needs: [fmt, machete]
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Use substrate and polkadot node binaries
uses: ./.github/workflows/actions/use-nodes
- name: Install Rust stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
components: clippy
override: true
- name: Rust Cache
uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3
- name: Run clippy
run: |
cargo clippy --all-targets --features unstable-light-client -- -D warnings
cargo clippy -p subxt-lightclient --no-default-features --features web -- -D warnings
cargo clippy -p subxt --no-default-features --features web -- -D warnings
cargo clippy -p subxt --no-default-features --features web,unstable-light-client -- -D warnings
- if: "failure()"
uses: "andymckay/cancel-action@a955d435292c0d409d104b57d8e78435a93a6ef1" # v0.5
wasm_clippy:
name: Cargo clippy (WASM)
runs-on: ubuntu-latest
needs: [fmt, machete]
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Use substrate and polkadot node binaries
uses: ./.github/workflows/actions/use-nodes
- name: Install Rust stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
target: wasm32-unknown-unknown
override: true
- name: Rust Cache
uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3
- name: Run clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: -p subxt --no-default-features --features web,unstable-light-client,jsonrpsee --target wasm32-unknown-unknown -- -D warnings
- if: "failure()"
uses: "andymckay/cancel-action@a955d435292c0d409d104b57d8e78435a93a6ef1" # v0.5
check:
name: Cargo check
runs-on: ubuntu-latest
needs: [fmt, machete]
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Use substrate and polkadot node binaries
uses: ./.github/workflows/actions/use-nodes
- name: Install Rust stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Rust Cache
uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3
- name: Install cargo-hack
uses: baptiste0928/cargo-install@v3
with:
crate: cargo-hack
version: 0.5
# A basic check over all targets together. This may lead to features being combined etc,
# and doesn't test combinations of different features.
- name: Cargo check all targets.
run: cargo check --all-targets
# Next, check subxt features.
# - `native` feature must always be enabled
# - `web` feature is always ignored.
# - This means, don't check --no-default-features and don't try enabling --all-features; both will fail
- name: Cargo hack; check each subxt feature
run: cargo hack -p subxt --each-feature check --exclude-no-default-features --exclude-all-features --exclude-features web --features native
# Subxt-signer has the "subxt" features enabled in the "check all targets" test. Run it on its own to
# check it without. We can't enable subxt or web features here, so no cargo hack.
- name: Cargo check subxt-signer
run: |
cargo check -p subxt-signer
cargo check -p subxt-signer --no-default-features --features sr25519
cargo check -p subxt-signer --no-default-features --features ecdsa
cargo check -p subxt-signer --no-default-features --features unstable-eth
# We can't enable web features here, so no cargo hack.
- name: Cargo check subxt-lightclient
run: cargo check -p subxt-lightclient
# Next, check each other package in isolation.
- name: Cargo hack; check each feature/crate on its own
run: cargo hack --exclude subxt --exclude subxt-signer --exclude subxt-lightclient --exclude-all-features --each-feature check --workspace
# Check the parachain-example code, which isn't a part of the workspace so is otherwise ignored.
- name: Cargo check parachain-example
run: cargo check --manifest-path examples/parachain-example/Cargo.toml
- if: "failure()"
uses: "andymckay/cancel-action@a955d435292c0d409d104b57d8e78435a93a6ef1" # v0.5
wasm_check:
name: Cargo check (WASM)
runs-on: ubuntu-latest
needs: [fmt, machete]
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Install Rust stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
target: wasm32-unknown-unknown
override: true
- name: Rust Cache
uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3
# Check WASM examples, which aren't a part of the workspace and so are otherwise missed:
- name: Cargo check WASM examples
run: |
cargo check --manifest-path examples/wasm-example/Cargo.toml --target wasm32-unknown-unknown
- if: "failure()"
uses: "andymckay/cancel-action@a955d435292c0d409d104b57d8e78435a93a6ef1" # v0.5
docs:
name: Check documentation and run doc tests
runs-on: ubuntu-latest
needs: [fmt, machete]
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Use substrate and polkadot node binaries
uses: ./.github/workflows/actions/use-nodes
- name: Install Rust stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Rust Cache
uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3
- name: Check internal documentation links
run: RUSTDOCFLAGS="--deny rustdoc::broken_intra_doc_links" cargo doc -vv --workspace --no-deps --document-private-items
- name: Run cargo test on documentation
uses: actions-rs/cargo@v1.0.3
with:
command: test
args: --doc --features unstable-reconnecting-rpc-client
- if: "failure()"
uses: "andymckay/cancel-action@a955d435292c0d409d104b57d8e78435a93a6ef1" # v0.5
tests:
name: "Test (Native)"
runs-on: ubuntu-latest-16-cores
needs: [clippy, wasm_clippy, check, wasm_check, docs]
timeout-minutes: 30
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Use substrate and polkadot node binaries
uses: ./.github/workflows/actions/use-nodes
- name: Install Rust stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Rust Cache
uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3
- name: Install cargo-nextest
run: cargo install cargo-nextest
- name: Run tests
uses: actions-rs/cargo@v1.0.3
with:
command: nextest
args: run --workspace --features unstable-reconnecting-rpc-client
- if: "failure()"
uses: "andymckay/cancel-action@a955d435292c0d409d104b57d8e78435a93a6ef1" # v0.5
unstable_backend_tests:
name: "Test (Unstable Backend)"
runs-on: ubuntu-latest-16-cores
needs: [clippy, wasm_clippy, check, wasm_check, docs]
timeout-minutes: 30
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Use substrate and polkadot node binaries
uses: ./.github/workflows/actions/use-nodes
- name: Install Rust stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Rust Cache
uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3
- name: Install cargo-nextest
run: cargo install cargo-nextest
- name: Run tests
uses: actions-rs/cargo@v1.0.3
with:
command: nextest
args: run --workspace --features unstable-backend-client
- if: "failure()"
uses: "andymckay/cancel-action@a955d435292c0d409d104b57d8e78435a93a6ef1" # v0.5
light_client_tests:
name: "Test (Light Client)"
runs-on: ubuntu-latest
needs: [clippy, wasm_clippy, check, wasm_check, docs]
timeout-minutes: 15
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Use substrate and polkadot node binaries
uses: ./.github/workflows/actions/use-nodes
- name: Install Rust stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Rust Cache
uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3
- name: Run tests
uses: actions-rs/cargo@v1.0.3
with:
command: test
args: --release --package integration-tests --features unstable-light-client
- if: "failure()"
uses: "andymckay/cancel-action@a955d435292c0d409d104b57d8e78435a93a6ef1" # v0.5
wasm_tests:
name: Test (WASM)
runs-on: ubuntu-latest
needs: [clippy, wasm_clippy, check, wasm_check, docs]
timeout-minutes: 30
env:
# Set timeout for wasm tests to be much bigger than the default 20 secs.
WASM_BINDGEN_TEST_TIMEOUT: 300
steps:
- uses: actions/checkout@v4
- name: Install wasm-pack
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
- name: Install firefox
uses: browser-actions/setup-firefox@latest
- name: Install chrome
uses: browser-actions/setup-chrome@latest
- name: Rust Cache
uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3
- name: Use substrate and polkadot node binaries
uses: ./.github/workflows/actions/use-nodes
- name: Run subxt WASM tests
run: |
# `listen-addr` is used to configure p2p to accept websocket connections instead of TCP.
# `node-key` provides a deterministic p2p address.
substrate-node --dev --node-key 0000000000000000000000000000000000000000000000000000000000000001 --listen-addr /ip4/0.0.0.0/tcp/30333/ws > /dev/null 2>&1 &
wasm-pack test --headless --firefox
wasm-pack test --headless --chrome
pkill substrate-node
working-directory: testing/wasm-rpc-tests
- name: Run subxt-lightclient WASM tests
run: |
# `listen-addr` is used to configure p2p to accept websocket connections instead of TCP.
# `node-key` provides a deterministic p2p address.
substrate-node --dev --node-key 0000000000000000000000000000000000000000000000000000000000000001 --listen-addr /ip4/0.0.0.0/tcp/30333/ws > /dev/null 2>&1 &
wasm-pack test --headless --firefox
wasm-pack test --headless --chrome
pkill substrate-node
working-directory: testing/wasm-lightclient-tests
- name: Run subxt-signer WASM tests
run: |
wasm-pack test --headless --firefox
wasm-pack test --headless --chrome
working-directory: signer/wasm-tests
- if: "failure()"
uses: "andymckay/cancel-action@a955d435292c0d409d104b57d8e78435a93a6ef1" # v0.5
no-std-tests:
name: "Test (no_std)"
runs-on: ubuntu-latest
needs: [machete, docs]
timeout-minutes: 30
steps:
- name: Checkout sources
uses: actions/checkout@v4
# Note: needs nighly toolchain because otherwise we cannot define custom lang-items.
- name: Install Rust nightly toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true
target: thumbv7em-none-eabi
- name: Install the gcc-arm-none-eabi linker
run: sudo apt install gcc-arm-none-eabi
- name: Rust Cache
uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3
# Note: We currently do not have a way to run real tests in a `no_std` environment.
# We can only make sure that they compile to ARM thumb ISA.
# Running the binary and inspecting the output would require an actual machine with matching ISA or some sort of emulator.
- name: Compile `no-std-tests` crate to `thumbv7em-none-eabi` target.
run: cargo build --target thumbv7em-none-eabi
working-directory: testing/no-std-tests
- if: "failure()"
uses: "andymckay/cancel-action@a955d435292c0d409d104b57d8e78435a93a6ef1" # v0.5