Skip to content

Commit a535a29

Browse files
authored
Run tests against multiple PostgreSQL versions
* Run tests against multiple PostgreSQL versions, closes #139
1 parent 2fd0967 commit a535a29

3 files changed

Lines changed: 29 additions & 1 deletion

File tree

.github/workflows/publish.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ jobs:
1010
strategy:
1111
matrix:
1212
python-version: [3.6, 3.7, 3.8, 3.9]
13+
postgresql-version: [10, 11, 12, 13]
1314
steps:
1415
- uses: actions/checkout@v2
1516
- name: Set up Python ${{ matrix.python-version }}
@@ -23,11 +24,23 @@ jobs:
2324
key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.py') }}
2425
restore-keys: |
2526
${{ runner.os }}-pip-
27+
- name: Install PostgreSQL
28+
env:
29+
POSTGRESQL_VERSION: ${{ matrix.postgresql-version }}
30+
run: |
31+
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
32+
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
33+
sudo apt-get update
34+
sudo apt-get -y install "postgresql-$POSTGRESQL_VERSION"
2635
- name: Install dependencies
2736
run: |
2837
pip install -e '.[test]'
2938
- name: Run tests
39+
env:
40+
POSTGRESQL_VERSION: ${{ matrix.postgresql-version }}
3041
run: |
42+
export POSTGRESQL_PATH="/usr/lib/postgresql/$POSTGRESQL_VERSION/bin/postgres"
43+
export INITDB_PATH="/usr/lib/postgresql/$POSTGRESQL_VERSION/bin/initdb"
3144
pytest
3245
deploy:
3346
runs-on: ubuntu-latest

.github/workflows/test.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ jobs:
88
strategy:
99
matrix:
1010
python-version: [3.6, 3.7, 3.8, 3.9]
11+
postgresql-version: [10, 11, 12, 13]
1112
steps:
1213
- uses: actions/checkout@v2
1314
- name: Set up Python ${{ matrix.python-version }}
@@ -21,11 +22,23 @@ jobs:
2122
key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.py') }}
2223
restore-keys: |
2324
${{ runner.os }}-pip-
25+
- name: Install PostgreSQL
26+
env:
27+
POSTGRESQL_VERSION: ${{ matrix.postgresql-version }}
28+
run: |
29+
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
30+
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
31+
sudo apt-get update
32+
sudo apt-get -y install "postgresql-$POSTGRESQL_VERSION"
2433
- name: Install dependencies
2534
run: |
2635
pip install -e '.[test]'
2736
- name: Run tests
37+
env:
38+
POSTGRESQL_VERSION: ${{ matrix.postgresql-version }}
2839
run: |
40+
export POSTGRESQL_PATH="/usr/lib/postgresql/$POSTGRESQL_VERSION/bin/postgres"
41+
export INITDB_PATH="/usr/lib/postgresql/$POSTGRESQL_VERSION/bin/initdb"
2942
pytest
3043
- name: Check formatting
3144
run: black . --check

pytest_use_postgresql.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
from django.conf import settings
66
from testing.postgresql import Postgresql
77

8-
_POSTGRESQL = Postgresql()
8+
postgres = os.environ.get("POSTGRESQL_PATH")
9+
initdb = os.environ.get("INITDB_PATH")
10+
_POSTGRESQL = Postgresql(postgres=postgres, initdb=initdb)
911

1012

1113
@pytest.hookimpl(tryfirst=True)

0 commit comments

Comments
 (0)