.github/workflows/testing.yml

Summary

Maintainability
Test Coverage
name: Testing

on: workflow_call

jobs:
  test:
    runs-on: ubuntu-20.04
    strategy:
      matrix:
        python-version: [3.8, 3.9, 3.10.2, 3.11, 3.12]
        sqlalchemy-version: [1.3, 1.4]
        django-version: [2.2, 4.2]
        exclude:
          - python-version: '3.8'
            sqlalchemy-version: '1.4'
          - python-version: '3.9'
            sqlalchemy-version: '1.4'
          - python-version: '3.8'
            django-version: '4.2'
          - python-version: '3.9'
            django-version: '4.2'
    name: Test Py ${{ matrix.python-version }}, SQLA ${{ matrix.sqlalchemy-version }}, Django ${{ matrix.django-version }}
    steps:
    - uses: actions/checkout@v3
    - name: Set up Python ${{ matrix.python-version }}
      uses: actions/setup-python@v4
      with:
        python-version: ${{ matrix.python-version }}
    - name: Install and configure Poetry
      uses: snok/install-poetry@v1
      with:
        version: 1.3.2
    - name: Install dependencies
      run: |
        sed -i.bak 's/^SQLAlchemy = .*/SQLAlchemy = "^${{ matrix.sqlalchemy-version }}"/' pyproject.toml
        sed -i.bak 's/^Django = .*/Django = "^${{ matrix.django-version }}"/' pyproject.toml
        poetry install
    - name: Test with pytest
      run: |
        poetry run pytest -rfs --cov --cov-config=.coveragerc --cov-report="" --disable-warnings
        cp .coverage ".coverage.${{ matrix.python-version }}"
    - name: Upload coverage report
      uses: actions/upload-artifact@v3
      with:
        name: coverage-reports
        path: ".coverage.${{ matrix.python-version }}"

  coverage-check:
    name: Coverage check
    runs-on: ubuntu-20.04
    needs: [test]
    steps:
      - uses: actions/checkout@v3
      - name: Set up Python 3.12
        uses: actions/setup-python@v4
        with:
          python-version: 3.12
      - name: Install dependencies
        run: |
          pip3 install coverage==7.2.3
      - name: Download coverage reports
        uses: actions/download-artifact@v1
        with:
          name: coverage-reports
      - name: Combine reports
        run: |
          coverage combine coverage-reports
          coverage report --fail-under=100