diff --git a/.github/workflows/tox.yml b/.github/workflows/tox.yml index f317fb9..698a043 100644 --- a/.github/workflows/tox.yml +++ b/.github/workflows/tox.yml @@ -33,8 +33,9 @@ jobs: tox test: - name: Run tests + name: Run tests (SQLite) runs-on: ubuntu-latest + strategy: matrix: python: ["3.10", "3.11"] @@ -56,3 +57,39 @@ jobs: run: | pip install tox tox + + test-pg: + name: Run tests (Postgres) + runs-on: ubuntu-latest + strategy: + matrix: + toxenv: [postgres] + env: + TOXENV: py${{ matrix.python }}-django${{ matrix.django }} + + # run postgres tests on GH + services: + postgres: + image: postgres + env: + POSTGRES_PASSWORD: postgres + # Set health checks to wait until postgres has started + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + + steps: + - name: Check out the repository + uses: actions/checkout@v3 + + - name: Set up Python ${{ matrix.python }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python }} + + - name: Install and run tox + run: | + pip install tox + tox diff --git a/tox.ini b/tox.ini index 1c6eb09..e1a8154 100644 --- a/tox.ini +++ b/tox.ini @@ -3,6 +3,7 @@ isolated_build = True envlist = fmt, lint, mypy, django-checks, + postgres, py310-django{32,40,41,42,main} py311-django{32,40,41,42,main} @@ -19,7 +20,17 @@ deps = djangomain: https://github.com/django/django/archive/main.tar.gz commands = - pytest --cov=anonymiser --verbose tests/ + pytest --cov=anonymiser --verbose --ds={env:DJANGO_SETTINGS_MODULE} tests/ + +[testenv:postgres] +deps = + pytest + pytest-django + psycopg2-binary + django + +commands = + pytest --verbose --ds=tests.settings_postgres tests/ [testenv:django-checks] description = Django system checks and missing migrations