Skip to content

Latest commit

 

History

History
52 lines (35 loc) · 2.89 KB

README.md

File metadata and controls

52 lines (35 loc) · 2.89 KB

rs-fmt-check Action

MIT licensed CI

Rustfmt suggestions in your Pull Requests

This GitHub Action executes rustfmt and posts all suggestions as annotations for the pushed commit 2.

Screenshot of a rustfmt suggestion displayed in the commit interface of GitHub

This GitHub Action is based on clechasseur/rs-clippy-check, which itself has been forked from actions-rs/clippy-check. See LICENSE for copyright attribution details.

Example workflow

Note: this workflow uses actions-rust-lang/setup-rust-toolchain to install the most recent nightly rustfmt 1.

name: Rustfmt check

on: push

jobs:
  rustfmt_check:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
      - uses: actions-rust-lang/setup-rust-toolchain@9399c7bb15d4c7d47b27263d024f0a4978346ba4 # v1.11.0
        with:
          toolchain: nightly
          components: rustfmt
      - uses: clechasseur/rs-fmt-check@e1bd0f5c24ced02542ed905bde212ffc9c324863 # v2.0.8

Inputs

All inputs are optional.

Name Description Type Default
toolchain Rust toolchain to use 1 string nightly
args Arguments for the cargo fmt command string
working-directory Directory where to perform the cargo fmt command string

For extra details about the toolchain and args inputs, see rs-cargo Action.

Notes

1 : This action currently relies on an unstable rustfmt feature (emit json) and as such, requires a nightly toolchain at the minimum. You should not change the value of the toolchain parameter unless you know the specified toolchain supports the feature correctly.

2 : Currently, GitHub sets a limit of 10 warning annotations per run (see this page for more information). So if there are more than 10 suggestions returned by rustfmt, only the first 10 will appear as PR annotations. The other suggestions will still appear in the check run summary (see this one for example).