meta icon indicating copy to clipboard operation
meta copied to clipboard

Auto rustfmt commit action?

Open repi opened this issue 6 years ago • 2 comments

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.

repi avatar Sep 27 '19 16:09 repi

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

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

raftario avatar Sep 28 '19 03:09 raftario

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.)

CAD97 avatar Oct 09 '19 05:10 CAD97