Skip to content

Commit c0956e4

Browse files
cmichiascjones
andauthored
CI: Use stable for clippy and cargo test (#1391)
* Use stable `clippy` * Use stable for `cargo test` * Update test fixtures cd crates/lang/ export TRYBUILD=overwrite cargo test --verbose --all-features --no-fail-fast * Remove unnecessary cfg feature * Update `CONTRIBUTING.md` * Update test fixtures * Update `CONTRIBUTING.md` * Update CONTRIBUTING.md Co-authored-by: Andrew Jones <[email protected]> * Update CONTRIBUTING.md Co-authored-by: Andrew Jones <[email protected]> Co-authored-by: Andrew Jones <[email protected]>
1 parent 2cf8c3d commit c0956e4

40 files changed

+255
-349
lines changed

.gitlab-ci.yml

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ variables:
3939
# `cargo-contract`, but in our CI here we also use e.g.
4040
# `cargo check` directly.
4141
RUSTC_BOOTSTRAP: "1"
42+
# TODO `cargo clippy --verbose --all-targets --all-features` for this crate
43+
# currently fails on `stable`, but succeeds on `nightly`. This is due to
44+
# this fix not yet in stable: https://github.com/rust-lang/rust-clippy/issues/8895.
45+
# Remove the following line again as soon as `clippy` on stable succeeds again.
46+
CLIPPY_ALLOWED: "clippy::extra_unused_lifetimes"
4247

4348
workflow:
4449
rules:
@@ -138,7 +143,7 @@ clippy-std:
138143
<<: *test-refs
139144
script:
140145
- for crate in ${ALL_CRATES}; do
141-
cargo +nightly clippy --verbose --all-targets --all-features --manifest-path ./crates/${crate}/Cargo.toml -- -D warnings;
146+
cargo clippy --verbose --all-targets --all-features --manifest-path ./crates/${crate}/Cargo.toml -- -D warnings -A $CLIPPY_ALLOWED;
142147
done
143148

144149
clippy-wasm:
@@ -147,7 +152,7 @@ clippy-wasm:
147152
<<: *test-refs
148153
script:
149154
- for crate in ${ALSO_WASM_CRATES}; do
150-
cargo +nightly clippy --verbose --no-default-features --manifest-path ./crates/${crate}/Cargo.toml --target wasm32-unknown-unknown -- -D warnings;
155+
cargo clippy --verbose --no-default-features --manifest-path ./crates/${crate}/Cargo.toml --target wasm32-unknown-unknown -- -D warnings -A $CLIPPY_ALLOWED;
151156
done
152157
allow_failure: true
153158

@@ -158,15 +163,15 @@ examples-clippy-std:
158163
script:
159164
- for example in examples/*/; do
160165
if [ "$example" = "examples/upgradeable-contracts/" ]; then continue; fi;
161-
cargo +nightly clippy --verbose --all-targets --manifest-path ${example}/Cargo.toml -- -D warnings;
166+
cargo clippy --verbose --all-targets --manifest-path ${example}/Cargo.toml -- -D warnings -A $CLIPPY_ALLOWED;
162167
done
163168
- for contract in ${DELEGATOR_SUBCONTRACTS}; do
164-
cargo +nightly clippy --verbose --all-targets --manifest-path ./examples/delegator/${contract}/Cargo.toml -- -D warnings;
169+
cargo clippy --verbose --all-targets --manifest-path ./examples/delegator/${contract}/Cargo.toml -- -D warnings -A $CLIPPY_ALLOWED;
165170
done
166171
- for contract in ${UPGRADEABLE_CONTRACTS}; do
167-
cargo +nightly clippy --verbose --all-targets --manifest-path ./examples/upgradeable-contracts/${contract}/Cargo.toml -- -D warnings;
172+
cargo clippy --verbose --all-targets --manifest-path ./examples/upgradeable-contracts/${contract}/Cargo.toml -- -D warnings -A $CLIPPY_ALLOWED;
168173
done
169-
- cargo +nightly clippy --verbose --all-targets --manifest-path ./examples/upgradeable-contracts/set-code-hash/updated-incrementer/Cargo.toml -- -D warnings;
174+
- cargo clippy --verbose --all-targets --manifest-path ./examples/upgradeable-contracts/set-code-hash/updated-incrementer/Cargo.toml -- -D warnings -A $CLIPPY_ALLOWED;
170175
allow_failure: true
171176

172177
examples-clippy-wasm:
@@ -176,15 +181,15 @@ examples-clippy-wasm:
176181
script:
177182
- for example in examples/*/; do
178183
if [ "$example" = "examples/upgradeable-contracts/" ]; then continue; fi;
179-
cargo +nightly clippy --verbose --manifest-path ${example}/Cargo.toml --no-default-features --target wasm32-unknown-unknown -- -D warnings;
184+
cargo clippy --verbose --manifest-path ${example}/Cargo.toml --no-default-features --target wasm32-unknown-unknown -- -D warnings -A $CLIPPY_ALLOWED;
180185
done
181186
- for contract in ${DELEGATOR_SUBCONTRACTS}; do
182-
cargo +nightly clippy --verbose --manifest-path ./examples/delegator/${contract}/Cargo.toml --no-default-features --target wasm32-unknown-unknown -- -D warnings;
187+
cargo clippy --verbose --manifest-path ./examples/delegator/${contract}/Cargo.toml --no-default-features --target wasm32-unknown-unknown -- -D warnings -A $CLIPPY_ALLOWED;
183188
done
184189
- for contract in ${UPGRADEABLE_CONTRACTS}; do
185-
cargo +nightly clippy --verbose --manifest-path ./examples/upgradeable-contracts/${contract}/Cargo.toml --no-default-features --target wasm32-unknown-unknown -- -D warnings;
190+
cargo clippy --verbose --manifest-path ./examples/upgradeable-contracts/${contract}/Cargo.toml --no-default-features --target wasm32-unknown-unknown -- -D warnings -A $CLIPPY_ALLOWED;
186191
done
187-
- cargo +nightly clippy --verbose --manifest-path ./examples/upgradeable-contracts/set-code-hash/updated-incrementer/Cargo.toml --no-default-features --target wasm32-unknown-unknown -- -D warnings;
192+
- cargo clippy --verbose --manifest-path ./examples/upgradeable-contracts/set-code-hash/updated-incrementer/Cargo.toml --no-default-features --target wasm32-unknown-unknown -- -D warnings -A $CLIPPY_ALLOWED;
188193
allow_failure: true
189194

190195

@@ -264,8 +269,8 @@ test:
264269
# at the same time, hence we use this workaround.
265270
QUICKCHECK_TESTS: 0
266271
script:
267-
- cargo +nightly test --verbose --all-features --no-fail-fast --workspace
268-
- cargo +nightly test --verbose --all-features --no-fail-fast --workspace --doc
272+
- cargo test --verbose --all-features --no-fail-fast --workspace
273+
- cargo test --verbose --all-features --no-fail-fast --workspace --doc
269274

270275
docs:
271276
stage: workspace
@@ -321,7 +326,7 @@ codecov:
321326
script:
322327
# RUSTFLAGS are the cause target cache can't be used here
323328
- cargo build --verbose --all-features --workspace
324-
- cargo +nightly test --verbose --all-features --no-fail-fast --workspace
329+
- cargo test --verbose --all-features --no-fail-fast --workspace
325330
# coverage with branches
326331
- grcov . --binary-path ./target/debug/ --source-dir . --output-type lcov --llvm --branch
327332
--ignore-not-existing --ignore "/*" --ignore "tests/*" --output-path lcov-w-branch.info

CONTRIBUTING.md

Lines changed: 26 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -36,35 +36,46 @@ contributing in the first place anyways, right?)
3636
To help you out here's a [really good post](https://cbea.ms/git-commit/) on how to write good commit
3737
messages.
3838

39+
### Stable vs Nightly Rust
40+
41+
For everything but `rustfmt` we use Rust `stable` together with `export RUSTC_BOOTSTRAP=1`.
42+
You have to export this environment variable locally too! Setting it will enable nightly
43+
features in stable Rust. So it's definitely a hack, but we decided on it since using nightly
44+
in the CI and for tooling came with a lot of maintenance burden.
45+
3946
### Checklist
4047

4148
Below is a checklist for you before doing a pull request.
4249

43-
Following these will ensure that your pull request is going to be accepted.
44-
45-
1. Run `rustfmt` automatically.
46-
1. Run `clippy` on your changes.
47-
1. Run tests via `cargo test --release` for off-chain testing.
48-
1. For critical parts perform some manual on-chain tests.
49-
1. Build the code and run tests also for the `wasm32` target.
50-
1. Try to run some examples and see if they are still working correctly.
51-
1. Sometimes clippy lints can be unfortunate or even buggy and it can be very hard to fix those.
52-
In these situations you may skip the clippy lint with `#[clippy::skip]`, however,
53-
note that this always requires a good rational as a side-comment and probably link to the eventual clippy bug.
54-
1. **Important** Strive for simple, clean and concise code.
55-
If your code is very complex - because it is trying to accomplish complex things - try to think about how another aproach or design could simplify it.
50+
1. Name your branch with a prefix and a descriptive name in the style of `peter-refactor-storage-implementation`.
5651
1. We won't accept a pull request with `FIXME` or `TODO` comments in it.
5752
Please try to fix them by yourself and resolve all remaining to-do items.
5853
If that is not possible then write an issue for each of them and link to the source line and commit with a proper description. For more information go [here](#Issues-&-pull-requests).
5954
1. Document everything properly that you have written, refactored or touched. Especially keeping documentation up-to-date is very important. For larger portions please try to also update the ink! wiki or write a new entry there.
6055
1. Write tests for your code. If your code is hard to test, try to find a design that allows for testing.
61-
1. If needed also update the [`README`](README.md).
6256
1. For performance critical parts we also want additional performance tests.
6357
1. If you implement a fix for a reported bug also include a regression test alongside the fix if possible.
6458
1. When commenting or documenting code make use of proper punctuation.
65-
This might seem pedantic but we believe that in essence this is going to improve overall comment and documentation quality.
59+
This might seem pedantic, but we believe that in essence this is going to improve overall comment and documentation quality.
6660
1. If possible try to sign your commits, e.g. using GPG keys. For more information about this go [here](https://help.github.com/en/articles/signing-commits).
6761

62+
Verify the following locally, otherwise the CI will fail:
63+
64+
1. Is `rustfmt` happy with it ?
65+
- `cargo +nightly fmt --all`
66+
1. Is `clippy` happy with it?
67+
- `cargo clippy --all-targets --all-features` -- -D warnings;
68+
1. Does the code still compile?
69+
- `cargo check --all-features`
70+
1. Do all the examples still compile?
71+
- `cargo contract check --manifest-path ./examples/.../Cargo.toml`
72+
1. Is the `wasm32` target still compiling?
73+
- `cargo check --no-default-features --target wasm32-unknown-unknown`
74+
1. Are all the tests passing?
75+
- `cargo test --all-features --workspace`
76+
1. Are all the tests for the examples passing?
77+
- `cargo test --manifest-path ./examples/.../Cargo.toml`
78+
6879
### Backwards Compatibility
6980

7081
ink! and `pallet-contracts` are projects under active development. As the Contracts API
@@ -93,29 +104,6 @@ older nodes, please do the following:
93104

94105
You can have a look at the [PR#1284](https://github.com/paritytech/ink/pull/1284/files#diff-e7cc1cdb3856da1293c785de863703d5961c324aa2018decb0166ea1eb0631e8R191) for a reference of how the described way could be implemented.
95106

96-
## Continuous Integration
97-
98-
Our [continuous integration (CI)](https://github.com/paritytech/ink/blob/master/.gitlab-ci.yml) will check for the following properties of all changes.
99-
100-
1. Is `rustfmt` happy with it ?
101-
- `cargo fmt --all`
102-
1. Is `clippy` happy with it?
103-
- `cargo clippy --all-targets --all-features`
104-
1. Does the code still compile?
105-
- `cargo check --all-features`
106-
1. Do all the examples still compile?
107-
- `cargo +nightly contract check --manifest-path ./examples/.../Cargo.toml`
108-
1. Is the `wasm-32` target still compiling?
109-
- `cargo check --no-default-features --target wasm32-unknown-unknown`
110-
1. Are all the tests passing?
111-
- `cargo test --all-features --workspace`
112-
1. Are all the tests for the examples passing?
113-
- `cargo +nightly test --manifest-path ./examples/.../Cargo.toml`
114-
1. Is the test code coverage increasing or at least stable?
115-
1. Has the size of the example contract binaries changed?
116-
117-
Only if our very demanding CI is happy with your pull request we will eventually merge it.
118-
Exceptions confirm the rule!
119107

120108
## Issues and Pull Requests
121109

crates/lang/tests/ui/contract/fail/constructor-input-non-codec.stderr

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ error[E0277]: the trait bound `NonCodecType: WrapperTypeDecode` is not satisfied
22
--> tests/ui/contract/fail/constructor-input-non-codec.rs:13:28
33
|
44
13 | pub fn constructor(_input: NonCodecType) -> Self {
5-
| ^^^^^^^^^^^^^^^^^^^^ the trait `WrapperTypeDecode` is not implemented for `NonCodecType`
5+
| ^^^^^^ the trait `WrapperTypeDecode` is not implemented for `NonCodecType`
66
|
77
= help: the following other types implement trait `WrapperTypeDecode`:
88
Arc<T>
99
Box<T>
1010
Rc<T>
11-
= note: required for `NonCodecType` to implement `parity_scale_codec::Decode`
11+
= note: required because of the requirements on the impl of `parity_scale_codec::Decode` for `NonCodecType`
1212
note: required by a bound in `DispatchInput`
1313
--> src/codegen/dispatch/type_check.rs
1414
|
@@ -18,27 +18,20 @@ note: required by a bound in `DispatchInput`
1818
error[E0277]: the trait bound `NonCodecType: WrapperTypeDecode` is not satisfied
1919
--> tests/ui/contract/fail/constructor-input-non-codec.rs:13:9
2020
|
21-
13 | / pub fn constructor(_input: NonCodecType) -> Self {
22-
14 | | Self {}
23-
15 | | }
24-
| |_________^ the trait `WrapperTypeDecode` is not implemented for `NonCodecType`
21+
13 | pub fn constructor(_input: NonCodecType) -> Self {
22+
| ^^^ the trait `WrapperTypeDecode` is not implemented for `NonCodecType`
2523
|
2624
= help: the following other types implement trait `WrapperTypeDecode`:
2725
Arc<T>
2826
Box<T>
2927
Rc<T>
30-
= note: required for `NonCodecType` to implement `parity_scale_codec::Decode`
28+
= note: required because of the requirements on the impl of `parity_scale_codec::Decode` for `NonCodecType`
3129

3230
error[E0277]: the trait bound `NonCodecType: WrapperTypeEncode` is not satisfied
33-
--> tests/ui/contract/fail/constructor-input-non-codec.rs:3:1
31+
--> tests/ui/contract/fail/constructor-input-non-codec.rs:13:9
3432
|
35-
3 | #[ink::contract]
36-
| ^^^^^^^^^^^^^^^^ the trait `WrapperTypeEncode` is not implemented for `NonCodecType`
37-
...
38-
13 | / pub fn constructor(_input: NonCodecType) -> Self {
39-
14 | | Self {}
40-
15 | | }
41-
| |_________- required by a bound introduced by this call
33+
13 | pub fn constructor(_input: NonCodecType) -> Self {
34+
| ^^^ the trait `WrapperTypeEncode` is not implemented for `NonCodecType`
4235
|
4336
= help: the following other types implement trait `WrapperTypeEncode`:
4437
&T
@@ -50,7 +43,7 @@ error[E0277]: the trait bound `NonCodecType: WrapperTypeEncode` is not satisfied
5043
String
5144
Vec<T>
5245
parity_scale_codec::Ref<'a, T, U>
53-
= note: required for `NonCodecType` to implement `Encode`
46+
= note: required because of the requirements on the impl of `Encode` for `NonCodecType`
5447
note: required by a bound in `ExecutionInput::<ArgumentList<ArgumentListEnd, ArgumentListEnd>>::push_arg`
5548
--> $WORKSPACE/crates/env/src/call/execution_input.rs
5649
|
Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
error: encountered ink! constructor with overlapping wildcard selectors
22
--> tests/ui/contract/fail/constructor-multiple-wildcard-selectors.rs:15:9
33
|
4-
15 | / pub fn constructor2() -> Self {
5-
16 | | Self {}
6-
17 | | }
7-
| |_________^
4+
15 | pub fn constructor2() -> Self {
5+
| ^^^
86

97
error: first ink! constructor with overlapping wildcard selector here
108
--> tests/ui/contract/fail/constructor-multiple-wildcard-selectors.rs:10:9
119
|
12-
10 | / pub fn constructor1() -> Self {
13-
11 | | Self {}
14-
12 | | }
15-
| |_________^
10+
10 | pub fn constructor1() -> Self {
11+
| ^^^

crates/lang/tests/ui/contract/fail/constructor-selector-and-wildcard-selector.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ error: encountered ink! attribute arguments with equal kinds
22
--> tests/ui/contract/fail/constructor-selector-and-wildcard-selector.rs:9:51
33
|
44
9 | #[ink(constructor, selector = 0xCAFEBABA, selector = _)]
5-
| ^^^^^^^^^^^^
5+
| ^^^^^^^^
66

77
error: first equal ink! attribute argument with equal kind here
88
--> tests/ui/contract/fail/constructor-selector-and-wildcard-selector.rs:9:28
99
|
1010
9 | #[ink(constructor, selector = 0xCAFEBABA, selector = _)]
11-
| ^^^^^^^^^^^^^^^^^^^^^
11+
| ^^^^^^^^
Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
1-
error[E0637]: `&` without an explicit lifetime name cannot be used here
2-
--> tests/ui/contract/fail/constructor-self-receiver-03.rs:10:34
3-
|
4-
10 | pub fn constructor(this: &Self) -> Self {
5-
| ^ explicit lifetime name needed here
6-
71
error[E0411]: cannot find type `Self` in this scope
82
--> tests/ui/contract/fail/constructor-self-receiver-03.rs:10:35
93
|
104
6 | pub struct Contract {}
11-
| ---------------------- `Self` not allowed in a constant item
5+
| --- `Self` not allowed in a constant item
126
...
137
10 | pub fn constructor(this: &Self) -> Self {
148
| ^^^^ `Self` is only available in impls, traits, and type definitions
@@ -22,16 +16,13 @@ error[E0411]: cannot find type `Self` in this scope
2216
10 | pub fn constructor(this: &Self) -> Self {
2317
| ^^^^ `Self` is only available in impls, traits, and type definitions
2418

25-
error[E0277]: the trait bound `&'static Contract: WrapperTypeDecode` is not satisfied
26-
--> tests/ui/contract/fail/constructor-self-receiver-03.rs:10:9
19+
error[E0106]: missing lifetime specifier
20+
--> tests/ui/contract/fail/constructor-self-receiver-03.rs:10:34
21+
|
22+
10 | pub fn constructor(this: &Self) -> Self {
23+
| ^ expected named lifetime parameter
2724
|
28-
10 | / pub fn constructor(this: &Self) -> Self {
29-
11 | | Self {}
30-
12 | | }
31-
| |_________^ the trait `WrapperTypeDecode` is not implemented for `&'static Contract`
25+
help: consider introducing a named lifetime parameter
3226
|
33-
= help: the following other types implement trait `WrapperTypeDecode`:
34-
Arc<T>
35-
Box<T>
36-
Rc<T>
37-
= note: required for `&'static Contract` to implement `parity_scale_codec::Decode`
27+
10 | pub<'a> fn constructor(this: &'a Self) -> Self {
28+
| ++++ ++

crates/lang/tests/ui/contract/fail/event-too-many-topics-anonymous.stderr

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,18 @@
1-
error[E0277]: the trait bound `EventTopics<4>: RespectTopicLimit<2>` is not satisfied
1+
error[E0277]: the trait bound `EventTopics<4_usize>: RespectTopicLimit<2_usize>` is not satisfied
22
--> tests/ui/contract/fail/event-too-many-topics-anonymous.rs:26:5
33
|
4-
26 | / pub struct Event {
5-
27 | | #[ink(topic)]
6-
28 | | arg_1: i8,
7-
29 | | #[ink(topic)]
8-
... |
9-
34 | | arg_4: i32,
10-
35 | | }
11-
| |_____^ the trait `RespectTopicLimit<2>` is not implemented for `EventTopics<4>`
4+
26 | pub struct Event {
5+
| ^^^ the trait `RespectTopicLimit<2_usize>` is not implemented for `EventTopics<4_usize>`
126
|
137
= help: the following other types implement trait `RespectTopicLimit<N>`:
14-
<EventTopics<0> as RespectTopicLimit<0>>
15-
<EventTopics<0> as RespectTopicLimit<10>>
16-
<EventTopics<0> as RespectTopicLimit<11>>
17-
<EventTopics<0> as RespectTopicLimit<12>>
18-
<EventTopics<0> as RespectTopicLimit<1>>
19-
<EventTopics<0> as RespectTopicLimit<2>>
20-
<EventTopics<0> as RespectTopicLimit<3>>
21-
<EventTopics<0> as RespectTopicLimit<4>>
8+
<EventTopics<0_usize> as RespectTopicLimit<0_usize>>
9+
<EventTopics<0_usize> as RespectTopicLimit<10_usize>>
10+
<EventTopics<0_usize> as RespectTopicLimit<11_usize>>
11+
<EventTopics<0_usize> as RespectTopicLimit<12_usize>>
12+
<EventTopics<0_usize> as RespectTopicLimit<1_usize>>
13+
<EventTopics<0_usize> as RespectTopicLimit<2_usize>>
14+
<EventTopics<0_usize> as RespectTopicLimit<3_usize>>
15+
<EventTopics<0_usize> as RespectTopicLimit<4_usize>>
2216
and 83 others
2317
note: required by a bound in `EventRespectsTopicLimit`
2418
--> src/codegen/event/topics.rs

0 commit comments

Comments
 (0)