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

Check Rust feature configs #964

Merged
merged 9 commits into from
Nov 12, 2023
Merged

Check Rust feature configs #964

merged 9 commits into from
Nov 12, 2023

Conversation

ggwpez
Copy link
Contributor

@ggwpez ggwpez commented Nov 8, 2023

Adds the Zepter CLI to the CI to verify feature integrity of all Rust crates. It uses (nearly) the same config file as the Polkadot-SDK.
cc @AurevoirXavier maybe you also want to add your tool?

What it does:

  • Formats the features with 80 line width.
  • Checks that try-runtime, runtime-benchmarks and std is forwarded to dependencies.
  • Skips the check that if crate B has a feature that crate A also must have that feature (we skipped this in the SDK, but could be enabled).

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

codecov bot commented Nov 8, 2023

Codecov Report

Merging #964 (1993e51) into master (0abce5c) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##           master     #964   +/-   ##
=======================================
  Coverage   85.32%   85.32%           
=======================================
  Files          88       88           
  Lines       10476    10476           
=======================================
  Hits         8939     8939           
  Misses       1537     1537           

📣 Codecov offers a browser extension for seamless coverage viewing on GitHub. Try it in Chrome or Firefox today!

@aurexav
Copy link

aurexav commented Nov 9, 2023

cc @AurevoirXavier maybe you also want to add your tool?

Sure, thank you. However, I am currently waiting for my new laptop, so I will be unavailable for a brief period.

@ggwpez
Copy link
Contributor Author

ggwpez commented Nov 9, 2023

Sure, thank you. However, I am currently waiting for my new laptop, so I will be unavailable for a brief period.

Okay nice. I am waiting for @xlc for some feedback on the approach.

Signed-off-by: Oliver Tale-Yazdi <[email protected]>
Makefile Outdated
@@ -34,9 +34,11 @@ Cargo.toml: Cargo.dev.toml

dev-format: Cargo.toml
cargo fmt --all
zepter format features --fix
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe have them on a separate target otherwise we need to indicate on README to tell user to install zepter first

but a good amount of time people won't need to use it so I want to make it optional

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay I put it into another target. LMK if i overdid it 😅

@@ -29,6 +29,8 @@ jobs:
uses: dtolnay/rust-toolchain@nightly
- name: Install Wasm toolchain
run: rustup target add wasm32-unknown-unknown
- name: Install Zepter
run: cargo install zepter --version 0.14.0 --locked -q -f --no-default-features && zepter --version
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesn't need to happen in this PR but at some stage I want to use https://github.com/taiki-e/install-action (powered by https://github.com/cargo-bins/cargo-binstall) to install tools. I don't know if zepter is compatible with it but we could try and see

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea i wanted to use cargo-install as well. I think it just pulls binaries from the the GH release page. Will explore it and then open another MR when its done.

@@ -41,3 +43,5 @@ jobs:
run: make dev-check
- name: Run tests
run: make dev-test
- name: Check Rust features
run: zepter run check
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

best to do check before tests

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Signed-off-by: Oliver Tale-Yazdi <[email protected]>
Signed-off-by: Oliver Tale-Yazdi <[email protected]>
@xlc xlc merged commit b45942e into open-web3-stack:master Nov 12, 2023
4 checks passed
"frame-support/try-runtime",
"frame-system/try-runtime",
"orml-tokens/try-runtime",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is causing issues when I try to publish this to crates.io using cargo release. orml-tokens is only a dev-dependencies so I think there is no reason to enable features for it?

Copy link
Contributor Author

@ggwpez ggwpez Nov 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, maybe it should be an optional feature enable then like orml-tokens?/try-runtime. Since when the feature is not propagated some of the tests could error i think.
I will try to debug it.

Copy link
Contributor Author

@ggwpez ggwpez Nov 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No the optional is not possible to compile then. I think in the past, Parity stripped dev-dependencies before publishing from the Cargo.toml files. Not sure if this still happens.
PS: Yea i think it still re-writes them https://github.com/paritytech/parity-publish/blob/1db5cd6056f76ebc8bb202931589397ce5b2cd36/src/apply.rs#L86

Maybe i can make a Zepter command to quickly strip all the dev stuff out.

Copy link
Member

@xlc xlc Nov 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried and not working. I believe it is cargo release removes dev-dependencies before publish and all those features will not be valid.
Besides, we don't really need to enable them for dev-dependencies anyway. If the tests requires the feature, we simply import them with feature enabled in dev-dependencies directly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a first version of this here ggwpez/zepter#56 for zepter transpose features strip-dev-only.
I will write some more tests tomorrow and fix a few edge-cases but it seems to work when i tested it with cargo publish --dry-run on the crates here.

@ggwpez ggwpez deleted the oty-feature-check branch November 13, 2023 20:39
@aurexav
Copy link

aurexav commented Nov 23, 2023

Currently, cargo-featalign requires a kitchensink-runtime or similar to perform the checks which is more accurate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants