name: Run tests

on:
  # run on push in main or rel_* branches excluding changes are only on doc or example folders
  push:
    branches:
      - main
      - "rel_*"
      # branches used to test the workflow
      - "workflow_test_*"
    paths-ignore:
      - "docs/**"

jobs:
  run-test:
    name: ${{ matrix.python-version }}-${{ matrix.os }}
    runs-on: ${{ matrix.os }}
    strategy:
      # run this job using this matrix
      matrix:
        os:
          - "ubuntu-latest"
          - "windows-latest"
          - "macos-latest"
        python-version:
          - "3.8"
          - "3.9"
          - "3.10"
          - "3.11"
          - "3.12"

        exclude:
          # beaker raises warning on 3.10. only windows seems affected
          # See https://github.com/bbangert/beaker/pull/213
          - os: "windows-latest"
            python-version: "3.10"

      fail-fast: false

    # steps to run in each job. Some are github actions, others run shell commands
    steps:
      - name: Checkout repo
        uses: actions/checkout@v4

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

      - name: Install dependencies
        run: |
          python -m pip install --upgrade pip
          pip install --upgrade tox setuptools
          pip list

      - name: Run tests
        run: tox
