name: Test
on:
  pull_request:
  push:
    branches: [master, develop]
  workflow_dispatch:
concurrency:
  group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
  cancel-in-progress: true
jobs:
  build-test:
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        # Also adapt tox.ini on change
        python-version: ['3.9', 'pypy3.11', '3.x']
        # macOS on ARM, Ubuntu on x86, Windows on X86
        os: [macos-latest, ubuntu-latest, windows-latest]
    steps:
      - name: Checkout
        uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - name: Set up Python ${{ matrix.python-version }}
        uses: actions/setup-python@v5
        with:
          python-version: ${{ matrix.python-version }}
          cache: 'pip'
          cache-dependency-path: 'pyproject.toml'
      - name: Install dependencies
        run: |
          python -m pip install --upgrade pip
          pip install --editable ".[dev]"
      - name: Test with tox
        run: tox -e py
