Skip to content
Snippets Groups Projects
Unverified Commit 4a443567 authored by Oliver Tale-Yazdi's avatar Oliver Tale-Yazdi Committed by GitHub
Browse files

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: default avatarOliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
parent 12130a76
No related merge requests found
Pipeline #404606 canceled with stages
in 45 minutes and 13 seconds
Showing
with 76 additions and 20 deletions
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"
......@@ -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",
......
......@@ -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",
......
......@@ -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",
......
......@@ -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",
......
......@@ -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",
......
......@@ -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",
......
......@@ -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",
]
......@@ -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",
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment