name: CI

on: [push]

jobs:
  ci:
    needs: [linting, formatting, testing, type-checking]
    name: CI
    runs-on: "ubuntu-latest"
    steps:
      - name: Done
        run: exit 0

  type-checking:
    runs-on: "ubuntu-latest"

    steps:
      - uses: actions/checkout@v4

      - name: Install uv
        uses: astral-sh/setup-uv@v3

      - name: Set up Python ${{ matrix.python-version }}
        run: |
          uv python install ${{ matrix.python-version }}
          uv venv

      - name: Install dependencies
        run: |
          uv sync --only-group type-checking

      - name: Run formatting
        run: |
          uv run pyright

  formatting:
    runs-on: "ubuntu-latest"

    steps:
      - uses: actions/checkout@v4

      - name: Install uv
        uses: astral-sh/setup-uv@v3

      - name: Set up Python ${{ matrix.python-version }}
        run: |
          uv python install ${{ matrix.python-version }}
          uv venv

      - name: Install dependencies
        run: |
          uv sync --only-group linting

      - name: Run formatting
        run: |
          uv run ruff format --check .

  linting:
    runs-on: "ubuntu-latest"

    steps:
      - uses: actions/checkout@v4

      - name: Install uv
        uses: astral-sh/setup-uv@v3

      - name: Set up Python ${{ matrix.python-version }}
        run: |
          uv python install ${{ matrix.python-version }}
          uv venv

      - name: Install dependencies
        run: |
          uv sync --only-group linting

      - name: Run linting
        run: |
          uv run ruff check .

  testing:
    runs-on: "ubuntu-latest"
    strategy:
      max-parallel: 5
      matrix:
        python-version: ["3.10", "3.11", "3.12", "3.13"]

    steps:
      - uses: actions/checkout@v4

      - name: Install uv
        uses: astral-sh/setup-uv@v3

      - name: Set up Python ${{ matrix.python-version }}
        run: |
          uv python install ${{ matrix.python-version }}
          uv venv

      - name: Install dependencies
        run: |
          uv sync --only-group testing

      - name: Testing
        run: |
          uv run pytest -v tests/*.py
