Skip to content

Commit 54bcb34

Browse files
Fix CI (#2486)
* ci: Run tests on stable * ci: Enable `RUSTC_BOOTSTRAP` for RISCV builds * ci: bless selector-overlap test output * ci: build contracts on stable * ci: style * ci: remove unnecessary --all arg from test command * fix: respect `CARGO_TARGET_DIR` when fetching metadata in e2e contract builds * ci: re-partition and disable cache for integration tests * ci: separate job for flaky wildcard selector test * ci: separate job for flaky debugging strategies test * ci: ignore static buffer assertion padding pending ink_allocator updates
1 parent 2508611 commit 54bcb34

File tree

8 files changed

+263
-29
lines changed

8 files changed

+263
-29
lines changed

.github/workflows/ci.yml

+82-24
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ jobs:
7373
bash --version
7474
ink-node --version; cargo contract --version; git --version
7575
echo -e '[registry]\nprotocol = \"sparse\"' > /usr/local/cargo/config.toml
76-
echo \"cargo-contract-version=$(cargo +nightly contract --version)\" >> $GITHUB_OUTPUT
76+
echo \"cargo-contract-version=$(cargo contract --version)\" >> $GITHUB_OUTPUT
7777
7878
spellcheck:
7979
runs-on: ubuntu-latest
@@ -328,11 +328,13 @@ jobs:
328328
- name: Build for RISC-V
329329
uses: ./.github/run-container-command
330330
if: ${{ matrix.type == 'RISCV' }}
331+
env:
332+
RUSTC_BOOTSTRAP: 1
331333
with:
332334
command: |
333335
for crate in ${ALSO_RISCV_CRATES}; do
334336
echo ${crate};
335-
RUSTFLAGS=\"--cfg substrate_runtime\" cargo +nightly build \
337+
RUSTFLAGS=\"--cfg substrate_runtime\" cargo build \
336338
--no-default-features --release \
337339
--target ${CLIPPY_TARGET} \
338340
--manifest-path ./crates/${crate}/Cargo.toml \
@@ -367,7 +369,7 @@ jobs:
367369
QUICKCHECK_TESTS: 0
368370
with:
369371
command: |
370-
cargo +nightly nextest run --all-features --no-fail-fast --workspace --locked
372+
cargo nextest run --all-features --no-fail-fast --workspace --locked
371373
372374
test-docs:
373375
runs-on: ubuntu-latest
@@ -386,7 +388,7 @@ jobs:
386388
uses: ./.github/init
387389
with:
388390
cache: true
389-
cache-directories: ${{ github.workspace}}/${{ env.CARGO_TARGET_DIR }}
391+
cache-directories: ${{ github.workspace }}/${{ env.CARGO_TARGET_DIR }}
390392
cache-key: ${{ matrix.type }}
391393

392394
- name: Test
@@ -403,7 +405,7 @@ jobs:
403405
QUICKCHECK_TESTS: 0
404406
with:
405407
command: |
406-
cargo +nightly test --all-features --no-fail-fast --workspace --doc --locked
408+
cargo test --all-features --no-fail-fast --workspace --doc --locked
407409
408410
test-linting:
409411
runs-on: ubuntu-latest
@@ -422,7 +424,7 @@ jobs:
422424
uses: ./.github/init
423425
with:
424426
cache: true
425-
cache-directories: ${{ github.workspace}}/${{ env.CARGO_TARGET_DIR }}
427+
cache-directories: ${{ github.workspace }}/${{ env.CARGO_TARGET_DIR }}
426428
cache-key: ${{ matrix.type }}
427429

428430
- name: Test Linting
@@ -453,7 +455,7 @@ jobs:
453455
uses: ./.github/init
454456
with:
455457
cache: true
456-
cache-directories: ${{ github.workspace}}/${{ env.CARGO_TARGET_DIR }}
458+
cache-directories: ${{ github.workspace }}/${{ env.CARGO_TARGET_DIR }}
457459

458460
- name: Create docs
459461
uses: ./.github/run-container-command
@@ -463,7 +465,7 @@ jobs:
463465
command: |
464466
for package in $(cargo metadata --format-version 1 | jq -r '.workspace_members[]' | awk '{print $1}'); do
465467
# Run cargo doc for each workspace member
466-
cargo +nightly doc --no-deps --all-features -p ${package}
468+
cargo doc --no-deps --all-features -p ${package}
467469
done
468470
mv ${CARGO_TARGET_DIR}/doc ./crate-docs
469471
# FIXME: remove me after CI image gets nonroot
@@ -523,6 +525,10 @@ jobs:
523525
examples-test:
524526
runs-on: ubuntu-latest
525527
needs: [fmt]
528+
strategy:
529+
fail-fast: false
530+
matrix:
531+
partition: [1, 2, 3, 4]
526532
steps:
527533
- name: Checkout
528534
uses: actions/checkout@v4
@@ -532,9 +538,13 @@ jobs:
532538
- name: Initialize runner
533539
uses: ./.github/init
534540
with:
535-
cache: true
536-
cache-directories: ${{ github.workspace}}/${{ env.CARGO_TARGET_DIR }}
537-
cache-on-failure: true
541+
# TODO: (@davidsemakula) Re-enable cache if we can improve its ROI,
542+
# currently it eats up more than 65% of disk space, causing this job to run out of disk space,
543+
# or require a very large number of partitions, and generally makes this job too flaky.
544+
cache: false
545+
# cache-directories: ${{ github.workspace }}/${{ env.CARGO_TARGET_DIR }}
546+
# cache-on-failure: true
547+
# cache-key: ${{ matrix.partition }}
538548

539549
- name: Test Examples
540550
uses: ./.github/run-container-command
@@ -544,8 +554,9 @@ jobs:
544554
with:
545555
# Run all tests with --all-features, which will run the `e2e-tests` feature if present.
546556
command: |
547-
scripts/for_all_contracts_exec.sh --path integration-tests --ignore internal/static-buffer --ignore internal/mapping -- \
548-
cargo +nightly test --all-features --all --manifest-path {}
557+
scripts/for_all_contracts_exec.sh --path integration-tests --ignore internal/static-buffer --ignore internal/mapping \
558+
--ignore public/debugging-strategies --ignore public/wildcard-selector --partition ${{ matrix.partition }}/4 -- \
559+
cargo test --all-features --manifest-path {}
549560
550561
examples-test-mapping:
551562
runs-on: ubuntu-latest
@@ -560,7 +571,7 @@ jobs:
560571
uses: ./.github/init
561572
with:
562573
cache: true
563-
cache-directories: ${{ github.workspace}}/${{ env.CARGO_TARGET_DIR }}
574+
cache-directories: ${{ github.workspace }}/${{ env.CARGO_TARGET_DIR }}
564575
cache-on-failure: true
565576

566577
- name: Test Mapping Example
@@ -572,7 +583,54 @@ jobs:
572583
INK_STATIC_BUFFER_SIZE: 256
573584
with:
574585
command: |
575-
cargo +nightly test --all --all-features --manifest-path integration-tests/internal/mapping/Cargo.toml
586+
cargo test --all-features --manifest-path integration-tests/internal/mapping/Cargo.toml
587+
588+
# TODO: (@davidsemakula) Add back to `examples-test` job when flakiness is fixed.
589+
examples-test-debugging-strategies:
590+
runs-on: ubuntu-latest
591+
needs: ci-image
592+
steps:
593+
- name: Checkout
594+
uses: actions/checkout@v4
595+
with:
596+
fetch-depth: 1
597+
598+
- name: Initialize runner
599+
uses: ./.github/init
600+
with:
601+
cache: true
602+
cache-directories: ${{ github.workspace }}/${{ env.CARGO_TARGET_DIR }}
603+
cache-on-failure: true
604+
605+
- name: Test Wildcard Selector Example
606+
uses: ./.github/run-container-command
607+
with:
608+
command: |
609+
cargo test --all-features --manifest-path integration-tests/public/debugging-strategies/Cargo.toml
610+
611+
612+
# TODO: (@davidsemakula) Add back to `examples-test` job when flakiness is fixed.
613+
examples-test-wildcard-selector:
614+
runs-on: ubuntu-latest
615+
needs: ci-image
616+
steps:
617+
- name: Checkout
618+
uses: actions/checkout@v4
619+
with:
620+
fetch-depth: 1
621+
622+
- name: Initialize runner
623+
uses: ./.github/init
624+
with:
625+
cache: true
626+
cache-directories: ${{ github.workspace }}/${{ env.CARGO_TARGET_DIR }}
627+
cache-on-failure: true
628+
629+
- name: Test Wildcard Selector Example
630+
uses: ./.github/run-container-command
631+
with:
632+
command: |
633+
cargo test --all-features --manifest-path integration-tests/public/wildcard-selector/Cargo.toml
576634
577635
examples-custom-test:
578636
runs-on: ubuntu-latest
@@ -587,7 +645,7 @@ jobs:
587645
uses: ./.github/init
588646
with:
589647
cache: true
590-
cache-directories: ${{ github.workspace}}/${{ env.CARGO_TARGET_DIR }}
648+
cache-directories: ${{ github.workspace }}/${{ env.CARGO_TARGET_DIR }}
591649
cache-on-failure: true
592650

593651
- name: Run E2E test with on-chain contract
@@ -601,12 +659,12 @@ jobs:
601659
command: |
602660
# run flipper E2E test with on-chain contract
603661
ink-node -lruntime::revive=debug 2>&1 &
604-
cargo +nightly contract build --release --manifest-path integration-tests/public/flipper/Cargo.toml
605-
export CONTRACT_ADDR_HEX=$(cargo +nightly contract instantiate \
662+
cargo contract build --release --manifest-path integration-tests/public/flipper/Cargo.toml
663+
export CONTRACT_ADDR_HEX=$(cargo contract instantiate \
606664
--manifest-path integration-tests/public/flipper/Cargo.toml \
607665
--suri //Alice --args true -x -y --output-json | \
608666
jq -r .contract | xargs subkey inspect | grep -o "0x.*" | head -n1)
609-
CONTRACTS_NODE_URL=ws://127.0.0.1:9944 cargo +nightly test \
667+
CONTRACTS_NODE_URL=ws://127.0.0.1:9944 cargo test \
610668
--features e2e-tests \
611669
--manifest-path integration-tests/public/flipper/Cargo.toml \
612670
e2e_test_deployed_contract \
@@ -624,7 +682,7 @@ jobs:
624682
# the readme + test comments explain why `32`, in short because the tests write
625683
# content into the buffer and want to provoke an exhaustion of the buffer.
626684
cargo clean --manifest-path integration-tests/internal/static-buffer/Cargo.toml
627-
INK_STATIC_BUFFER_SIZE=32 cargo +nightly test --manifest-path integration-tests/internal/static-buffer/Cargo.toml --all-features
685+
INK_STATIC_BUFFER_SIZE=32 cargo test --manifest-path integration-tests/internal/static-buffer/Cargo.toml --all-features
628686
629687
examples-contract-build-riscv:
630688
runs-on: ubuntu-latest
@@ -639,7 +697,7 @@ jobs:
639697
uses: ./.github/init
640698
with:
641699
cache: true
642-
cache-directories: ${{ github.workspace}}/${{ env.CARGO_TARGET_DIR }}
700+
cache-directories: ${{ github.workspace }}/${{ env.CARGO_TARGET_DIR }}
643701
cache-on-failure: true
644702

645703
- name: Extract branch name
@@ -710,7 +768,7 @@ jobs:
710768
uses: ./.github/init
711769
with:
712770
cache: true
713-
cache-directories: ${{ github.workspace}}/${{ env.CARGO_TARGET_DIR }}
771+
cache-directories: ${{ github.workspace }}/${{ env.CARGO_TARGET_DIR }}
714772

715773
- name: Create Examples Docs
716774
uses: ./.github/run-container-command
@@ -751,7 +809,7 @@ jobs:
751809
uses: ./.github/init
752810
with:
753811
cache: true
754-
cache-directories: ${{ github.workspace}}/${{ env.CARGO_TARGET_DIR }}
812+
cache-directories: ${{ github.workspace }}/${{ env.CARGO_TARGET_DIR }}
755813

756814
- name: Fuzz
757815
uses: ./.github/run-container-command
@@ -766,7 +824,7 @@ jobs:
766824
for crate in ${ALL_CRATES}; do
767825
if grep "ink-fuzz-tests =" ./crates/${crate}/Cargo.toml;
768826
then
769-
cargo +nightly test --features ink-fuzz-tests --manifest-path ./crates/${crate}/Cargo.toml --no-fail-fast -- fuzz_ || exit_code=$?;
827+
cargo test --features ink-fuzz-tests --manifest-path ./crates/${crate}/Cargo.toml --no-fail-fast -- fuzz_ || exit_code=$?;
770828
all_tests_passed=$(( all_tests_passed | exit_code ));
771829
fi
772830
done

crates/e2e/src/contract_build.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ use std::{
3232
hash_map::Entry,
3333
HashMap,
3434
},
35+
env,
3536
path::{
3637
Path,
3738
PathBuf,
@@ -61,7 +62,12 @@ struct ContractProject {
6162

6263
impl ContractProject {
6364
fn new() -> Self {
64-
let cmd = cargo_metadata::MetadataCommand::new();
65+
let mut cmd = cargo_metadata::MetadataCommand::new();
66+
if let Some(target_dir) = env::var_os("CARGO_TARGET_DIR")
67+
.filter(|target_dir| Path::new(&target_dir).is_absolute())
68+
{
69+
cmd.env("CARGO_TARGET_DIR", &target_dir);
70+
}
6571
let metadata = cmd
6672
.exec()
6773
.unwrap_or_else(|err| panic!("Error invoking `cargo metadata`: {}", err));

crates/ink/tests/ui/contract/fail/trait/trait-message-selector-overlap-1.stderr

+56
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,59 @@ error[E0119]: conflicting implementations of trait `TraitCallForwarderFor<108389
2121
43 | | fn message(&self) {}
2222
44 | | }
2323
| |_____^ conflicting implementation for `contract::_::CallBuilder`
24+
25+
error[E0283]: type annotations needed
26+
--> tests/ui/contract/fail/trait/trait-message-selector-overlap-1.rs:19:1
27+
|
28+
19 | #[ink::contract]
29+
| ^^^^^^^^^^^^^^^^
30+
| |
31+
| cannot infer type
32+
| help: use the fully qualified path to an implementation: `<Type as ImpliesReturn>::messageOutput`
33+
|
34+
= note: multiple `impl`s satisfying `_: ImpliesReturn<()>` found in the `ink` crate:
35+
- impl<Args, RetType, Abi> ImpliesReturn<RetType> for Execution<Args, RetType, Abi>;
36+
- impl<E, CallType, Args, Abi> ImpliesReturn<()> for ink::ink_env::call::CallBuilder<E, Set<CallType>, Set<ExecutionInput<Args, Abi>>, Set<()>>
37+
where E: ink::ink_env::Environment;
38+
- impl<T, E, CallType, Args, Abi> ImpliesReturn<T> for ink::ink_env::call::CallBuilder<E, Set<CallType>, Set<ExecutionInput<Args, Abi>>, Set<ReturnType<T>>>
39+
where E: ink::ink_env::Environment;
40+
- impl<T> ImpliesReturn<T> for T;
41+
= note: associated types cannot be accessed directly on a `trait`, they can only be accessed through a specific `impl`
42+
note: required by a bound in `foo1::TraitDefinition::messageOutput`
43+
--> tests/ui/contract/fail/trait/trait-message-selector-overlap-1.rs:6:9
44+
|
45+
4 | #[ink::trait_definition]
46+
| ------------------------ required by a bound in this associated type
47+
5 | pub trait TraitDefinition {
48+
6 | / #[ink(message)]
49+
7 | | fn message(&self);
50+
| |__________________________^ required by this bound in `TraitDefinition::messageOutput`
51+
= note: this error originates in the attribute macro `ink::contract` (in Nightly builds, run with -Z macro-backtrace for more info)
52+
53+
error[E0283]: type annotations needed
54+
--> tests/ui/contract/fail/trait/trait-message-selector-overlap-1.rs:19:1
55+
|
56+
19 | #[ink::contract]
57+
| ^^^^^^^^^^^^^^^^
58+
| |
59+
| cannot infer type
60+
| help: use the fully qualified path to an implementation: `<Type as ImpliesReturn>::messageOutput`
61+
|
62+
= note: multiple `impl`s satisfying `_: ImpliesReturn<()>` found in the `ink` crate:
63+
- impl<Args, RetType, Abi> ImpliesReturn<RetType> for Execution<Args, RetType, Abi>;
64+
- impl<E, CallType, Args, Abi> ImpliesReturn<()> for ink::ink_env::call::CallBuilder<E, Set<CallType>, Set<ExecutionInput<Args, Abi>>, Set<()>>
65+
where E: ink::ink_env::Environment;
66+
- impl<T, E, CallType, Args, Abi> ImpliesReturn<T> for ink::ink_env::call::CallBuilder<E, Set<CallType>, Set<ExecutionInput<Args, Abi>>, Set<ReturnType<T>>>
67+
where E: ink::ink_env::Environment;
68+
- impl<T> ImpliesReturn<T> for T;
69+
= note: associated types cannot be accessed directly on a `trait`, they can only be accessed through a specific `impl`
70+
note: required by a bound in `foo2::TraitDefinition::messageOutput`
71+
--> tests/ui/contract/fail/trait/trait-message-selector-overlap-1.rs:14:9
72+
|
73+
12 | #[ink::trait_definition]
74+
| ------------------------ required by a bound in this associated type
75+
13 | pub trait TraitDefinition {
76+
14 | / #[ink(message)]
77+
15 | | fn message(&self);
78+
| |__________________________^ required by this bound in `TraitDefinition::messageOutput`
79+
= note: this error originates in the attribute macro `ink::contract` (in Nightly builds, run with -Z macro-backtrace for more info)

crates/ink/tests/ui/contract/fail/trait/trait-message-selector-overlap-2.stderr

+56
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,59 @@ error[E0119]: conflicting implementations of trait `TraitCallForwarderFor<151820
2121
43 | | fn message(&self) {}
2222
44 | | }
2323
| |_____^ conflicting implementation for `contract::_::CallBuilder`
24+
25+
error[E0283]: type annotations needed
26+
--> tests/ui/contract/fail/trait/trait-message-selector-overlap-2.rs:19:1
27+
|
28+
19 | #[ink::contract]
29+
| ^^^^^^^^^^^^^^^^
30+
| |
31+
| cannot infer type
32+
| help: use the fully qualified path to an implementation: `<Type as ImpliesReturn>::messageOutput`
33+
|
34+
= note: multiple `impl`s satisfying `_: ImpliesReturn<()>` found in the `ink` crate:
35+
- impl<Args, RetType, Abi> ImpliesReturn<RetType> for Execution<Args, RetType, Abi>;
36+
- impl<E, CallType, Args, Abi> ImpliesReturn<()> for ink::ink_env::call::CallBuilder<E, Set<CallType>, Set<ExecutionInput<Args, Abi>>, Set<()>>
37+
where E: ink::ink_env::Environment;
38+
- impl<T, E, CallType, Args, Abi> ImpliesReturn<T> for ink::ink_env::call::CallBuilder<E, Set<CallType>, Set<ExecutionInput<Args, Abi>>, Set<ReturnType<T>>>
39+
where E: ink::ink_env::Environment;
40+
- impl<T> ImpliesReturn<T> for T;
41+
= note: associated types cannot be accessed directly on a `trait`, they can only be accessed through a specific `impl`
42+
note: required by a bound in `foo1::TraitDefinition::messageOutput`
43+
--> tests/ui/contract/fail/trait/trait-message-selector-overlap-2.rs:6:9
44+
|
45+
4 | #[ink::trait_definition(namespace = "same")]
46+
| -------------------------------------------- required by a bound in this associated type
47+
5 | pub trait TraitDefinition {
48+
6 | / #[ink(message)]
49+
7 | | fn message(&self);
50+
| |__________________________^ required by this bound in `TraitDefinition::messageOutput`
51+
= note: this error originates in the attribute macro `ink::contract` (in Nightly builds, run with -Z macro-backtrace for more info)
52+
53+
error[E0283]: type annotations needed
54+
--> tests/ui/contract/fail/trait/trait-message-selector-overlap-2.rs:19:1
55+
|
56+
19 | #[ink::contract]
57+
| ^^^^^^^^^^^^^^^^
58+
| |
59+
| cannot infer type
60+
| help: use the fully qualified path to an implementation: `<Type as ImpliesReturn>::messageOutput`
61+
|
62+
= note: multiple `impl`s satisfying `_: ImpliesReturn<()>` found in the `ink` crate:
63+
- impl<Args, RetType, Abi> ImpliesReturn<RetType> for Execution<Args, RetType, Abi>;
64+
- impl<E, CallType, Args, Abi> ImpliesReturn<()> for ink::ink_env::call::CallBuilder<E, Set<CallType>, Set<ExecutionInput<Args, Abi>>, Set<()>>
65+
where E: ink::ink_env::Environment;
66+
- impl<T, E, CallType, Args, Abi> ImpliesReturn<T> for ink::ink_env::call::CallBuilder<E, Set<CallType>, Set<ExecutionInput<Args, Abi>>, Set<ReturnType<T>>>
67+
where E: ink::ink_env::Environment;
68+
- impl<T> ImpliesReturn<T> for T;
69+
= note: associated types cannot be accessed directly on a `trait`, they can only be accessed through a specific `impl`
70+
note: required by a bound in `foo2::TraitDefinition::messageOutput`
71+
--> tests/ui/contract/fail/trait/trait-message-selector-overlap-2.rs:14:9
72+
|
73+
12 | #[ink::trait_definition(namespace = "same")]
74+
| -------------------------------------------- required by a bound in this associated type
75+
13 | pub trait TraitDefinition {
76+
14 | / #[ink(message)]
77+
15 | | fn message(&self);
78+
| |__________________________^ required by this bound in `TraitDefinition::messageOutput`
79+
= note: this error originates in the attribute macro `ink::contract` (in Nightly builds, run with -Z macro-backtrace for more info)

0 commit comments

Comments
 (0)