Skip to content

Check formatting of Rust code with rustfmt

License

Notifications You must be signed in to change notification settings

actions-rust-lang/rustfmt

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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@v4
      # 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

Inputs

All inputs are optional. If a toolchain file (i.e., rust-toolchain or rust-toolchain.toml) is found in the root of the repository, it takes precedence. All input values are ignored if a toolchain file exists.

Name Description Default
manifest-path Path to the Cargo.toml file, by default in the root of the repository. ./Cargo.toml