-
Notifications
You must be signed in to change notification settings - Fork 1.9k
ci: use pinned nightly rustfmt
to make unstable features take effect
#2896
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
Conversation
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Hey @lucienfer, thanks for the PR! I'm surprised this is necessary: |
You’re right, after digging a bit I realized that dprint wasn’t actually checking the Rust formatting properly because it was configured to run rustfmt on the stable toolchain. Since the repo’s To fix this I made two changes: This should ensure that formatting is consistently checked both locally (via dprint) and in CI. |
Awesome that you investigated, super helpful! I remember we had #2168 a while ago, which made us go from nightly to stable for this. I think we should revisit my comment from then and simply pin the nightly version for this. Something like When I did this recently in my new company, I ran into I filled dprint/dprint#1023 about this in For people at home calling |
I updated the PR to pin rustfmt to |
.github/workflows/build.yml
Outdated
rustup toolchain install --profile minimal nightly-2025-09-01 | ||
rustup component add rustfmt --toolchain nightly-2025-09-01 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for this! One suggestion: could you use a variable for this so it's easier to update in a few months?
Cc @egithinji, could we use cargo xtask install-tools
here? Not now, but in a later PR since this just refactors the existing install commands.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this looks good now, we just need to fix the formatting!
Head branch was pushed to by a user without write access
rustfmt
to make unstable features take effect
What does this PR do?
This PR extends the existing
format
job in.github/workflows/build.yml
tocheck Rust formatting with nightly
rustfmt
:Why?
• The repository already defines a rustfmt.toml with nightly-only settings (imports_granularity, use_small_heuristics = "Max", etc.).
• The CI installs nightly rustfmt but wasn’t actually using it.
• Currently, dprint/check verifies formatting for Markdown/PO/JS/etc., but not Rust code.
This PR makes sure PRs fail if Rust code is not formatted according to rustfmt.toml.
How was it tested?
• Ran locally with:
Both checks pass on a clean branch.
• CI workflow updated accordingly.
If Rust code is unformatted, the format job will now fail.
Closes #2794