Improve features dev-ex (#1831)

Adds a config file that allows to run `zepter` without any arguments in
the workspace to address all issues.
A secondary workflow for the CI is provided as `zepter run check`. Both
the formatting and linting are now in one check for efficiancy.

The latest version also detects some more things that `featalign` was
already showing.

Error message [in the
CI](https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/jobs/3916205)
now looks like this:
```pre
...
crate 'test-parachains' (/Users/vados/Documents/work/polkadot-sdk/polkadot/parachain/test-parachains/Cargo.toml)
  feature 'std'
    must propagate to:
      parity-scale-codec
Found 55 issues (run with --fix to fix).
Error: Command 'lint propagate-feature' failed with exit code 1

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.

For more information, see:
  - https://github.com/paritytech/polkadot-sdk/issues/1831
  - https://github.com/ggwpez/zepter
```

TODO:
- [x] Check that CI fails correctly

---------

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
This commit is contained in:
Oliver Tale-Yazdi
2023-10-24 17:59:38 +02:00
committed by GitHub
parent 12130a76ac
commit 4a44356773
46 changed files with 108 additions and 23 deletions
+45
View File
@@ -0,0 +1,45 @@
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.13.2
# 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',
# Enabling this feature somehow pulls in two versions of `sp-runtime-interface` and makes it impossible to build that crate with `cargo b -p sp-runtime-interface`. We therefore disable it for now.
'--ignore-missing-propagate=sp-core/std:bandersnatch_vrfs/std',
# 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"
+3 -16
View File
@@ -21,16 +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
# FIXME
.cargo-deny-licenses:
stage: check
@@ -91,17 +81,14 @@ job-starter:
script:
- echo ok
test-rust-feature-propagation:
check-rust-feature-propagation:
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.2 -q -f zepter && zepter --version
- zepter run check
# More info can be found here: https://github.com/paritytech/polkadot/pull/5865
.check-runtime-migration:
@@ -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",
+2
View File
@@ -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",
]
@@ -55,6 +55,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",
+1
View File
@@ -57,6 +57,7 @@ std = [
"log/std",
"polkadot-runtime-common/std",
"polkadot-runtime-parachains/std",
"rand_chacha/std",
"scale-info/std",
"sp-core/std",
"sp-io/std",
+3
View File
@@ -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",
@@ -66,6 +68,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",
@@ -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",
@@ -217,6 +217,7 @@ std = [
"polkadot-core-primitives/std",
"polkadot-parachain-primitives/std",
"polkadot-runtime-common/std",
"primitive-types/std",
"rococo-runtime-constants/std",
"scale-info/std",
"sp-api/std",
@@ -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",
@@ -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",
@@ -53,6 +53,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",
@@ -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",
+1
View File
@@ -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",
+1
View File
@@ -31,6 +31,7 @@ std = [
"codec/std",
"cumulus-primitives-core/std",
"frame-support/std",
"log/std",
"pallet-xcm-benchmarks/std",
"polkadot-runtime-common/std",
"polkadot-runtime-parachains/std",
+1 -1
View File
@@ -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
@@ -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" ]
@@ -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" ]
@@ -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
View File
@@ -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",
+1
View File
@@ -29,6 +29,7 @@ wasm-api = []
std = [
"bounded-collections/std",
"environmental/std",
"log/std",
"parity-scale-codec/std",
"scale-info/std",
"serde/std",
@@ -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",
+1
View File
@@ -38,6 +38,7 @@ std = [
"frame-benchmarking?/std",
"frame-support/std",
"frame-system/std",
"log/std",
"scale-info/std",
"serde",
"sp-core/std",
+1
View File
@@ -29,6 +29,7 @@ runtime-benchmarks = [
"sp-runtime/runtime-benchmarks",
]
std = [
"environmental/std",
"frame-benchmarking/std",
"frame-support/std",
"log/std",
+1
View File
@@ -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",
@@ -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",
+1
View File
@@ -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",
+1
View File
@@ -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",
+1
View File
@@ -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",
+1
View File
@@ -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",
+1
View File
@@ -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",
+1
View File
@@ -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",
@@ -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",
@@ -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",
+1
View File
@@ -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",
+1
View File
@@ -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",
+1
View File
@@ -33,6 +33,7 @@ std = [
"codec/std",
"frame-support/std",
"frame-system/std",
"log/std",
"pallet-balances/std",
"scale-info/std",
"sp-api/std",
+1
View File
@@ -66,6 +66,7 @@ std = [
"log/std",
"scale-info/std",
"serde/std",
"serde_json/std",
"sp-api/std",
"sp-arithmetic/std",
"sp-core/std",
@@ -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 = []
@@ -42,6 +42,7 @@ std = [
"sp-mmr-primitives/std",
"sp-runtime/std",
"sp-std/std",
"strum/std",
]
# Serde support without relying on std features.
+2
View File
@@ -116,7 +116,9 @@ std = [
"thiserror",
"tiny-bip39",
"tracing",
"w3f-bls?/std",
"zeroize/alloc",
"zeroize/std",
]
# Serde support without relying on std features.
+2 -1
View File
@@ -44,8 +44,9 @@ std = [
"bytes/std",
"codec/std",
"ed25519-dalek",
"ed25519-dalek?/std",
"libsecp256k1",
"log",
"log/std",
"secp256k1",
"sp-core/std",
"sp-externalities/std",
@@ -33,6 +33,7 @@ std = [
"codec/std",
"log/std",
"mmr-lib/std",
"scale-info/std",
"serde/std",
"sp-api/std",
"sp-core/std",
@@ -25,6 +25,7 @@ substrate-wasm-builder = { path = "../../../utils/wasm-builder", optional = true
[features]
default = [ "std" ]
std = [
"bytes/std",
"sp-core/std",
"sp-io/std",
"sp-runtime-interface/std",
@@ -37,10 +37,12 @@ rand = { version = "0.8.5", features = ["small_rng"], optional = true }
default = [ "std" ]
std = [
"aes-gcm",
"aes-gcm?/std",
"codec/std",
"curve25519-dalek",
"ed25519-dalek",
"hkdf",
"hkdf?/std",
"rand",
"scale-info/std",
"sha2",
@@ -23,5 +23,5 @@ sp-std = { path = "../std", default-features = false}
[features]
default = [ "std" ]
std = [ "codec/std", "log", "sp-std/std", "wasmtime" ]
std = [ "codec/std", "log/std", "sp-std/std", "wasmtime" ]
wasmtime = [ "anyhow", "dep:wasmtime" ]
+2
View File
@@ -81,6 +81,8 @@ std = [
"sc-executor/std",
"sc-service",
"scale-info/std",
"serde/std",
"serde_json/std",
"sp-api/std",
"sp-application-crypto/std",
"sp-block-builder/std",