on:
  pull_request:
    paths:
    - '**.rs'
    - '**/Cargo.toml'
  workflow_dispatch:

name: Rust lints

jobs:
  clippy:
    name: Clippy
    runs-on: ubuntu-latest
    steps:
    - name: Checkout sources
      uses: actions/checkout@v4

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

    - name: Check clippy
      run: cargo clippy --all-features -- -D warnings

  rustfmt:
    name: Rustfmt
    runs-on: ubuntu-latest
    steps:
    - name: Checkout sources
      uses: actions/checkout@v4

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

    - name: Check format
      run: cargo fmt --check
