name: Python package

on:
  workflow_dispatch:
  pull_request:
  push:

jobs:
  lint:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v5
      - name: Set up Python
        uses: actions/setup-python@v6
        with:
          python-version: 3.x
      - name: Install uv
        uses: astral-sh/setup-uv@v7
      - name: Install dependencies
        run: uv sync
      - name: Run pre-commit
        run: uv run pre-commit run --all-files --show-diff-on-failure --color=always

  build:
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        python-version: ["3.10", "3.11", "3.12", "3.13", "3.14", "pypy3.10"]
        os: [ubuntu-latest, macOS-latest, windows-latest]

    steps:
      - uses: actions/checkout@v5
      - name: Set up Python ${{ matrix.python-version }}
        uses: actions/setup-python@v6
        with:
          python-version: ${{ matrix.python-version }}
          allow-prereleases: true
      - name: Install uv
        uses: astral-sh/setup-uv@v7
      - name: Install dependencies
        run: |
          uv sync --no-dev --group test
          uv pip install .
      - name: Test with pytest
        run: |
          uv run --no-sync pytest
