Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve features dev-ex #1831

Merged
merged 15 commits into from
Oct 24, 2023
43 changes: 43 additions & 0 deletions .cargo/zepter.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
version:
format: 1
# Minimum version of the binary that is expected to work. This is just for printing a nice error
# message when someone tries to use an older version.
binary: 0.12.0

# The examples in this file assume crate `A` to have a dependency on crate `B`.
workflows:
check:
- [
'lint',
# Check that `A` activates the features of `B`.
'propagate-feature',
# These are the features to check:
'--features=try-runtime,runtime-benchmarks,std',
# Do not try to add a new section into `[features]` of `A` only because `B` expose that feature. There are edge-cases where this is still needed, but we can add them manually.
'--left-side-feature-missing=ignore',
# Ignore the case that `A` it outside of the workspace. Otherwise it will report errors in external dependencies that we have no influence on.
'--left-side-outside-workspace=ignore',
# Some features imply that they activate a specific dependency as non-optional. Otherwise the default behaviour with a `?` is used.
'--feature-enables-dep=try-runtime:frame-try-runtime,runtime-benchmarks:frame-benchmarking',
# Actually modify the files and not just report the issues:
'--offline',
'--locked',
'--show-path',
'--quiet',
]
# Format the features into canonical format:
- ['format', 'features', '--offline', '--locked', '--quiet']
# Same as `check`, but with the `--fix` flag.
default:
- [ $check.0, '--fix' ]
- [ $check.1, '--fix' ]

# Will be displayed when any workflow fails:
help:
text: |
Polkadot-SDK uses the Zepter CLI to detect abnormalities in the feature configuration.
It looks like one more more checks failed; please check the console output. You can try to automatically address them by running `zepter`.
Otherwise please ask directly in the Merge Request, GitHub Discussions or on Matrix Chat, thank you.
links:
- "https://github.com/paritytech/polkadot-sdk/issues/1831"
- "https://github.com/ggwpez/zepter"
20 changes: 3 additions & 17 deletions .gitlab/pipeline/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,6 @@ check-try-runtime:
# experimental code may rely on try-runtime and vice-versa
- time cargo check --locked --all --features try-runtime,experimental

cargo-fmt-manifest:
stage: check
extends:
- .docker-env
- .common-refs
script:
- cargo install zepter --locked --version 0.11.0 -q -f --no-default-features && zepter --version
- echo "👉 Hello developer! If you see this CI check failing then it means that one of the your changes in a Cargo.toml file introduced ill-formatted or unsorted features. Please take a look at 'docs/STYLE_GUIDE.md#manifest-formatting' to find out more."
- zepter format features --check
allow_failure: true # Experimental

# FIXME
.cargo-deny-licenses:
stage: check
Expand Down Expand Up @@ -92,17 +81,14 @@ job-starter:
script:
- echo ok

test-rust-feature-propagation:
test-rust-features-zepter:
stage: check
extends:
- .kubernetes-env
- .test-pr-refs
script:
- cargo install --locked --version 0.11.1 -q -f zepter && zepter --version
- echo "👉 Hello developer! If you see this CI check failing then it means that one of the crates is missing a feature for one of its dependencies. The output below tells you which feature needs to be added for which dependency to which crate. You can do this by modifying the Cargo.toml file. For more context see the MR where this check was introduced https://github.com/paritytech/substrate/pull/14660"
- zepter lint propagate-feature --feature try-runtime --left-side-feature-missing=ignore --workspace --feature-enables-dep="try-runtime:frame-try-runtime" --locked
- zepter lint propagate-feature --feature runtime-benchmarks --left-side-feature-missing=ignore --workspace --feature-enables-dep="runtime-benchmarks:frame-benchmarking" --locked
- zepter lint propagate-feature --feature std --left-side-feature-missing=ignore --workspace --locked
- cargo install --locked --version 0.13.0 -q -f zepter && zepter --version
- zepter run check

# More info can be found here: https://github.com/paritytech/polkadot/pull/5865
.check-runtime-migration:
Expand Down
1 change: 1 addition & 0 deletions bridges/primitives/chain-polkadot-bulletin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ std = [
"codec/std",
"frame-support/std",
"frame-system/std",
"scale-info/std",
"sp-api/std",
"sp-runtime/std",
"sp-std/std",
Expand Down
2 changes: 2 additions & 0 deletions bridges/primitives/relayers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ default = [ "std" ]
std = [
"bp-messages/std",
"bp-runtime/std",
"codec/std",
"frame-support/std",
"scale-info/std",
"sp-runtime/std",
"sp-std/std",
]
1 change: 1 addition & 0 deletions cumulus/pallets/parachain-system/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ cumulus-test-relay-sproof-builder = { path = "../../test/relay-sproof-builder" }
[features]
default = [ "std" ]
std = [
"bytes/std",
"codec/std",
"cumulus-pallet-parachain-system-proc-macro/std",
"cumulus-primitives-core/std",
Expand Down
1 change: 1 addition & 0 deletions cumulus/pallets/xcmp-queue/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ std = [
"frame-system/std",
"log/std",
"polkadot-runtime-common/std",
"rand_chacha/std",
"scale-info/std",
"sp-io/std",
"sp-runtime/std",
Expand Down
3 changes: 3 additions & 0 deletions cumulus/parachains/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,13 @@ substrate-wasm-builder = { path = "../../../substrate/utils/wasm-builder" }
[features]
default = [ "std" ]
std = [
"codec/std",
"cumulus-primitives-core/std",
"cumulus-primitives-utility/std",
"frame-support/std",
"frame-system/std",
"log/std",
"num-traits/std",
"pallet-asset-tx-payment/std",
"pallet-assets/std",
"pallet-authorship/std",
Expand All @@ -65,6 +67,7 @@ std = [
"polkadot-core-primitives/std",
"polkadot-primitives/std",
"rococo-runtime-constants/std",
"scale-info/std",
"sp-consensus-aura/std",
"sp-core/std",
"sp-io/std",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ std = [
"polkadot-core-primitives/std",
"polkadot-parachain-primitives/std",
"polkadot-runtime-common/std",
"primitive-types/std",
"scale-info/std",
"sp-api/std",
"sp-block-builder/std",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ std = [
"polkadot-core-primitives/std",
"polkadot-parachain-primitives/std",
"polkadot-runtime-common/std",
"primitive-types/std",
"scale-info/std",
"sp-api/std",
"sp-block-builder/std",
Expand Down
1 change: 1 addition & 0 deletions cumulus/parachains/runtimes/assets/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ std = [
"pallet-asset-tx-payment/std",
"pallet-xcm/std",
"parachains-common/std",
"scale-info/std",
"sp-api/std",
"sp-runtime/std",
"sp-std/std",
Expand Down
1 change: 1 addition & 0 deletions cumulus/parachains/runtimes/assets/test-utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ substrate-wasm-builder = { path = "../../../../../substrate/utils/wasm-builder"
default = [ "std" ]
std = [
"assets-common/std",
"codec/std",
"cumulus-pallet-dmp-queue/std",
"cumulus-pallet-parachain-system/std",
"cumulus-pallet-xcmp-queue/std",
Expand Down
1 change: 1 addition & 0 deletions cumulus/parachains/runtimes/test-utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ substrate-wasm-builder = { path = "../../../../substrate/utils/wasm-builder" }
default = [ "std" ]
std = [
"assets-common/std",
"codec/std",
"cumulus-pallet-dmp-queue/std",
"cumulus-pallet-parachain-system/std",
"cumulus-pallet-xcmp-queue/std",
Expand Down
1 change: 1 addition & 0 deletions cumulus/primitives/timestamp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ cumulus-primitives-core = { path = "../core", default-features = false }
[features]
default = [ "std" ]
std = [
"codec/std",
"cumulus-primitives-core/std",
"sp-inherents/std",
"sp-std/std",
Expand Down
1 change: 1 addition & 0 deletions cumulus/primitives/utility/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ std = [
"codec/std",
"cumulus-primitives-core/std",
"frame-support/std",
"log/std",
"polkadot-runtime-common/std",
"sp-io/std",
"sp-runtime/std",
Expand Down
2 changes: 1 addition & 1 deletion docs/STYLE_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ let mut target_path =

> **TLDR**
> You can use the CLI tool [Zepter](https://crates.io/crates/zepter) to
> format the files: `zepter format features`
> format the files: `zepter format features --fix` (or `zepter f f -f`).

Rust `Cargo.toml` files need to respect certain formatting rules. All entries
need to be alphabetically sorted. This makes it easier to read them and insert
Expand Down
2 changes: 1 addition & 1 deletion polkadot/parachain/test-parachains/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ sp-core = { path = "../../../substrate/primitives/core" }

[features]
default = [ "std" ]
std = [ "adder/std", "halt/std" ]
std = [ "adder/std", "halt/std", "parity-scale-codec/std" ]
2 changes: 1 addition & 1 deletion polkadot/parachain/test-parachains/adder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ substrate-wasm-builder = { path = "../../../../substrate/utils/wasm-builder" }

[features]
default = [ "std" ]
std = [ "parachain/std", "sp-io/std", "sp-std/std" ]
std = [ "parachain/std", "parity-scale-codec/std", "sp-io/std", "sp-std/std" ]
8 changes: 7 additions & 1 deletion polkadot/parachain/test-parachains/undying/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,10 @@ substrate-wasm-builder = { path = "../../../../substrate/utils/wasm-builder" }

[features]
default = [ "std" ]
std = [ "parachain/std", "sp-io/std", "sp-std/std" ]
std = [
"log/std",
"parachain/std",
"parity-scale-codec/std",
"sp-io/std",
"sp-std/std",
]
2 changes: 2 additions & 0 deletions polkadot/runtime/parachains/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ std = [
"polkadot-parachain-primitives/std",
"polkadot-runtime-metrics/std",
"primitives/std",
"rand/std",
"rand_chacha/std",
"rustc-hex/std",
"scale-info/std",
"serde/std",
Expand Down
1 change: 1 addition & 0 deletions polkadot/xcm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ wasm-api = []
std = [
"bounded-collections/std",
"environmental/std",
"log/std",
"parity-scale-codec/std",
"scale-info/std",
"serde/std",
Expand Down
2 changes: 2 additions & 0 deletions polkadot/xcm/pallet-xcm-benchmarks/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ std = [
"frame-benchmarking/std",
"frame-support/std",
"frame-system/std",
"log/std",
"scale-info/std",
"sp-io/std",
"sp-runtime/std",
"sp-std/std",
Expand Down
1 change: 1 addition & 0 deletions polkadot/xcm/pallet-xcm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ std = [
"frame-benchmarking?/std",
"frame-support/std",
"frame-system/std",
"log/std",
"scale-info/std",
"serde",
"sp-core/std",
Expand Down
1 change: 1 addition & 0 deletions polkadot/xcm/xcm-executor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ runtime-benchmarks = [
"sp-runtime/runtime-benchmarks",
]
std = [
"environmental/std",
"frame-benchmarking/std",
"frame-support/std",
"log/std",
Expand Down
1 change: 1 addition & 0 deletions substrate/bin/node/runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ std = [
"pallet-utility/std",
"pallet-vesting/std",
"pallet-whitelist/std",
"primitive-types/std",
"scale-info/std",
"sp-api/std",
"sp-authority-discovery/std",
Expand Down
1 change: 1 addition & 0 deletions substrate/frame/asset-conversion/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ std = [
"frame-system/std",
"pallet-assets/std",
"pallet-balances/std",
"primitive-types/std",
"scale-info/std",
"sp-api/std",
"sp-arithmetic/std",
Expand Down
1 change: 1 addition & 0 deletions substrate/frame/democracy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ std = [
"frame-benchmarking?/std",
"frame-support/std",
"frame-system/std",
"log/std",
"pallet-balances/std",
"pallet-preimage/std",
"pallet-scheduler/std",
Expand Down
1 change: 1 addition & 0 deletions substrate/frame/glutton/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ std = [
"frame-benchmarking?/std",
"frame-support/std",
"frame-system/std",
"log/std",
"pallet-balances/std",
"scale-info/std",
"sp-core/std",
Expand Down
1 change: 1 addition & 0 deletions substrate/frame/identity/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ sp-core = { path = "../../primitives/core" }
default = [ "std" ]
std = [
"codec/std",
"enumflags2/std",
"frame-benchmarking?/std",
"frame-support/std",
"frame-system/std",
Expand Down
1 change: 1 addition & 0 deletions substrate/frame/message-queue/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ std = [
"frame-benchmarking?/std",
"frame-support/std",
"frame-system/std",
"log/std",
"scale-info/std",
"sp-arithmetic/std",
"sp-core/std",
Expand Down
1 change: 1 addition & 0 deletions substrate/frame/multisig/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ std = [
"frame-benchmarking?/std",
"frame-support/std",
"frame-system/std",
"log/std",
"pallet-balances/std",
"scale-info/std",
"sp-io/std",
Expand Down
1 change: 1 addition & 0 deletions substrate/frame/nfts/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ sp-keystore = { path = "../../primitives/keystore" }
default = [ "std" ]
std = [
"codec/std",
"enumflags2/std",
"frame-benchmarking?/std",
"frame-support/std",
"frame-system/std",
Expand Down
2 changes: 2 additions & 0 deletions substrate/frame/nomination-pools/benchmarking/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ sp-io = { path = "../../../primitives/io" }
default = [ "std" ]

std = [
"codec/std",
"frame-benchmarking/std",
"frame-election-provider-support/std",
"frame-support/std",
Expand All @@ -52,6 +53,7 @@ std = [
"pallet-nomination-pools/std",
"pallet-staking/std",
"pallet-timestamp/std",
"scale-info/std",
"sp-core/std",
"sp-io/std",
"sp-runtime-interface/std",
Expand Down
1 change: 1 addition & 0 deletions substrate/frame/referenda/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ std = [
"frame-benchmarking?/std",
"frame-support/std",
"frame-system/std",
"log/std",
"pallet-balances/std",
"pallet-preimage/std",
"pallet-scheduler/std",
Expand Down
1 change: 1 addition & 0 deletions substrate/frame/society/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ std = [
"frame-support-test/std",
"frame-support/std",
"frame-system/std",
"log/std",
"pallet-balances/std",
"rand_chacha/std",
"scale-info/std",
Expand Down
1 change: 1 addition & 0 deletions substrate/frame/statement/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ std = [
"codec/std",
"frame-support/std",
"frame-system/std",
"log/std",
"pallet-balances/std",
"scale-info/std",
"sp-api/std",
Expand Down
1 change: 1 addition & 0 deletions substrate/frame/support/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ std = [
"log/std",
"scale-info/std",
"serde/std",
"serde_json/std",
"sp-api/std",
"sp-arithmetic/std",
"sp-core/std",
Expand Down
2 changes: 1 addition & 1 deletion substrate/primitives/api/proc-macro/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ assert_matches = "1.3.0"
[features]
# Required for the doc tests
default = [ "std" ]
std = []
std = [ "blake2/std" ]
no-metadata-docs = []
frame-metadata = []
1 change: 1 addition & 0 deletions substrate/primitives/consensus/beefy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ std = [
"sp-mmr-primitives/std",
"sp-runtime/std",
"sp-std/std",
"strum/std",
]

# Serde support without relying on std features.
Expand Down
Loading
Loading