name: unit-tests

on:
  push:
    branches: [ "main" ]
    paths-ignore:
      - '**/*.md'
  pull_request:
    branches: [ "main" ]
    paths-ignore:
      - '**/*.md'

permissions:
  contents: read

defaults:
    run:
        shell: bash

jobs:
  unit-tests:
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest, windows-latest, macos-latest]
        # TODO consider bringing back 3.7. Note Windows x 3.7 fails from some sqlalchemy related problem
        python-version: ["3.8", "3.9", "3.10", "3.11"]
    runs-on: ${{ matrix.os }}
    steps:
    - uses: actions/checkout@v3
    - uses: ./.github/actions/setup_build_env
      with:
          python-version: ${{ matrix.python-version }}
          run-poetry-install: true
          create-venv-at-path: .venv
    - name: Run unit tests
      run: |
        export PYTHONUNBUFFERED=1
        poetry run pytest tests --cov --no-cov-on-fail --cov-report=
    - run: poetry run coverage html
