Skip to content
You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
check-square

GitHub Action

Check formatting of Rust code with rustfmt

v1.0.0

Check formatting of Rust code with rustfmt

check-square

Check formatting of Rust code with rustfmt

Run `cargo fmt` and check Rust code. Highlights places which are not correctly formatted.

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Check formatting of Rust code with rustfmt

uses: actions-rust-lang/rustfmt@v1.0.0

Learn more about this action in actions-rust-lang/rustfmt

Choose a version

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.

Problem Matcher:

Annotation highlighting formatting differences.

Example workflow

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