Skip to content

Commit

Permalink
Add PG to GH actions
Browse files Browse the repository at this point in the history
  • Loading branch information
hugorodgerbrown committed Sep 18, 2023
1 parent 2a3efbb commit 41cb067
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 2 deletions.
39 changes: 38 additions & 1 deletion .github/workflows/tox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand All @@ -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
13 changes: 12 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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}

Expand All @@ -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
Expand Down

0 comments on commit 41cb067

Please sign in to comment.