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

Run rustfmt for each PR via GitHub Actions #4

Merged
merged 4 commits into from
May 24, 2023
Merged

Run rustfmt for each PR via GitHub Actions #4

merged 4 commits into from
May 24, 2023

Conversation

dongsupark
Copy link
Member

@dongsupark dongsupark commented May 23, 2023

Run CI workflow for each pull request. At the moment it only runs cargo fmt --all --check.

Add .rustfmt.toml to configure rustfmt per project.
Note, it is unfortunately not possible to set trailing_comma option, because that is only available in Nightly toolchains.
See also the doc.

Disable rustfmt check in case of method calls that spread across multiple lines, which we would like to keep as-is, even if rustfmt does not provide a way to disable or configure the changes.

With disabling rustfmt checks, we are now able to run rustfmt with the following .rustfmt.toml.

max_width=200
fn_call_width=80
reorder_imports=false
use_small_heuristics="Off"

Fixes flatcar/Flatcar#1026.

Testing done

Done via my fork.

  • Changelog entries added in the respective changelog/ directory (user-facing change, bug fix, security fix, update)
  • Inspected CI output for image differences: /boot and /usr size, packages, list files for any missing binaries, kernel modules, config files, kernel modules, etc.

Run CI workflow for each pull request.
At the moment it only runs `cargo fmt --all --check`.
Add .rustfmt.toml to configure rustfmt per project.

Note, it is unfortunately not possible to set `trailing_comma` option,
because that is only available in Nightly toolchains.
See also https://github.com/rust-lang/rustfmt/blob/master/Configurations.md#trailing_comma
Disable rustfmt check in case of method calls that spread across
multiple lines, which we would like to keep as-is, even if rustfmt
does not provide a way to disable or configure the changes.
With disabling rustfmt checks, we are now able to run rustfmt with the
following .rustfmt.toml.

```
max_width=200
fn_call_width=80
reorder_imports=false
use_small_heuristics="Off"
```
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all --check
Copy link
Member

Choose a reason for hiding this comment

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

Maybe in a follow up we should also run clippy or at least cargo check.

Copy link
Collaborator

@wrl wrl left a comment

Choose a reason for hiding this comment

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

All looks good!

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.

rustfmt configuration
3 participants