Skip to content

chore: bump psycopg package version to 3.1.20.dev1 #225

chore: bump psycopg package version to 3.1.20.dev1

chore: bump psycopg package version to 3.1.20.dev1 #225

name: 3rd party tests
on:
push:
branches:
- "master"
- "maint-3.1"
- "sqlalchemy_pipeline"
- "django_pipeline"
paths-ignore:
- "docs/*"
- "tools/*"
workflow_dispatch:
concurrency:
# Cancel older requests of the same workflow in the same branch.
group: ${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: true
jobs:
sqlalchemy:
# linux should be enough to test if everything works.
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version:
- "3.12"
- "3.8"
sqlalchemy_label:
# what version of sqlalchemy to download is defined in the "include" section below,
# in the variable pip_sqlalchemy
- git_main
- release
impl:
- c
- python
include:
- sqlalchemy_label: git_main
pip_sqlalchemy: git+https://github.com/sqlalchemy/sqlalchemy.git#egg=SQLAlchemy
- sqlalchemy_label: release
pip_sqlalchemy: sqlalchemy>=2
env:
PSYCOPG_IMPL: ${{ matrix.impl }}
DEPS: ./psycopg pytest pytest-xdist greenlet
services:
postgresql:
image: postgres:15
env:
POSTGRES_PASSWORD: password
POSTGRES_DB: test
ports:
- 5432:5432
# Wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Setup PG
env:
PGPASSWORD: password
run: |
psql -AXqte "host=127.0.0.1 dbname=test user=postgres" << HERE
SELECT version();
CREATE SCHEMA test_schema;
CREATE SCHEMA test_schema_2;
CREATE EXTENSION hstore;
HERE
- name: Include psycopg-c to the packages to install
if: ${{ matrix.impl == 'c' }}
run: |
echo "DEPS=$DEPS ./psycopg_c" >> $GITHUB_ENV
- name: Install pycopg packages
run: pip install $DEPS
- name: Setup and install sqlalchemy
run: |
pip download --no-deps --no-binary :all: ${{ matrix.pip_sqlalchemy }}
mkdir sa_home
case $(file --brief --mime-type SQLAlchemy*) in
application/gzip)
tar -C sa_home -xzf SQLAlchemy*
;;
application/zip)
unzip -d sa_home -q SQLAlchemy*
;;
*)
echo "Unexpected format for $(file --mime-type SQLAlchemy*)" >&2
exit 1
;;
esac
mv sa_home/$( ls sa_home ) sa_home/sa
cd sa_home/sa
pip install .
- name: Run sqlalchemy tests
env:
URL: postgresql+psycopg://postgres:password@127.0.0.1/test
working-directory: sa_home/sa
run: pytest -n 2 -q --dburi $URL --backend-only --dropfirst --color=yes --dbdriver psycopg_async
django:
# linux should be enough to test if everything works.
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
django_label:
# what version of django to download is defined in the "include" section below,
# in the variable pip_django
- git_main
- lts
impl:
- c
- python
include:
- django_label: git_main
pip_django: git+https://github.com/django/django.git#egg=Django
# Need pylibmc wheel package to test with Python 3.12.
# https://github.com/lericson/pylibmc/issues/288
python-version: "3.11"
# TODO: Needs updating with new LTS releases, is this something we want?
# Also needs consideration against which python we wanna test.
# Current logic is test oldest in lts and newest in main
- django_label: lts
pip_django: "'Django>=4.2,<4.3'"
python-version: "3.8"
env:
DEPS: ./psycopg psycopg_pool>=3.2
services:
postgresql:
image: postgres:15
env:
POSTGRES_PASSWORD: password
POSTGRES_DB: postgres
ports:
- 5432:5432
# Wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Setup PG
env:
PGPASSWORD: password
run: |
psql -AXqte "host=127.0.0.1 dbname=postgres user=postgres" << HERE
SELECT version();
HERE
- name: Include psycopg-c to the packages to install
if: ${{ matrix.impl == 'c' }}
run: |
echo "DEPS=$DEPS ./psycopg_c" >> $GITHUB_ENV
- name: Install pycopg packages
run: pip install $DEPS
- name: Download and configure Django
run: |
pip download --no-deps --no-binary :all: ${{ matrix.pip_django }}
mkdir django_home
case $(file --brief --mime-type Django*) in
application/gzip)
tar -C django_home -xzf Django*
;;
application/zip)
unzip -d django_home -q Django*
;;
*)
echo "Unexpected format for $(file --mime-type Django*)" >&2
exit 1
;;
esac
mv django_home/$( ls django_home ) django_home/django
cat << HERE > django_home/django/tests/test_postgresql.py
DATABASES = {
"default": {
"ENGINE": "django.db.backends.postgresql",
"HOST": "127.0.0.1",
"USER": "postgres",
"PASSWORD": "password",
},
"other": {
"ENGINE": "django.db.backends.postgresql",
"HOST": "127.0.0.1",
"USER": "postgres",
"PASSWORD": "password",
},
}
SECRET_KEY = "django_tests_secret_key"
# Use a fast hasher to speed up tests.
PASSWORD_HASHERS = [
"django.contrib.auth.hashers.MD5PasswordHasher",
]
DEFAULT_AUTO_FIELD = "django.db.models.AutoField"
USE_TZ = False
HERE
- uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ matrix.python-version }}-pip-${{ hashFiles('django_home/django/tests/requirements/py3.txt', 'django_home/django/setup.cfg') }}
restore-keys: |
${{ matrix.python-version }}-pip-
- name: Install Django and dependencies
working-directory: django_home/django
run: |
pip install .
pip install -r tests/requirements/py3.txt
- name: Run Django tests
working-directory: django_home/django/tests
run: ./runtests.py --settings=test_postgresql postgres_tests backends queries