actions-rs / meta

🦀 GitHub Actions for Rust - recipes, discussions, questions and ideas
https://github.com/actions-rs
Creative Commons Zero v1.0 Universal
353 stars 15 forks source link

Auto rustfmt commit action? #8

Open repi opened 5 years ago

repi commented 5 years ago

On all of our repos we have a CI check that ensures rustfmt has been run and fails the build if it has not, and we are experimenting with changing to use the actions-rs action for just that instead of Travis & Buildkite.

But one thing we've thought about (cc @jake-shadle) that may be even better alternative workflow would be a rustfmt action that instead of warning or failing a PR on fmt differences actually just runs cargo fmt and commits & pushes changed files to the PR branch.

How hard would it be to create such an action?

Probably is not the best workflow for everyone, but we typically squash our commits so some occasional "Rustfmt" commits is fine, and nice to not have to do manually and push up on a broken build.

This is mostly a problem because RLS doesn't work in our large projects (https://github.com/EmbarkStudios/rust-ecosystem/issues/8) which makes rustfmt not automatically run in VS Code so formatting on save often doesn't work so code slips in without correct formatting.

raftario commented 5 years ago

I could also use this, gonna start working on it!

@svartalf You can mention me when/if you want me to transfer ownership.

CAD97 commented 5 years ago

I had a different idea: add a rustfmt-check like clippy-check. Since GitHub now (beta) supports multiline diff comments as well as suggestions, the output of cargo clippy -- --check can be parsed and turned into suggestions directly on the PR.

(Of course, this is assuming GitHub decides to give the token used for running PRs from forks write permissions to the PR comments to be of any real use.)