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

feat: add rustfmt imports_granularity #1077

Merged
merged 11 commits into from
Jan 5, 2024
Merged

Conversation

qiweiii
Copy link
Contributor

@qiweiii qiweiii commented Dec 24, 2023

What was wrong?

resolve #1046

How was it fixed?

  • add rustfmt.toml
  • run cargo +nightly fmt --all
  • update ci to use nightly toolchain

@qiweiii
Copy link
Contributor Author

qiweiii commented Dec 25, 2023

the lint ci failed, not very familiar with circleci, please help😁

Copy link
Member

@ogenev ogenev left a comment

Choose a reason for hiding this comment

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

The new rustlang/rust:nightly-slim image seems to break the CircleCI lint job because the sudo command is not included.

I'm not sure what the slim version contains compared to the regular nightly but I guess we can get away with the regular image.

Copy link
Member

@ogenev ogenev left a comment

Choose a reason for hiding this comment

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

We need also to update the fmt command in book/src/developers/contributing/git/pull_requests.md.

@ogenev
Copy link
Member

ogenev commented Jan 3, 2024

The lint is still failing, it looks like we don't need the sudo command for the nightly image lint used inside the install-depends step. But this step is also used in other jobs.

Creating an install-depends-nighly step without sudo and adding this step for the lint (instead of the default install-depends) is a reasonable solution.

@qiweiii
Copy link
Contributor Author

qiweiii commented Jan 4, 2024

Nice, lint works now, I also added a rust-toolchain file so developers don't need to manually switch toolchain

@ogenev
Copy link
Member

ogenev commented Jan 4, 2024

Nice, lint works now, I also added a rust-toolchain file so developers don't need to manually switch toolchain

Great but we don't want to pin Trin to the latest nightly version (at least we need to have a discussion about that with the rest of the team).

The current workflow is to use nightly only for fmt, so let's remove the rust-toolchain file for now. In the future, if we decide, we can pin Trin to a nightly specific version (for example nightly-2023-01-04) and this will not require to manually set nighly fmt with +nighlty.

@ogenev
Copy link
Member

ogenev commented Jan 4, 2024

By the way, while we are still here, could you also add those configs to the rustfmt.toml file:

comment_width = 100
wrap_comments = true
format_code_in_doc_comments = true
doc_comment_code_block_width = 100

- setup-and-restore-sccache-cache
- run:
name: Run Clippy
command: cargo clippy --all --all-targets --all-features --no-deps -- --deny warnings
Copy link
Member

Choose a reason for hiding this comment

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

Looking at this now, I assume here clippy is running with the nightly version, but because we don't pin Trin to nightly there may be some discrepancies between nightly clippy and stable clippy in the future.

It would be better if we split the lint job to cargo-fmt and cargo-clippy and run clippy with the default stable toolchain.

If you don't feel like doing it in this PR, we can leave it for a future fix (this will not be a blocker for merging this PR).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I could try it in this PR, seems like a simple change

Copy link
Contributor Author

Choose a reason for hiding this comment

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

all done!

Copy link
Member

@ogenev ogenev left a comment

Choose a reason for hiding this comment

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

Looks good to me 💯 !. Thank you for this contribution, really happy to see some structure to our imports. ❤️

@ogenev ogenev merged commit 8c7cedc into ethereum:master Jan 5, 2024
11 checks passed
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.

Enforce imports granularity config option in rustfmt
2 participants