name: Check formatting

on:
  push:
    branches:
      - master
  pull_request:

env:
  CARGO_TERM_COLOR: always

jobs:
  fmt:
    name: Check formatting
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable
        with:
          components: rustfmt

      - name: Run cargo fmt
        run: cargo fmt --check --all
