---
name: "unit tests - all"
on:
  pull_request:
  push:
    branches:
      - "main"
jobs:
  tox:
    name: "Python ${{ matrix.python-version }} -- ${{ matrix.os }} "
    runs-on: ${{ matrix.os }}
    continue-on-error: ${{ matrix.experimental }}
    strategy:
      matrix:
        os: [ubuntu-latest, windows-latest, macos-latest]
        python-version: ["3.10", "3.11"]
        experimental: [false]
        # Include experimental or bleeding-edge releases.
        # Windows is not included as it can be unreliable, e.g.
        # psycopg2-binary is only released some time after a Python
        # major/minor version is formally released.
        #
        # Uncomment below (including 'include:') when the next
        # reasonable test candidate is made available:
        include:
          #
          # Versions list: https://github.com/actions/python-versions/releases
          # Example formatting: 3.11.0-alpha.1, 3.9.0-beta.8, 3.10.0-rc.3
          #
          - os: ubuntu-latest
            python-version: "3.12.0"
            experimental: true
          - os: macos-latest
            python-version: "3.12.0"
            experimental: true
    steps:
      - name: "check out repository"
        uses: "actions/checkout@v2"
        with:
          submodules: 'true'
      - name: "set up python ${{ matrix.python-version }}"
        uses: "actions/setup-python@v2"
        with:
          python-version: "${{ matrix.python-version }}"
      - name: "get pip cache dir"
        id: "pip-cache"
        run: |
          echo "::set-output name=dir::$(pip cache dir)"
      - name: "cache pip packages"
        uses: "actions/cache@v2"
        with:
          path: "${{ steps.pip-cache.outputs.dir }}"
          key: "${{ runner.os }}-pip-${{ hashFiles('**/base.txt', '**/local.txt') }}"
          restore-keys: |
            ${{ runner.os }}-pip-
      - name: "install tox"
        run: |
          python -m pip install --upgrade pip
          pip install tox
      - name: "run tox"
        env:
          TOXENV: py3
        run: |
          tox
