-
Notifications
You must be signed in to change notification settings - Fork 6
400 lines (356 loc) · 16.3 KB
/
Copy pathrust.yml
File metadata and controls
400 lines (356 loc) · 16.3 KB
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
name: Rust
on:
push:
branches:
- main
pull_request:
workflow_dispatch:
concurrency:
group: rust-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
# Not needed in CI, should make things a bit faster
CARGO_INCREMENTAL: 0
CARGO_TERM_COLOR: always
# Build smaller artifacts to avoid running out of space in CI and make it a bit faster
RUSTFLAGS: -C strip=symbols
# Needed for things like file system access
MIRIFLAGS: -Zmiri-disable-isolation
RUST_BACKTRACE: full
jobs:
cargo-fmt:
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Configure cache
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml') }}
restore-keys: |
${{ runner.os }}-cargo-
# Cache on Windows is so slow, it is faster without it, see many reports like
# https://github.com/actions/runner-images/issues/7320
if: runner.os != 'Windows'
- name: cargo fmt
run: cargo fmt --all -- --check
cargo-clippy:
strategy:
matrix:
os:
- ubuntu-24.04
- ubuntu-24.04-arm
- macos-15
- windows-2025
type:
- together
- individually
- features
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Configure cache
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml') }}
restore-keys: |
${{ runner.os }}-cargo-
# Cache on Windows is so slow, it is faster without it, see many reports like
# https://github.com/actions/runner-images/issues/7320
if: runner.os != 'Windows'
- name: cargo clippy
run: |
cargo -Zgitoxide -Zgit clippy --locked --all-targets -- -D warnings
if: matrix.type == 'together'
- name: cargo clippy (each crate individually)
shell: bash
run: |
for crate_path in crates/{contracts/{core,example,system},execution,farmer,node,shared}/*; do
if [ ! -f "$crate_path/Cargo.toml" ]; then
continue
fi
crate="$(basename -- $crate_path)"
echo "Checking \`$crate\` individually"
cargo -Zgitoxide -Zgit clippy --all-targets --package $crate -- -D warnings
done
if: matrix.type == 'individually'
- name: cargo clippy (various features)
shell: bash
run: |
for feature in alloc parallel scale-codec serde; do
echo "Check clippy with feature: $feature"
for crate_path in crates/{execution,farmer,node,shared}/*; do
# Not all crates have this feature
if ! grep --no-messages --quiet "^$feature = \[" "$crate_path/Cargo.toml"; then
continue
fi
crate="$(basename -- $crate_path)"
echo "Checking \`$feature\` in \`$crate\`"
cargo -Zgitoxide -Zgit clippy --all-targets --package $crate --features $crate/$feature -- -D warnings
done
done
# Ensure `clippy` is happy with `guest` feature
echo "Checking \`guest\` in contracts"
for contract_path in crates/contracts/{example,system}/*; do
contract="$(basename -- $contract_path)"
echo "Checking \`guest\` in \`$contract\`"
cargo -Zgitoxide -Zgit clippy --all-targets --package $contract --features $contract/guest -- -D warnings
done
for crate_path in crates/contracts/core/*; do
# Not all crates have this feature
if ! grep --no-messages --quiet "^guest = \[" "$crate_path/Cargo.toml"; then
continue
fi
crate="$(basename -- $crate_path)"
echo "Checking \`guest\` in \`$crate\`"
cargo -Zgitoxide -Zgit clippy --all-targets --package $crate --features $crate/guest -- -D warnings
done
echo "Checking \`executor\` in \`ab-contracts-common\`"
cargo -Zgitoxide -Zgit clippy --all-targets --package ab-contracts-common --features ab-contracts-common/executor -- -D warnings
echo "Checking \`payload-builder\` in \`ab-system-contract-simple-wallet-base\`"
cargo -Zgitoxide -Zgit clippy --all-targets --package ab-system-contract-simple-wallet-base --features ab-system-contract-simple-wallet-base/payload-builder -- -D warnings
if: matrix.type == 'features'
cargo-test:
strategy:
matrix:
os:
- ubuntu-24.04
- ubuntu-24.04-arm
- macos-15
- windows-2025
miri:
- true
- false
type:
- together
- features
- guest-feature
exclude:
- os: macos-15
type: guest-feature
- os: windows-2025
type: guest-feature
runs-on: ${{ matrix.os }}
env:
command: ${{ matrix.miri == true && 'miri nextest run' || 'nextest run' }}
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Configure cache
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml') }}
restore-keys: |
${{ runner.os }}-cargo-
# Cache on Windows is so slow, it is faster without it, see many reports like
# https://github.com/actions/runner-images/issues/7320
if: runner.os != 'Windows'
- name: Install cargo-nextest
uses: taiki-e/install-action@d12e869b89167df346dd0ff65da342d1fb1202fb # 2.53.2
with:
tool: cargo-nextest
# TODO: This is a workaround for https://github.com/RustCrypto/stream-ciphers/issues/426
- name: Miri aarch64 workaround
run: |
echo "RUSTFLAGS=${{ env.RUSTFLAGS }} --cfg chacha20_force_soft" >> $GITHUB_ENV
if: matrix.miri == true && (matrix.os == 'ubuntu-24.04-arm' || matrix.os == 'macos-15')
- name: Install Vulkan runtime and enable shader testing
run: |
sudo apt-get update
sudo apt-get install --no-install-recommends --yes mesa-vulkan-drivers
echo "EXTRA_OPTIONS=--features=__force-gpu-tests" >> $GITHUB_ENV
if: matrix.miri == false && matrix.os == 'ubuntu-24.04' && matrix.type == 'together'
- name: cargo ${{ env.command }}
run: |
cargo -Zgitoxide -Zgit ${{ env.command }} --locked ${{ env.EXTRA_OPTIONS }}
if: matrix.type == 'together'
- name: cargo test (various features)
shell: bash
run: |
for feature in alloc parallel scale-codec serde; do
for crate_path in crates/{execution,farmer,node,shared}/*; do
# Not all crates have this feature
if ! grep --no-messages --quiet "^$feature = \[" "$crate_path/Cargo.toml"; then
continue
fi
crate="$(basename -- $crate_path)"
echo "Testing \`$feature\` in \`$crate\`"
cargo -Zgitoxide -Zgit ${{ env.command }} --no-tests pass --package $crate --features $crate/$feature
done
done
echo "Checking \`executor\` in \`ab-contracts-common\`"
cargo -Zgitoxide -Zgit ${{ env.command }} --package ab-contracts-common --features ab-contracts-common/executor
echo "Testing \`payload-builder\` in \`ab-system-contract-simple-wallet-base\`"
cargo -Zgitoxide -Zgit ${{ env.command }} --package ab-system-contract-simple-wallet-base --features ab-system-contract-simple-wallet-base/payload-builder
if: matrix.type == 'features'
- name: cargo ${{ env.command }} (guest feature)
shell: bash
run: |
# Ensure tests pass with `guest` feature
for contract_path in crates/contracts/{example,system}/*; do
contract="$(basename -- $contract_path)"
echo "Testing \`guest\` in \`$contract\`"
cargo -Zgitoxide -Zgit ${{ env.command }} --no-tests pass --package $contract --features $contract/guest
done
for create_path in crates/contracts/core/*; do
# Not all crates have this feature
if ! grep --no-messages --quiet "^guest = \[" "$crate_path/Cargo.toml"; then
continue
fi
crate="$(basename -- $create_path)"
echo "Testing \`guest\` in \`$crate\`"
cargo -Zgitoxide -Zgit ${{ env.command }} --no-tests pass --package $crate --features $crate/guest
done
if: matrix.type == 'guest-feature' && runner.os == 'Linux'
no-panic:
strategy:
matrix:
os:
- ubuntu-24.04
- ubuntu-24.04-arm
- macos-15
- windows-2025
type:
- default
- features
- guest-feature
exclude:
- os: macos-15
type: guest-feature
- os: windows-2025
type: guest-feature
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Configure cache
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml') }}
restore-keys: |
${{ runner.os }}-cargo-
# Cache on Windows is so slow, it is faster without it, see many reports like
# https://github.com/actions/runner-images/issues/7320
if: runner.os != 'Windows'
- name: Ensure no panics in annotated code
env:
# Increase inlining threshold to make sure the compiler can see that some functions do not panic
# Native CPU and LTO to allow compiler to apply more optimizations and prove lack of panics in more cases
RUSTFLAGS: ${{ env.RUSTFLAGS }} -Cllvm-args=--inline-threshold=5000 -C embed-bitcode -C lto -Z dylib-lto -C target-cpu=native
shell: bash
run: |
# TODO: This doesn't seem to work for now: https://users.rust-lang.org/t/compiler-optimizations-are-different-for-crate-itself-vs-dependency/130187?u=nazar-pc
# So we end up building individual crates instead, which is unfortunate
# cargo -Zgitoxide -Zgit build --release --all-targets --features no-panic
# Ensure no panics in various crates
for crate_path in crates/{contracts/{core,example,system},execution,farmer,node,shared}/*; do
# Not all crates have this feature yet
if ! grep --no-messages --quiet '^no-panic = \[' "$crate_path/Cargo.toml"; then
continue
fi
crate="$(basename -- $crate_path)"
echo "Checking \`$crate\`"
cargo -Zgitoxide -Zgit build --release --all-targets --features no-panic --package $crate
done
if: matrix.type == 'default'
- name: Ensure no panics in annotated code (various features)
env:
# Increase inlining threshold to make sure the compiler can see that some functions do not panic
# Native CPU and LTO to allow compiler to apply more optimizations and prove lack of panics in more cases
RUSTFLAGS: ${{ env.RUSTFLAGS }} -Cllvm-args=--inline-threshold=5000 -C embed-bitcode -C lto -Z dylib-lto -C target-cpu=native
shell: bash
run: |
# Ensure no panics with `alloc` feature
for crate_path in crates/{execution,farmer,node,shared}/*; do
# Not all crates have this feature yet
if ! grep --no-messages --quiet '^no-panic = \[' "$crate_path/Cargo.toml" || \
! grep --no-messages --quiet '^alloc = \[' "$crate_path/Cargo.toml"; then
continue
fi
crate="$(basename -- $crate_path)"
echo "Checking \`alloc\` in \`$crate\`"
cargo -Zgitoxide -Zgit build --release --all-targets --features no-panic --package $crate --features $crate/alloc
done
echo "Checking \`executor\` in \`ab-contracts-common\`"
cargo -Zgitoxide -Zgit build --release --all-targets --features no-panic --package ab-contracts-common --features ab-contracts-common/executor
echo "Checking \`payload-builder\` in \`ab-system-contract-simple-wallet-base\`"
cargo -Zgitoxide -Zgit build --release --all-targets --features no-panic --package ab-system-contract-simple-wallet-base --features ab-system-contract-simple-wallet-base/payload-builder
if: matrix.type == 'features'
- name: Ensure no panics in annotated code (guest feature)
run: |
# Ensure no panics with `guest` feature
for contract_path in crates/contracts/{example,system}/*; do
# Not all contracts have this feature yet
if ! grep --no-messages --quiet '^no-panic = \[' "$contract_path/Cargo.toml"; then
continue
fi
contract="$(basename -- $contract_path)"
echo "Checking \`guest\` in \`$contract\`"
cargo -Zgitoxide -Zgit build --release --all-targets --features no-panic --package $contract --features $contract/guest
done
for contract_path in crates/contracts/core/*; do
# Not all contracts have this feature yet
if ! grep --no-messages --quiet '^no-panic = \[' "$crate_path/Cargo.toml" || \
! grep --no-messages --quiet '^guest = \[' "$crate_path/Cargo.toml"; then
continue
fi
contract="$(basename -- $contract_path)"
echo "Checking \`guest\` in \`$contract\`"
cargo -Zgitoxide -Zgit build --release --all-targets --features no-panic --package $contract --features $contract/guest
done
if: matrix.type == 'guest-feature' && runner.os == 'Linux'
contracts:
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Configure cache
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Ensure contracts compile for a custom target
run: |
for contract_path in crates/contracts/{example,system}/*; do
contract="$(basename -- $contract_path)"
echo "Checking \`$contract\`"
# TODO: This uses x86-64-based target, but will have to change to riscv64e-based target eventually
cargo -Zgitoxide -Zgit rustc -Z build-std=core --crate-type cdylib --profile contract --target crates/contracts/x86_64-unknown-none-abundance.json --package $contract --features $contract/guest
done
rust-all:
# Hack for buggy GitHub Actions behavior with skipped checks: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/collaborating-on-repositories-with-code-quality-features/troubleshooting-required-status-checks#handling-skipped-but-required-checks
if: ${{ always() }}
runs-on: ubuntu-24.04
needs:
- cargo-clippy
- cargo-fmt
- cargo-test
- contracts
- no-panic
steps:
- name: Check job statuses
# Another hack is to actually check the status of the dependencies or else it'll fall through
run: |
echo "Checking statuses..."
[[ "${{ needs.cargo-clippy.result }}" == "success" ]] || exit 1
[[ "${{ needs.cargo-fmt.result }}" == "success" ]] || exit 1
[[ "${{ needs.cargo-test.result }}" == "success" ]] || exit 1
[[ "${{ needs.contracts.result }}" == "success" ]] || exit 1
[[ "${{ needs.no-panic.result }}" == "success" ]] || exit 1