name: Test

on: [push, pull_request, workflow_dispatch]

permissions: {}

env:
  FORCE_COLOR: 1
  PIP_DISABLE_PIP_VERSION_CHECK: 1

jobs:
  test:
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        python-version:
          - "pypy3.11"
          - "3.14t"
          - "3.14"
          - "3.13t"
          - "3.13"
          - "3.12"
          - "3.11"
          - "3.10"
          - "3.9"
        os: [macos-latest, ubuntu-latest]

    steps:
      - uses: actions/checkout@v4
        with:
          persist-credentials: false

      - name: Set up Python ${{ matrix.python-version }}
        uses: actions/setup-python@v5
        with:
          python-version: ${{ matrix.python-version }}
          allow-prereleases: true

      - name: Set PYTHON_GIL
        if: endsWith(matrix.python-version, 't')
        run: |
          echo "PYTHON_GIL=0" >> "$GITHUB_ENV"

      - name: Install uv
        uses: hynek/setup-cached-uv@v2

      - name: Tox tests
        run: |
          uvx --python ${{ matrix.python-version }} --with tox-uv tox -e py

      - name: Upload coverage
        uses: codecov/codecov-action@v5
        with:
          flags: ${{ matrix.os }}
          name: ${{ matrix.os }} Python ${{ matrix.python-version }}

  success:
    needs: test
    runs-on: ubuntu-latest
    name: Test successful
    steps:
      - name: Success
        run: echo Test successful
