-
Notifications
You must be signed in to change notification settings - Fork 441
729 lines (645 loc) · 24.8 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
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
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
name: continuous-integration
on:
pull_request:
types:
- opened
- reopened
- synchronize
paths-ignore:
- '**/*.md'
- 'CODEOWNERS'
- 'LICENSE'
- 'CODE_OF_CONDUCT.adoc'
- 'FILE_HEADER'
push:
branches:
- master
- v[0-9]+.[0-9]+.* # i.e. v1.0, v2.1rc1
tags:
- v*
paths-ignore:
- '**/*.md'
- 'CODEOWNERS'
- 'LICENSE'
- 'CODE_OF_CONDUCT.adoc'
- 'FILE_HEADER'
env:
# Image can be edited at https://github.com/use-ink/docker-images
IMAGE: useink/ci
CARGO_TARGET_DIR: /ci-cache/${{ github.repository }}/targets/${{ github.ref_name }}/${{ github.job }}
CARGO_INCREMENTAL: 0
PURELY_STD_CRATES: ink/codegen metadata engine e2e e2e/macro ink/ir
ALSO_RISCV_CRATES: env storage storage/traits allocator prelude primitives ink ink/macro
# TODO `cargo clippy --all-targets --all-features` for this crate
# currently fails on `stable`, but succeeds on `nightly`. This is due to
# this fix not yet in stable: https://github.com/rust-lang/rust-clippy/issues/8895.
# Remove the following line again as soon as `clippy` on stable succeeds again.
CLIPPY_ALLOWED: clippy::extra_unused_lifetimes
# We plan to fully support RISC-V as a bytecode for contracts soon.
# RISC-V does not have a standard library in contrast to Wasm. Compiling against
# this target also makes sure that we don't pull in `std` by accident (through dependencies).
# RISC-V is a modular architecture. We might switch to a different flavor with more features
# later. For example, `riscv64imc-unknown-none-elf`.
RISCV_TARGET: .github/riscv64emac-unknown-none-polkavm.json
concurrency:
# Cancel in-progress jobs triggered only on pull_requests
group: ${{ github.head_ref || github.run_id }}
cancel-in-progress: true
### lint
jobs:
set-image:
# GitHub Actions does not allow using 'env' in a container context.
# This workaround sets the container image for each job using 'set-image' job output.
runs-on: ubuntu-latest
outputs:
IMAGE: ${{ steps.set_image.outputs.IMAGE }}
steps:
- id: set_image
run: echo "IMAGE=${{ env.IMAGE }}" >> $GITHUB_OUTPUT
spellcheck:
runs-on: ubuntu-latest
defaults:
run:
shell: bash
needs: [set-image]
container:
image: ${{ needs.set-image.outputs.IMAGE }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 100
- name: Rust Info
uses: ./.github/rust-info
- name: Check Spelling
run: |
cargo spellcheck check -v --cfg=.config/cargo_spellcheck.toml --checkers hunspell --code 1 -- recursive .
cargo spellcheck check -v --cfg=.config/cargo_spellcheck.toml --checkers hunspell --code 1 -- recursive ./integration-tests/*
fmt:
if: false
runs-on: ubuntu-latest
defaults:
run:
shell: bash
needs: [set-image]
container:
image: ${{ needs.set-image.outputs.IMAGE }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 100
- name: Rust Info
uses: ./.github/rust-info
- name: Check Formatting
run: |
zepter run check
cargo +nightly fmt --all -- --check
# For the UI tests we need to disable the license check
cargo +nightly fmt --all -- --check ./crates/ink/tests/ui/contract/{pass,fail}/*.rs
cargo +nightly fmt --all -- --check ./crates/ink/tests/ui/trait_def/{pass,fail}/*.rs
- name: Check Examples Formatting
run: |
scripts/for_all_contracts_exec.sh --path integration-tests -- cargo +nightly fmt --manifest-path {} -- --check
# This file is not a part of the cargo project, so it wouldn't be formatted the usual way
rustfmt +nightly --check ./integration-tests/public/psp22-extension/runtime/psp22-extension-example.rs
clippy:
runs-on: ubuntu-latest
defaults:
run:
shell: bash
needs: [set-image]
container:
image: ${{ needs.set-image.outputs.IMAGE }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 100
- name: Cache
uses: Swatinem/rust-cache@82a92a6e8fbeee089604da2575dc567ae9ddeaab # v2.7.5
with:
cache-directories: ${{ env.CARGO_TARGET_DIR }}
- name: Rust Info
uses: ./.github/rust-info
- name: Run Clippy
run: |
ALL_CRATES="${PURELY_STD_CRATES} ${ALSO_RISCV_CRATES}"
for crate in ${ALL_CRATES}; do
cargo clippy --all-targets --all-features --manifest-path ./crates/${crate}/Cargo.toml \
-- -D warnings -A ${CLIPPY_ALLOWED};
done
- name: Run Clippy for RISC-V Crates
run: |
for crate in ${ALSO_RISCV_CRATES}; do
cargo clippy --no-default-features --manifest-path ./crates/${crate}/Cargo.toml \
--target ${RISCV_TARGET} \
-- -D warnings -A ${CLIPPY_ALLOWED};
done
clippy-examples:
runs-on: ubuntu-latest
defaults:
run:
shell: bash
needs: [set-image]
container:
image: ${{ needs.set-image.outputs.IMAGE }}
strategy:
fail-fast: false
matrix:
type: [STD, RISCV]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 100
- name: Cache
uses: Swatinem/rust-cache@82a92a6e8fbeee089604da2575dc567ae9ddeaab # v2.7.5
with:
cache-directories: ${{ env.CARGO_TARGET_DIR }}
- name: Rust Info
uses: ./.github/rust-info
- name: Run Clippy for Examples
if: ${{ matrix.type == 'STD' }}
run: |
scripts/for_all_contracts_exec.sh --path integration-tests -- cargo clippy --all-targets \
--manifest-path {} -- -D warnings -A $CLIPPY_ALLOWED
- name: Run Clippy for RISC-V Examples
if: ${{ matrix.type == 'RISCV' }}
run: |
scripts/for_all_contracts_exec.sh --path integration-tests -- cargo clippy --no-default-features \
--target ${RISCV_TARGET} \
--manifest-path {} -- -D warnings -A $CLIPPY_ALLOWED
check:
runs-on: ubuntu-latest
defaults:
run:
shell: bash
needs: [set-image]
container:
image: ${{ needs.set-image.outputs.IMAGE }}
strategy:
fail-fast: false
matrix:
type: [STD, RISCV]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 100
- name: Cache
uses: Swatinem/rust-cache@82a92a6e8fbeee089604da2575dc567ae9ddeaab # v2.7.5
with:
cache-directories: ${{ env.CARGO_TARGET_DIR }}
- name: Rust Info
uses: ./.github/rust-info
- name: Check
if: ${{ matrix.type == 'STD' }}
run: |
ALL_CRATES="${PURELY_STD_CRATES} ${ALSO_RISCV_CRATES}"
for crate in ${ALL_CRATES}; do
cargo check --all-features --manifest-path ./crates/${crate}/Cargo.toml;
done
- name: Check RISCV
if: ${{ matrix.type == 'RISCV' }}
env:
RUSTC_BOOTSTRAP: 1
run: |
for crate in ${ALSO_RISCV_CRATES}; do
cargo check --no-default-features --target $RISCV_TARGET -Zbuild-std="core,alloc" \
--manifest-path ./crates/${crate}/Cargo.toml;
done
dylint:
runs-on: ubuntu-latest
defaults:
run:
shell: bash
needs: [set-image]
container:
image: ${{ needs.set-image.outputs.IMAGE }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 100
- name: Cache
uses: Swatinem/rust-cache@82a92a6e8fbeee089604da2575dc567ae9ddeaab # v2.7.5
with:
cache-directories: ${{ env.CARGO_TARGET_DIR }}
- name: Rust Info
uses: ./.github/rust-info
- name: Dylint
run: |
cd linting/
# we are using a toolchain file in this directory
# add required components for CI
rustup component add rustfmt clippy
rustup component add rust-src rustc-dev llvm-tools-preview
cargo check --verbose
cargo +nightly fmt --all -- --check
cargo clippy -- -D warnings;
# Needed until https://github.com/mozilla/sccache/issues/1000 is fixed.
unset RUSTC_WRAPPER
cargo test --all-features
### workspace
build:
runs-on: ubuntu-latest
needs: [set-image, check]
defaults:
run:
shell: bash
container:
image: ${{ needs.set-image.outputs.IMAGE }}
strategy:
fail-fast: false
matrix:
type: [STD, RISCV]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 100
- name: Cache
uses: Swatinem/rust-cache@82a92a6e8fbeee089604da2575dc567ae9ddeaab # v2.7.5
with:
cache-directories: ${{ env.CARGO_TARGET_DIR }}
- name: Rust Info
uses: ./.github/rust-info
- name: Build for STD
if: ${{ matrix.type == 'STD' }}
run: |
ALL_CRATES="${PURELY_STD_CRATES} ${ALSO_RISCV_CRATES}"
for crate in ${ALL_CRATES}; do
cargo build --all-features --release --manifest-path ./crates/${crate}/Cargo.toml;
done
- name: Build for RISC-V
if: ${{ matrix.type == 'RISCV' }}
run: |
for crate in ${ALSO_RISCV_CRATES}; do
cargo build --no-default-features --release
--target RISCV_TARGET \
--manifest-path ./crates/${crate}/Cargo.toml;
done
test:
runs-on: ubuntu-latest
needs: [set-image, check]
defaults:
run:
shell: bash
container:
image: ${{ needs.set-image.outputs.IMAGE }}
strategy:
fail-fast: false
matrix:
workspace: [ink, linting]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 100
- name: Cache
uses: Swatinem/rust-cache@82a92a6e8fbeee089604da2575dc567ae9ddeaab # v2.7.5
with:
cache-directories: |
${{ env.CARGO_TARGET_DIR }}
- name: Rust Info
uses: ./.github/rust-info
- name: Test
if: ${{ matrix.workspace == 'ink' }}
env:
# Fix for linking of `linkme` for `cargo test`: https://github.com/dtolnay/linkme/issues/49
RUSTFLAGS: -Clink-arg=-z -Clink-arg=nostart-stop-gc
# Since we run the tests with `--all-features` this implies the feature
# `ink-fuzz-tests` as well -- i.e. the fuzz tests are run.
# There's no way to disable a single feature while enabling all features
# at the same time, hence we use this workaround.
QUICKCHECK_TESTS: 0
run: |
cargo nextest run --all-features --no-fail-fast --workspace --locked
cargo test --all-features --no-fail-fast --workspace --doc --locked
- name: Test Linting
if: ${{ matrix.workspace == 'linting' }}
env:
# Fix for linking of `linkme` for `cargo test`: https://github.com/dtolnay/linkme/issues/49
RUSTFLAGS: -Clink-arg=-z -Clink-arg=nostart-stop-gc
# Since we run the tests with `--all-features` this implies the feature
# `ink-fuzz-tests` as well -- i.e. the fuzz tests are run.
# There's no way to disable a single feature while enabling all features
# at the same time, hence we use this workaround.
QUICKCHECK_TESTS: 0
run: |
pushd linting && cargo nextest run --all-features --no-fail-fast --workspace && popd
docs:
runs-on: ubuntu-latest
needs: [set-image, check, fmt, clippy, clippy-examples, dylint, spellcheck]
defaults:
run:
shell: bash
container:
image: ${{ needs.set-image.outputs.IMAGE }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 100
- name: Cache
uses: Swatinem/rust-cache@82a92a6e8fbeee089604da2575dc567ae9ddeaab # v2.7.5
with:
cache-directories: ${{ env.CARGO_TARGET_DIR }}
- name: Rust Info
uses: ./.github/rust-info
- name: Create docs
env:
RUSTDOCFLAGS: -Dwarnings
run: |
for package in $(cargo metadata --format-version 1 | jq -r '.workspace_members[]' | awk '{print $1}'); do
# Run cargo doc for each workspace member
cargo doc --no-deps --all-features -p ${package}
done
mv ${CARGO_TARGET_DIR}/doc ./crate-docs
# FIXME: remove me after CI image gets nonroot
chown -R nonroot:nonroot ./crate-docs
- uses: actions/upload-artifact@v4
with:
name: ${{ github.job }}-data
path: ./crate-docs
retention-days: 1
codecov:
runs-on: ubuntu-latest
needs: [set-image, check, fmt, clippy, clippy-examples, dylint, spellcheck]
defaults:
run:
shell: bash
container:
image: ${{ needs.set-image.outputs.IMAGE }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Rust Info
uses: ./.github/rust-info
- name: Codecov
env:
# For codecov it's sufficient to run the fuzz tests only once.
QUICKCHECK_TESTS: 1
INK_COVERAGE_REPORTING: true
CARGO_INCREMENTAL: 0
# Needed because `codecov` requires nightly features to work
# (see `-Z` in the `RUSTFLAGS` below).
RUSTC_BOOTSTRAP: 1
# Variables partly came from https://github.com/mozilla/grcov/blob/master/README.md
RUSTFLAGS: -Zprofile -Zmir-opt-level=0 -Ccodegen-units=1
-Clink-dead-code -Copt-level=0 -Coverflow-checks=off
# The `cargo-taurpalin` coverage reporting tool seems to have better code instrumentation and thus
# produces better results for Rust codebases in general. However, unlike `grcov` it requires
# running docker with `--security-opt seccomp=unconfined` which is why we use `grcov` instead.
CODECOV_L_TOKEN: ${{ secrets.CODECOV_L_TOKEN }}
run: |
# RUSTFLAGS are the cause target cache can't be used here
# FIXME: rust-covfix doesn't support the external target dir
# https://github.com/Kogia-sima/rust-covfix/issues/7
unset "CARGO_TARGET_DIR"
cargo clean
# make sure there's no stale coverage artifacts
find . -name "*.profraw" -type f -delete
find . -name "*.gcda" -type f -delete
# FIXME: Access from 2 users, should be solved once ci-image works from a non-root user
git config --global --add safe.directory '*'
# RUSTFLAGS are the cause target cache can't be used here
cargo build --all-features --workspace
cargo test --all-features --no-fail-fast --workspace --locked -- --skip ui_tests
# coverage with branches
grcov . --binary-path ./target/debug/ --source-dir . --output-type lcov --llvm --branch \
--ignore-not-existing --ignore "/*" --ignore "tests/*" --output-path lcov-w-branch.info
rust-covfix lcov-w-branch.info --output lcov-w-branch-fixed.info
codecov --token "$CODECOV_L_TOKEN" --file lcov-w-branch-fixed.info --nonZero
# lines coverage
grcov . --binary-path ./target/debug/ --source-dir . --output-type lcov --llvm \
--ignore-not-existing --ignore "/*" --ignore "tests/*" --output-path lcov-lines.info
rust-covfix lcov-lines.info --output lcov-lines-fixed.info
codecov --token "$CODECOV_L_TOKEN" --file lcov-lines-fixed.info --nonZero
### examples
examples-test:
runs-on: ubuntu-latest
needs: [clippy]
strategy:
matrix:
partition: [1, 2, 3, 4, 5, 6]
steps:
# We go out of storage on runners
- name: Clean runner
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf "/usr/local/share/boost"
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 100
- name: Cache
uses: Swatinem/rust-cache@82a92a6e8fbeee089604da2575dc567ae9ddeaab # v2.7.5
with:
cache-directories: ${{ env.CARGO_TARGET_DIR }}
- name: Test Examples
env:
# Fix linking of `linkme`: https://github.com/dtolnay/linkme/issues/49
RUSTFLAGS: -Clink-arg=-z -Clink-arg=nostart-stop-gc
uses: docker://useink/ci
with:
# run all tests with --all-features, which will run the e2e-tests feature if present
args: /bin/bash -c "scripts/for_all_contracts_exec.sh --path integration-tests --ignore public/static-buffer --partition ${{ matrix.partition }}/6 -- cargo test \
--all-features --manifest-path {}"
examples-custom-test:
runs-on: ubuntu-latest
needs: [set-image, clippy]
defaults:
run:
shell: bash
container:
image: ${{ needs.set-image.outputs.IMAGE }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 100
- name: Cache
uses: Swatinem/rust-cache@82a92a6e8fbeee089604da2575dc567ae9ddeaab # v2.7.5
with:
cache-directories: ${{ env.CARGO_TARGET_DIR }}
- name: Rust Info
uses: ./.github/rust-info
- name: Test static-buffer example
env:
# Fix linking of `linkme`: https://github.com/dtolnay/linkme/issues/49
RUSTFLAGS: -Clink-arg=-z -Clink-arg=nostart-stop-gc
run: |
# run the static buffer test with a custom buffer size
cargo clean --manifest-path integration-tests/public/static-buffer/Cargo.toml
INK_STATIC_BUFFER_SIZE=30 cargo test --manifest-path integration-tests/public/static-buffer/Cargo.toml --all-features
- name: Run E2E test with on-chain contract
env:
# Fix linking of `linkme`: https://github.com/dtolnay/linkme/issues/49
RUSTFLAGS: -Clink-arg=-z -Clink-arg=nostart-stop-gc
run: |
# run flipper E2E test with on-chain contract
substrate-contracts-node -lruntime::contracts=debug 2>&1 &
cargo contract build --release --manifest-path integration-tests/public/flipper/Cargo.toml
export CONTRACT_ADDR_HEX=$(cargo contract instantiate \
--manifest-path integration-tests/public/flipper/Cargo.toml \
--suri //Alice --args true -x -y --output-json | \
jq -r .contract | xargs subkey inspect | grep -o "0x.*" | head -n1)
CONTRACTS_NODE_URL=ws://127.0.0.1:9944 cargo test \
--features e2e-tests \
--manifest-path integration-tests/public/flipper/Cargo.toml \
e2e_test_deployed_contract \
-- --ignored --nocapture
examples-contract-build:
runs-on: ubuntu-latest
needs: [set-image, build]
defaults:
run:
shell: bash
container:
image: ${{ needs.set-image.outputs.IMAGE }}
strategy:
fail-fast: false
matrix:
type: [RISCV]
partition: [1, 2, 3, 4]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 100
- name: Cache
uses: Swatinem/rust-cache@82a92a6e8fbeee089604da2575dc567ae9ddeaab # v2.7.5
with:
cache-directories: ${{ env.CARGO_TARGET_DIR }}
- name: Rust Info
uses: ./.github/rust-info
- name: Build Contract RISCV Examples
if: ${{ matrix.type == 'RISCV' }}
env:
RUSTC_BOOTSTRAP: 1
run: |
rustup component add rust-src --toolchain stable
cargo contract -V
# We skip some examples for those reasons:
# This uses dlmalloc which is only supported on select targets.
# - custom_allocator
# Pulls in sp-std which needlessly requires atomic pointers (TODO: Fix sp-std and enable this example)
# - call-runtime
scripts/for_all_contracts_exec.sh --path integration-tests --ignore public/custom-allocator --ignore public/call-runtime --ignore public/contract-xcm \
-- cargo build --manifest-path {} --no-default-features --target $RISCV_TARGET -Zbuild-std="core,alloc"
examples-docs:
runs-on: ubuntu-latest
needs: [set-image, build]
defaults:
run:
shell: bash
container:
image: ${{ needs.set-image.outputs.IMAGE }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 100
- name: Cache
uses: Swatinem/rust-cache@82a92a6e8fbeee089604da2575dc567ae9ddeaab # v2.7.5
with:
cache-directories: ${{ env.CARGO_TARGET_DIR }}
- name: Rust Info
uses: ./.github/rust-info
- name: Create Examples Docs
env:
RUSTDOCFLAGS: -Dwarnings
run: |
# `--document-private-items` needs to be in here because currently our contract macro
# puts the contract functions in a private module.
# Once https://github.com/use-ink/ink/issues/336 has been implemented we can get rid
# of this flag.
scripts/for_all_contracts_exec.sh --path integration-tests -- cargo doc --manifest-path {} \
--document-private-items --no-deps
# measurements
measurements:
needs: [examples-docs, examples-contract-build, examples-test, examples-custom-test]
uses: ./.github/workflows/measurements.yml
# fuzz
fuzz:
runs-on: ubuntu-latest
needs: [set-image, examples-docs, examples-contract-build, examples-test, examples-custom-test]
if: >
github.event_name == 'push' &&
github.ref == 'refs/heads/master'
permissions:
issues: write
defaults:
run:
shell: bash
container:
image: ${{ needs.set-image.outputs.IMAGE }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 100
- name: Cache
uses: Swatinem/rust-cache@82a92a6e8fbeee089604da2575dc567ae9ddeaab # v2.7.5
with:
cache-directories: ${{ env.CARGO_TARGET_DIR }}
- name: Rust Info
uses: ./.github/rust-info
- name: Fuzz
id: fuzz_test
env:
QUICKCHECK_TESTS: 5000
run: |
# We fuzz-test only crates which possess the `ink-fuzz-tests` feature
all_tests_passed=0
ALL_CRATES="${PURELY_STD_CRATES} ${ALSO_RISCV_CRATES}"
for crate in ${ALL_CRATES}; do
if grep "ink-fuzz-tests =" ./crates/${crate}/Cargo.toml;
then
cargo test --features ink-fuzz-tests --manifest-path ./crates/${crate}/Cargo.toml --no-fail-fast -- fuzz_ || exit_code=$?;
all_tests_passed=$(( all_tests_passed | exit_code ));
fi
done
exit ${all_tests_passed}
- name: Create Issue
if: ${{ failure() && steps.fuzz_test.conclusion == 'failure' }}
uses: actions/github-script@v7
with:
script: |
const runId = context.runId;
// Get the list of jobs for the current run using GitHub API
const jobs = await github.rest.actions.listJobsForWorkflowRun({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: runId
});
// Find the job ID by name
const job = jobs.data.jobs.find(job => job.name === context.job);
if (!job) {
console.error(`Job with name '${jobName}' not found.`);
return;
}
const jobId = job.id;
const title = "[ci] Failing fuzz tests on master ('" + new Date().toLocaleDateString() + "')";
const runUrl = context.serverUrl + "/" + context.repo.owner + "/" + context.repo.repo + "/actions/runs/" + runId + "/job/" + jobId;
const commitUrl = context.serverUrl + "/" + context.repo.owner + "/" + context.repo.repo + "/commit/" + context.sha;
const message = context.payload.head_commit.message;
const body = `
The CI job [${runId}](${runUrl}) just failed.
The offending commit is [${message}](${commitUrl}).
`;
const issue = await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: title,
body: body,
assignees: [],
labels: ['P-high']
});
console.log(`Issue created: ${issue.data.html_url}`);