name: Test & Lint

on:
  workflow_call:

jobs:
  lint:
    name: Lint
    runs-on: ubuntu-latest

    steps:
      - name: Checkout the code
        uses: actions/checkout@v6

      - name: Install `uv`
        run: |
          curl -LsSf https://astral.sh/uv/install.sh | sh

      - name: Lint with `ruff`
        run: |
          uv run ruff check

      - name: Format with `ruff`
        run: |
          uv run ruff format --check

  test:
    name: Test (Python ${{ matrix.python-version }})

    strategy:
      matrix:
        python-version:
          - "3.10"
          - "3.11"
          - "3.12"

      fail-fast: false

    runs-on: ubuntu-latest

    steps:
      - name: Checkout the code
        uses: actions/checkout@v6

      - name: Install `uv`
        run: |
          curl -LsSf https://astral.sh/uv/install.sh | sh

      - name: Set up Python ${{ matrix.python-version }}
        uses: actions/setup-python@v6
        with:
          python-version: ${{ matrix.python-version }}

      - name: Run tests
        run: |
          uv run pytest -v
