Skip to content

Commit

Permalink
Check and fix features (#203)
Browse files Browse the repository at this point in the history
Update: Trimmed this MR down to only do feature changes and no
formatting anymore, to reduce conflicts.

Changes:
- Add Zepter config from the SDK and fix all occurrences
- Add CI check to validate the feature config

[x] Does not require a CHANGELOG entry

---------

Signed-off-by: Oliver Tale-Yazdi <[email protected]>
Co-authored-by: Bastian Köcher <[email protected]>
Co-authored-by: fellowship-merge-bot[bot] <151052383+fellowship-merge-bot[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Mar 28, 2024
1 parent d367c61 commit 2e26967
Show file tree
Hide file tree
Showing 10 changed files with 232 additions and 120 deletions.
39 changes: 39 additions & 0 deletions .config/zepter.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
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',
# 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',
# Auxillary flags:
'--offline',
'--locked',
'--show-path',
'--quiet',
]
# Same as `check`, but with the `--fix` flag.
default:
- [ $check.0, '--fix' ]

# Will be displayed when any workflow fails:
help:
text: |
This repo 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/ggwpez/zepter"
35 changes: 35 additions & 0 deletions .github/workflows/check-features.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Various checks to verify the cargo workspace and its crates are correctly configured.
name: "Workspace"

on:
push:
branches: ["main", "release-*"]
pull_request:
workflow_dispatch:

# cancel previous runs
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
check:
runs-on: ubuntu-22.04

steps:
- name: Install stable Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable

- name: Install Zepter
run: cargo install --locked -q zepter && zepter --version

- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0 # Dont clone historic commits.

- name: Check features
run: zepter run check
6 changes: 6 additions & 0 deletions chain-spec-generator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,10 @@ runtime-benchmarks = [
"glutton-kusama-runtime/runtime-benchmarks",
"coretime-kusama-runtime/runtime-benchmarks",
"people-kusama-runtime/runtime-benchmarks",
"cumulus-primitives-core/runtime-benchmarks",
"pallet-staking/runtime-benchmarks",
"parachains-common/runtime-benchmarks",
"polkadot-primitives/runtime-benchmarks",
"polkadot-runtime-parachains/runtime-benchmarks",
"sp-runtime/runtime-benchmarks"
]
3 changes: 3 additions & 0 deletions system-parachains/asset-hubs/asset-hub-kusama/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ runtime-benchmarks = [
"sp-runtime/runtime-benchmarks",
"xcm-builder/runtime-benchmarks",
"xcm-executor/runtime-benchmarks",
"cumulus-primitives-core/runtime-benchmarks",
"parachains-common/runtime-benchmarks"
]
try-runtime = [
"cumulus-pallet-aura-ext/try-runtime",
Expand Down Expand Up @@ -257,6 +259,7 @@ std = [
"xcm-builder/std",
"xcm-executor/std",
"xcm/std",
"primitive-types/std"
]

# A feature that should be enabled when the runtime should be built for on-chain
Expand Down
3 changes: 3 additions & 0 deletions system-parachains/asset-hubs/asset-hub-polkadot/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ runtime-benchmarks = [
"sp-runtime/runtime-benchmarks",
"xcm-builder/runtime-benchmarks",
"xcm-executor/runtime-benchmarks",
"cumulus-primitives-core/runtime-benchmarks",
"parachains-common/runtime-benchmarks"
]
try-runtime = [
"cumulus-pallet-aura-ext/try-runtime",
Expand Down Expand Up @@ -245,6 +247,7 @@ std = [
"xcm-builder/std",
"xcm-executor/std",
"xcm/std",
"primitive-types/std"
]

# A feature that should be enabled when the runtime should be built for on-chain
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,5 @@ std = [
"sp-std/std",
"system-parachains-constants/std",
"xcm/std",
"snowbridge-core/std"
]
2 changes: 2 additions & 0 deletions system-parachains/collectives/collectives-polkadot/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ runtime-benchmarks = [
"sp-runtime/runtime-benchmarks",
"xcm-builder/runtime-benchmarks",
"xcm-executor/runtime-benchmarks",
"cumulus-primitives-core/runtime-benchmarks",
"parachains-common/runtime-benchmarks"
]
try-runtime = [
"cumulus-pallet-aura-ext/try-runtime",
Expand Down
1 change: 1 addition & 0 deletions system-parachains/coretime/coretime-kusama/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ std = [
"xcm-builder/std",
"xcm-executor/std",
"xcm/std",
"system-parachains-constants/std"
]

runtime-benchmarks = [
Expand Down
Loading

0 comments on commit 2e26967

Please sign in to comment.