Skip to content

Test

Test #10

Workflow file for this run

name: Test
# Trigger this workflow manually or after linting.
on:
workflow_dispatch:
workflow_run:
workflows:
- Lint
types:
- completed
jobs:
test-matrix:
if: github.event.workflow_run.conclusion == 'success'
runs-on: ubuntu-latest
strategy:
matrix:
python-version:
- '3.10'
- '3.11'
- '3.12'
steps:
- uses: actions/cache/restore@v3
with:
key: workdir-${{ github.sha }}
path: .
# Computer science has only 3 hard problems: naming things,
# cache invaconcurrency, lidation, and off-by-one errors.
- id: hash-sources
run: |
echo "hash=$(find src tests -type f -exec cat '{}' \; | sha512sum | awk '{print $1}')" >> $GITHUB_OUTPUT
shell: bash
- id: cache-pytest
uses: actions/cache@v3
with:
key: pytest-${{ matrix.python-version }}-${{ steps.hash-sources.outputs.hash }}
lookup-only: true
path: pytest.out
- if: steps.cache-pytest.outputs.cache-hit != 'true'
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: pip
- if: steps.cache-pytest.outputs.cache-hit != 'true'
name: Install test infrastructure
run: |
sudo make build-deps
pip install .[psycopg2cffi,test]
USER_SITE=`python -m site --user-site`
mkdir -p "${USER_SITE}"
echo "from psycopg2cffi import compat" > "${USER_SITE}/psycopg2.py"
echo "compat.register()" >> "${USER_SITE}/psycopg2.py"
- if: steps.cache-pytest.outputs.cache-hit != 'true'
uses: pavelzw/pytest-action@v2
with:
custom-arguments: --cov=stuart --report-log=pytest.out