name: PR Checks

on:
  pull_request:
  workflow_dispatch:

concurrency:
  group: pr-checks-${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

jobs:
  pre-commit:
    runs-on: ubuntu-latest
    permissions:
      contents: read

    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Set up Python
        uses: actions/setup-python@v5
        with:
          python-version: "3.12"
          cache: pip
          cache-dependency-path: |
            pyproject.toml
            .pre-commit-config.yaml

      - name: Install dependencies
        run: |
          python -m pip install --upgrade pip
          python -m pip install pre-commit
          python -m pip install -e .[dev]

      - name: Run pre-commit
        run: pre-commit run --all-files