Skip to content

Commit

Permalink
Check Rust feature configs (#964)
Browse files Browse the repository at this point in the history
* Add Zepter config

Signed-off-by: Oliver Tale-Yazdi <[email protected]>

* Update Makefile

Signed-off-by: Oliver Tale-Yazdi <[email protected]>

* CI check features

Signed-off-by: Oliver Tale-Yazdi <[email protected]>

* Fix all crate features

Signed-off-by: Oliver Tale-Yazdi <[email protected]>

* Use latest version

Signed-off-by: Oliver Tale-Yazdi <[email protected]>

* Add MR number

Signed-off-by: Oliver Tale-Yazdi <[email protected]>

* Install tool before using it

Signed-off-by: Oliver Tale-Yazdi <[email protected]>

* Different makefile targets

Signed-off-by: Oliver Tale-Yazdi <[email protected]>

* Run Zepter before cargo test

Signed-off-by: Oliver Tale-Yazdi <[email protected]>

---------

Signed-off-by: Oliver Tale-Yazdi <[email protected]>
  • Loading branch information
ggwpez authored Nov 12, 2023
1 parent 0abce5c commit b45942e
Show file tree
Hide file tree
Showing 24 changed files with 258 additions and 84 deletions.
49 changes: 49 additions & 0 deletions .config/zepter.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Configuration for the Zepter CLI to ensure correct feature configuration in the Rust workspace.
# <https://crates.io/crates/zepter>

version:
# File format for parsing it:
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 that everything is good without modifying anything:
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',
# Show the paths of failed crates to have them clickable in the terminal: 
'--show-path',
# Aux
'--offline',
'--locked',
'--quiet',
]
# Format the features into canonical format:
- ['format', 'features', '--offline', '--locked', '--quiet']
# Same as `check`, but actually fix the issues instead of just reporting them:
default:
- [ $check.0, '--fix' ]
- [ $check.1, '--fix' ]

# Will be displayed when any workflow fails:
help:
text: |
ORML uses the Zepter CLI to detect abnormalities in the feature configuration.
It looks like at least one check failed; please see 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/open-web3-stack/open-runtime-module-library/pull/964"
- "https://github.com/ggwpez/zepter"
4 changes: 4 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,9 @@ jobs:
run: cargo clippy -- -D warnings
- name: Check for Wasm
run: make dev-check
- name: Install Zepter
run: cargo install zepter --version 0.14.0 --locked -q -f --no-default-features && zepter --version
- name: Check Rust features
run: make dev-features-check
- name: Run tests
run: make dev-test
16 changes: 16 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,22 @@ dev-check-tests: Cargo.toml
dev-test: Cargo.toml
cargo test --all --features=runtime-benchmarks

# Check feature formatting and propagation.
dev-features-check:
zepter run check

# Try to automatically fix all features.
dev-features-fix:
zepter run default

# Check whether all features are formatted.
dev-features-format-check:
zepter format features

# Formats all features in all manifest files of the workspace.
dev-features-format:
zepter format features --fix

# run benchmarks via Acala node
benchmark-all:
cargo run --release --bin=acala --features=runtime-benchmarks -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=orml_auction --extrinsic="*" --wasm-execution=compiled --heap-pages=4096 --output=./auction/src/weights.rs --template ../templates/orml-weight-template.hbs
Expand Down
46 changes: 40 additions & 6 deletions asset-registry/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,34 +57,68 @@ orml-xcm-support = { path = "../xcm-support", default-features = false }
orml-xtokens = { path = "../xtokens" }

[features]
default = ["std"]
default = [ "std" ]
std = [
"serde",

"parity-scale-codec/std",
"cumulus-pallet-dmp-queue/std",
"cumulus-pallet-parachain-system/std",
"cumulus-pallet-xcm/std",
"cumulus-pallet-xcmp-queue/std",
"cumulus-primitives-core/std",
"frame-support/std",
"frame-system/std",
"log/std",
"orml-traits/std",
"orml-xcm-support/std",
"pallet-balances/std",
"pallet-message-queue/std",
"pallet-xcm/std",
"parachain-info/std",
"parity-scale-codec/std",
"polkadot-parachain-primitives/std",
"polkadot-runtime-common/std",
"polkadot-runtime-parachains/std",
"scale-info/std",
"serde",
"sp-core/std",
"sp-io/std",
"sp-runtime/std",
"sp-std/std",
"xcm-builder/std",
"xcm-executor/std",
"xcm/std",
]
runtime-benchmarks = [
"cumulus-pallet-parachain-system/runtime-benchmarks",
"cumulus-pallet-xcmp-queue/runtime-benchmarks",
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"orml-tokens/runtime-benchmarks",
"orml-xtokens/runtime-benchmarks",
"pallet-balances/runtime-benchmarks",
"pallet-message-queue/runtime-benchmarks",
"pallet-xcm/runtime-benchmarks",
"polkadot-parachain-primitives/runtime-benchmarks",
"polkadot-runtime-common/runtime-benchmarks",
"polkadot-runtime-parachains/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
"xcm-builder/runtime-benchmarks",
"xcm-executor/runtime-benchmarks",
"polkadot-runtime-parachains/runtime-benchmarks",
"polkadot-runtime-common/runtime-benchmarks",
]
try-runtime = [
"cumulus-pallet-dmp-queue/try-runtime",
"cumulus-pallet-parachain-system/try-runtime",
"cumulus-pallet-xcm/try-runtime",
"cumulus-pallet-xcmp-queue/try-runtime",
"frame-support/try-runtime",
"frame-system/try-runtime",
"orml-tokens/try-runtime",
"orml-xcm/try-runtime",
"orml-xtokens/try-runtime",
"pallet-balances/try-runtime",
"pallet-message-queue/try-runtime",
"pallet-xcm/try-runtime",
"parachain-info/try-runtime",
"polkadot-runtime-common/try-runtime",
"polkadot-runtime-parachains/try-runtime",
"sp-runtime/try-runtime",
]
10 changes: 6 additions & 4 deletions auction/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,21 @@ sp-core = { workspace = true, features = ["std"] }
sp-io = { workspace = true, features = ["std"] }

[features]
default = ["std"]
default = [ "std" ]
std = [
"serde",

"parity-scale-codec/std",
"frame-support/std",
"frame-system/std",
"orml-traits/std",
"parity-scale-codec/std",
"scale-info/std",
"serde",
"sp-core/std",
"sp-io/std",
"sp-runtime/std",
"sp-std/std",
]
try-runtime = [
"frame-support/try-runtime",
"frame-system/try-runtime",
"sp-runtime/try-runtime",
]
16 changes: 12 additions & 4 deletions authority/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,16 @@ pallet-root-testing = { workspace = true, features = ["std"] }
sp-io = { workspace = true, features = ["std"] }

[features]
default = ["std"]
default = [ "std" ]
std = [
"serde",

"parity-scale-codec/std",
"frame-support/std",
"frame-system/std",
"pallet-preimage/std",
"pallet-root-testing/std",
"pallet-scheduler/std",
"parity-scale-codec/std",
"scale-info/std",
"serde",
"sp-core/std",
"sp-io/std",
"sp-runtime/std",
Expand All @@ -42,9 +44,15 @@ std = [
runtime-benchmarks = [
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"pallet-preimage/runtime-benchmarks",
"pallet-scheduler/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
]
try-runtime = [
"frame-support/try-runtime",
"frame-system/try-runtime",
"pallet-preimage/try-runtime",
"pallet-root-testing/try-runtime",
"pallet-scheduler/try-runtime",
"sp-runtime/try-runtime",
]
6 changes: 3 additions & 3 deletions benchmarking/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ frame-system = { workspace = true, features = ["std"] }
[features]
default = [ "std" ]
std = [
"serde",

"parity-scale-codec/std",
"frame-benchmarking/std",
"frame-support/std",
"frame-system/std",
"log/std",
"parity-scale-codec/std",
"scale-info/std",
"serde",
"sp-api/std",
"sp-io/std",
"sp-runtime-interface/std",
Expand Down
12 changes: 8 additions & 4 deletions currencies/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,25 @@ sp-core = { workspace = true, features = ["std"] }
orml_tokens = { package = "orml-tokens", path = "../tokens", version = "0.5.0-dev" }

[features]
default = ["std"]
default = [ "std" ]
std = [
"serde",

"parity-scale-codec/std",
"frame-support/std",
"frame-system/std",
"orml-traits/std",
"orml-utilities/std",
"pallet-balances/std",
"parity-scale-codec/std",
"scale-info/std",
"serde",
"sp-core/std",
"sp-io/std",
"sp-runtime/std",
"sp-std/std",
]
try-runtime = [
"frame-support/try-runtime",
"frame-system/try-runtime",
"orml_tokens/try-runtime",
"pallet-balances/try-runtime",
"sp-runtime/try-runtime",
]
8 changes: 4 additions & 4 deletions gradually-update/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,13 @@ sp-runtime = { workspace = true }
sp-std = { workspace = true }

[features]
default = ["std"]
default = [ "std" ]
std = [
"serde",

"parity-scale-codec/std",
"frame-support/std",
"frame-system/std",
"parity-scale-codec/std",
"scale-info/std",
"serde",
"sp-core/std",
"sp-io/std",
"sp-runtime/std",
Expand All @@ -36,4 +35,5 @@ std = [
try-runtime = [
"frame-support/try-runtime",
"frame-system/try-runtime",
"sp-runtime/try-runtime",
]
10 changes: 6 additions & 4 deletions nft/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,20 @@ sp-core = { workspace = true, features = ["std"] }
sp-io = { workspace = true, features = ["std"] }

[features]
default = ["std"]
default = [ "std" ]
std = [
"serde",

"parity-scale-codec/std",
"frame-support/std",
"frame-system/std",
"parity-scale-codec/std",
"scale-info/std",
"serde",
"sp-core/std",
"sp-io/std",
"sp-runtime/std",
"sp-std/std",
]
try-runtime = [
"frame-support/try-runtime",
"frame-system/try-runtime",
"sp-runtime/try-runtime",
]
9 changes: 5 additions & 4 deletions oracle/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,23 @@ orml-utilities = { path = "../utilities", version = "0.5.0-dev", default-feature
sp-core = { workspace = true }

[features]
default = ["std"]
default = [ "std" ]
std = [
"serde",

"parity-scale-codec/std",
"frame-support/std",
"frame-system/std",
"orml-traits/std",
"orml-utilities/std",
"parity-scale-codec/std",
"scale-info/std",
"serde",
"sp-application-crypto/std",
"sp-core/std",
"sp-io/std",
"sp-runtime/std",
"sp-std/std",
]
try-runtime = [
"frame-support/try-runtime",
"frame-system/try-runtime",
"sp-runtime/try-runtime",
]
8 changes: 2 additions & 6 deletions oracle/runtime-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,5 @@ sp-api = { workspace = true }
sp-std = { workspace = true }

[features]
default = ["std"]
std = [
"parity-scale-codec/std",
"sp-api/std",
"sp-std/std"
]
default = [ "std" ]
std = [ "parity-scale-codec/std", "sp-api/std", "sp-std/std" ]
13 changes: 7 additions & 6 deletions parameters/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,18 @@ sp-core = { workspace = true, features = ["std"] }
sp-io = { workspace = true, features = ["std"] }

[features]
default = ["std"]
default = [ "std" ]
std = [
"serde",

"parity-scale-codec/std",
"frame-support/std",
"frame-system/std",
"orml-traits/std",
"parity-scale-codec/std",
"scale-info/std",
"serde",
"sp-core/std",
"sp-io/std",
"sp-runtime/std",
"sp-std/std",

"orml-traits/std",
]
runtime-benchmarks = [
"frame-support/runtime-benchmarks",
Expand All @@ -46,4 +46,5 @@ runtime-benchmarks = [
try-runtime = [
"frame-support/try-runtime",
"frame-system/try-runtime",
"sp-runtime/try-runtime",
]
Loading

0 comments on commit b45942e

Please sign in to comment.