diff --git a/README.md b/README.md index a06a868..37a5367 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,37 @@ -# rustfmt -Check formatting of Rust code with rustfmt +# Run `rustfmt` + +Run `cargo fmt --all` and report all formatting differences in a nice overview. +It works best in combination with [`actions-rust-lang/setup-rust-toolchain`] for [problem matcher] highlighting. + +Execution Summary: + +![The action reports any formatting issues found by rustfmt.](./imgs/rustfmt-results.png) + +Problem Matcher: + +![Annotation highlighting formatting differences.](./imgs/rustfmt-problem-matcher.png) + +## Example workflow + +```yaml +name: "Test Suite" +on: + push: + pull_request: + +jobs: + formatting: + name: cargo fmt + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + # Ensure rustfmt is installed and setup problem matcher + - uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + components: rustfmt + - name: Rustfmt Check + uses: actions-rust-lang/rustfmt@v1 +``` + +[`actions-rust-lang/setup-rust-toolchain`]: https://github.com/actions-rust-lang/setup-rust-toolchain +[problem matcher]: https://github.com/actions/toolkit/blob/main/docs/problem-matchers.md diff --git a/imgs/rustfmt-problem-matcher.png b/imgs/rustfmt-problem-matcher.png new file mode 100644 index 0000000..5d0d115 Binary files /dev/null and b/imgs/rustfmt-problem-matcher.png differ diff --git a/imgs/rustfmt-results.png b/imgs/rustfmt-results.png new file mode 100644 index 0000000..c65c544 Binary files /dev/null and b/imgs/rustfmt-results.png differ