name: Lint

on:
  push:
    branches:
      - main
  pull_request:
    types: [opened, edited, synchronize, reopened]
    branches:
      - main

jobs:
  lint:
    runs-on: windows-latest
    steps:
      - uses: actions/checkout@v6

      - name: Install Rust nightly
        uses: dtolnay/rust-toolchain@nightly
        with:
          components: rustfmt, clippy

      - name: Cache dependencies
        uses: Swatinem/rust-cache@v2

      - name: Check formatting
        run: cargo +nightly fmt --check

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

  check-title:
    runs-on: ubuntu-latest
    if: github.event_name == 'pull_request'
    steps:
      - uses: amannn/action-semantic-pull-request@v6
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          validateSingleCommit: false
