on: [push, pull_request]
permissions:
  contents: read

name: Lints

jobs:
  lints:
    name: rustfmt and clippy
    runs-on: ubuntu-latest
    steps:
      - name: Checkout sources
        uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
        with:
          persist-credentials: false

      - name: Install stable toolchain
        uses: dtolnay/rust-toolchain@b3b07ba8b418998c39fb20f53e8b695cdcc8de1b
        with:
          toolchain: stable
          components: rustfmt, clippy

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

      - name: Run cargo clippy
        run: cargo clippy -- -D warnings

      - name: Run cargo clippy on tests
        run: cargo clippy --tests -- -D warnings
