Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Format and Sort features in Cargo.toml files #14803

Merged
merged 13 commits into from
Aug 23, 2023

Conversation

ggwpez
Copy link
Member

@ggwpez ggwpez commented Aug 21, 2023

Changes:

  • Canonicalize (sort+format) the features in all Cargo.toml files.
  • Add an experimental CI check that all Cargo.tomls are formatted.
  • Update style guide to mention the auto-formatting.

Its fine if we dont merge this before the monorepo; this MR is mostly to gather feedback on the formatting.
Are you OK with the canonical format that this introduces? Eventually we should add it to bot fmt.

My only point would be that the default feature looks slightly weird, give that it normally just contains one item. On the other hand, this creates a uniform formatting for all features... WDYT?

I asserted locally that this does not alter the sha256 of the kitchensink runtime.

The CI prints a diff on error to make debugging easier:

diff --git a/primitives/runtime/Cargo.toml b/primitives/runtime/Cargo.toml
index 39d0148..adef632 100644
--- a/primitives/runtime/Cargo.toml
+++ b/primitives/runtime/Cargo.toml
@@ -50,13 +50,13 @@ std = [
 	"log/std",
+	# hi
+	"rand",
 	"sp-arithmetic/std",
-	# hi
-	"rand",
 	"sp-core/std",

Signed-off-by: Oliver Tale-Yazdi <[email protected]>
Signed-off-by: Oliver Tale-Yazdi <[email protected]>
Signed-off-by: Oliver Tale-Yazdi <[email protected]>
This reverts commit b2b1099.
@ggwpez ggwpez marked this pull request as ready for review August 21, 2023 19:16
@ggwpez ggwpez requested review from a team August 21, 2023 19:16
@ggwpez ggwpez requested a review from a team August 21, 2023 19:16
@ggwpez ggwpez requested review from koute and a team as code owners August 21, 2023 19:16
@ggwpez ggwpez added A0-please_review Pull request needs code review. B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. D3-trivial 🧸 PR contains trivial changes in a runtime directory that do not require an audit labels Aug 21, 2023
Signed-off-by: Oliver Tale-Yazdi <[email protected]>
@ggwpez ggwpez requested a review from bkchr August 21, 2023 19:21
Copy link
Member

@bkchr bkchr left a comment

Choose a reason for hiding this comment

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

Generally okay, but we should document on how to use the tool. Not sure we should let people copy a patch.

- .test-refs
script:
- cargo install zepter --locked --version 0.9.2 -q -f --no-default-features && zepter --version
- zepter format features --workspace --fix
Copy link
Member

Choose a reason for hiding this comment

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

The tool should be documented in the contribution guides or similar and how to use it

Copy link
Contributor

Choose a reason for hiding this comment

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

Better to add a bash script and run it in ci for local dev?

Copy link
Member Author

@ggwpez ggwpez Aug 23, 2023

Choose a reason for hiding this comment

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

I added some docs to the STYLE_GUIDE and mention it in the CI output.

WDYM? Running zepter format features (the --workspace and --fix flag are implicit now) is not much longer than invoking a bash script.

Copy link
Contributor

@juangirini juangirini left a comment

Choose a reason for hiding this comment

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

❤️

bin/node-template/pallets/template/Cargo.toml Outdated Show resolved Hide resolved
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]>
scripts/ci/gitlab/pipeline/test.yml Outdated Show resolved Hide resolved
scripts/ci/gitlab/pipeline/test.yml Show resolved Hide resolved
Signed-off-by: Oliver Tale-Yazdi <[email protected]>
@paritytech-ci paritytech-ci requested a review from a team August 23, 2023 13:18
Signed-off-by: Oliver Tale-Yazdi <[email protected]>
@ggwpez
Copy link
Member Author

ggwpez commented Aug 23, 2023

bot merge

@paritytech-processbot
Copy link

Waiting for commit status.

@paritytech-processbot paritytech-processbot bot merged commit b7c18f1 into master Aug 23, 2023
51 checks passed
@paritytech-processbot paritytech-processbot bot deleted the oty-format-features branch August 23, 2023 14:21
ggwpez added a commit to ggwpez/zepter that referenced this pull request Aug 23, 2023
paritytech/substrate#14803 should ensure that
Substrate master stays formatted. We can therefore check this here
already to ensure to not break it.

Signed-off-by: Oliver Tale-Yazdi <[email protected]>
ggwpez added a commit to ggwpez/zepter that referenced this pull request Aug 23, 2023
paritytech/substrate#14803 should ensure that
Substrate master stays formatted. We can therefore check this here
already to ensure to not break it.

Signed-off-by: Oliver Tale-Yazdi <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A0-please_review Pull request needs code review. B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. D3-trivial 🧸 PR contains trivial changes in a runtime directory that do not require an audit
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants