fix: use the simple query protocol to execute BEGIN/COMMIT out of pip… #4474
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Tests | |
on: | |
push: | |
# This should disable running the workflow on tags, according to the | |
# on.<push|pull_request>.<branches|tags> GitHub Actions docs. | |
branches: | |
- "*" | |
pull_request: | |
schedule: | |
- cron: '48 6 * * *' | |
concurrency: | |
# Cancel older requests of the same workflow in the same branch. | |
group: ${{ github.workflow }}-${{ github.ref_name }} | |
cancel-in-progress: true | |
jobs: | |
linux: # {{{ | |
runs-on: ubuntu-latest | |
if: true | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
# Test different combinations of Python, Postgres, libpq. | |
- {impl: python, python: "3.7", postgres: "postgres:10", libpq: newest} | |
- {impl: python, python: "3.8", postgres: "postgres:11"} | |
- {impl: python, python: "3.9", postgres: "postgres:13"} | |
- {impl: python, python: "3.10", postgres: "postgres:14"} | |
- {impl: python, python: "3.11", postgres: "postgres:15"} | |
- {impl: python, python: "3.12", postgres: "postgres:16", libpq: oldest} | |
- {impl: c, python: "3.7", postgres: "postgres:16", libpq: newest} | |
- {impl: c, python: "3.8", postgres: "postgres:14"} | |
- {impl: c, python: "3.9", postgres: "postgres:15"} | |
- {impl: c, python: "3.10", postgres: "postgres:13"} | |
- {impl: c, python: "3.11", postgres: "postgres:12", libpq: oldest} | |
- {impl: c, python: "3.12", postgres: "postgres:10", libpq: newest} | |
- {impl: python, python: "3.8", ext: gevent, postgres: "postgres:16"} | |
- {impl: c, python: "3.12", ext: gevent, postgres: "postgres:14"} | |
- {impl: python, python: "3.9", ext: dns, postgres: "postgres:14"} | |
- {impl: python, python: "3.9", ext: postgis, postgres: "postgis/postgis"} | |
# Test with minimum dependencies versions | |
- {impl: c, python: "3.7", ext: min, postgres: "postgres:15"} | |
# Test memory alignment | |
- {impl: c, python: "3.12", ext: align, postgres: "postgres:16"} | |
# Test with PyPy. | |
- {impl: python, python: "pypy3.9", postgres: "postgres:13"} | |
- {impl: python, python: "pypy3.10", postgres: "postgres:14"} | |
env: | |
PSYCOPG_IMPL: ${{ matrix.impl }} | |
DEPS: ./psycopg[test] ./psycopg_pool | |
PSYCOPG_TEST_DSN: "host=127.0.0.1 user=postgres password=password" | |
MARKERS: "" | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python }} | |
- name: Start PostgreSQL service | |
# Note: this would love to be a service, but I don't see a way to pass | |
# the args to the docker run command line. | |
run: | | |
docker pull ${{ matrix.postgres }} | |
docker run --rm -d --name postgres -p 5432:5432 \ | |
-e POSTGRES_PASSWORD=password ${{ matrix.postgres }} \ | |
-c max_prepared_transactions=10 | |
- name: Install the wanted libpq version | |
run: sudo ./tools/build/ci_install_libpq.sh ${{ matrix.libpq }} | |
- name: Include psycopg-c to the packages to install | |
if: ${{ matrix.impl == 'c' }} | |
run: | | |
echo "DEPS=$DEPS ./psycopg_c" >> $GITHUB_ENV | |
- name: Include gevent to the packages to install | |
if: ${{ matrix.ext == 'gevent' }} | |
run: | | |
echo "DEPS=$DEPS gevent" >> $GITHUB_ENV | |
echo "MARKERS=$MARKERS gevent" >> $GITHUB_ENV | |
- name: Include dnspython to the packages to install | |
if: ${{ matrix.ext == 'dns' }} | |
run: | | |
echo "DEPS=$DEPS dnspython" >> $GITHUB_ENV | |
echo "MARKERS=$MARKERS dns" >> $GITHUB_ENV | |
- name: Include shapely to the packages to install | |
if: ${{ matrix.ext == 'postgis' }} | |
run: | | |
echo "DEPS=$DEPS shapely" >> $GITHUB_ENV | |
echo "MARKERS=$MARKERS postgis" >> $GITHUB_ENV | |
- name: Exclude certain tests from pypy | |
if: ${{ startsWith(matrix.python, 'pypy') }} | |
run: | | |
echo "NOT_MARKERS=$NOT_MARKERS timing" >> $GITHUB_ENV | |
- name: Configure to use the oldest dependencies | |
if: ${{ matrix.ext == 'min' }} | |
run: | | |
echo "DEPS=$DEPS dnspython shapely gevent" >> $GITHUB_ENV | |
echo "PIP_CONSTRAINT=${{ github.workspace }}/tests/constraints.txt" \ | |
>> $GITHUB_ENV | |
- name: Configure memory alignment tests | |
if: ${{ matrix.ext == 'align' }} | |
run: | | |
echo "CFLAGS=-fsanitize=undefined" >> $GITHUB_ENV | |
echo "UBSAN_OPTIONS=halt_on_error=1" >> $GITHUB_ENV | |
echo "PYTEST_ADDOPTS=-v" >> $GITHUB_ENV | |
- name: Install Python packages | |
run: pip install $DEPS | |
- name: Run tests | |
run: ./tools/build/ci_test.sh | |
# }}} | |
macos-14: # {{{ | |
runs-on: macos-14 | |
if: true | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- {impl: python, python: "3.10"} | |
- {impl: python, python: "3.11"} | |
- {impl: python, python: "3.12"} | |
- {impl: c, python: "3.10"} | |
- {impl: c, python: "3.11"} | |
- {impl: c, python: "3.12"} | |
env: | |
PSYCOPG_IMPL: ${{ matrix.impl }} | |
DEPS: ./psycopg[test] ./psycopg_pool | |
PSYCOPG_TEST_DSN: "host=127.0.0.1 user=runner dbname=postgres" | |
# MacOS on GitHub Actions seems particularly slow. | |
# Don't run timing-based tests as they regularly fail. | |
# pproxy-based tests fail too, with the proxy not coming up in 2s. | |
NOT_MARKERS: "timing proxy mypy" | |
PG_VERSION: "16" | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python }} | |
- name: Install PostgreSQL on the runner | |
run: brew install postgresql@${PG_VERSION} | |
- name: Start PostgreSQL service | |
run: brew services start postgresql@${PG_VERSION} | |
- name: Find the libpq | |
if: ${{ matrix.impl == 'python' }} | |
run: | | |
echo "DYLD_LIBRARY_PATH=/opt/homebrew/opt/postgresql@${PG_VERSION}/lib:$DYLD_LIBRARY_PATH" >> $GITHUB_ENV | |
- name: Include psycopg-c to the packages to install | |
if: ${{ matrix.impl == 'c' }} | |
run: | | |
echo "DEPS=$DEPS ./psycopg_c" >> $GITHUB_ENV | |
echo "PATH=/opt/homebrew/opt/postgresql@${PG_VERSION}/bin:$PATH" >> $GITHUB_ENV | |
- name: Install Python packages | |
run: pip install $DEPS | |
- name: Run tests | |
run: ./tools/build/ci_test.sh | |
# }}} | |
macos-12: # {{{ | |
runs-on: macos-12 | |
if: true | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- {impl: python, python: "3.7"} | |
- {impl: python, python: "3.8"} | |
- {impl: python, python: "3.9"} | |
- {impl: c, python: "3.7"} | |
- {impl: c, python: "3.8"} | |
- {impl: c, python: "3.9"} | |
env: | |
PSYCOPG_IMPL: ${{ matrix.impl }} | |
DEPS: ./psycopg[test] ./psycopg_pool | |
PSYCOPG_TEST_DSN: "host=127.0.0.1 user=runner dbname=postgres" | |
# MacOS on GitHub Actions seems particularly slow. | |
# Don't run timing-based tests as they regularly fail. | |
# pproxy-based tests fail too, with the proxy not coming up in 2s. | |
NOT_MARKERS: "timing proxy mypy" | |
PG_VERSION: "16" | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python }} | |
- name: Install PostgreSQL on the runner | |
run: brew install postgresql@${PG_VERSION} | |
- name: Start PostgreSQL service | |
run: brew services start postgresql@${PG_VERSION} | |
- name: Include psycopg-c to the packages to install | |
if: ${{ matrix.impl == 'c' }} | |
run: | | |
echo "DEPS=$DEPS ./psycopg_c" >> $GITHUB_ENV | |
- name: Install Python packages | |
run: pip install $DEPS | |
- name: Run tests | |
run: ./tools/build/ci_test.sh | |
# }}} | |
windows: # {{{ | |
runs-on: windows-latest | |
if: true | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- {impl: python, python: "3.7"} | |
- {impl: python, python: "3.8"} | |
- {impl: python, python: "3.9"} | |
- {impl: python, python: "3.10"} | |
- {impl: python, python: "3.11"} | |
- {impl: python, python: "3.12"} | |
- {impl: c, python: "3.7"} | |
- {impl: c, python: "3.8"} | |
- {impl: c, python: "3.9"} | |
- {impl: c, python: "3.10"} | |
- {impl: c, python: "3.11"} | |
- {impl: c, python: "3.12"} | |
env: | |
PSYCOPG_IMPL: ${{ matrix.impl }} | |
DEPS: ./psycopg[test] ./psycopg_pool | |
PSYCOPG_TEST_DSN: "host=127.0.0.1 dbname=postgres" | |
# On windows pproxy doesn't seem very happy. Also a few timing test fail. | |
NOT_MARKERS: "timing proxy mypy" | |
defaults: | |
run: | |
shell: bash | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python }} | |
- name: Start PostgreSQL service | |
run: | | |
$PgSvc = Get-Service "postgresql*" | |
Set-Service $PgSvc.Name -StartupType manual | |
$PgSvc.Start() | |
shell: pwsh | |
- name: Build the C wheel | |
if: ${{ matrix.impl == 'c' }} | |
run: | | |
pip install delvewheel wheel | |
# The windows runner is a total mess, with random copies of the libpq | |
# scattered all over the places. Give precedence to the one under our | |
# control (or the illusion of it). | |
export PATH="/c/Program Files/PostgreSQL/14/bin/:$PATH" | |
# If the wheel is not delocated, import fails with some dll not found | |
# (but it won't tell which one). | |
pip wheel -v -w ./psycopg_c/dist/ ./psycopg_c/ | |
delvewheel repair --no-mangle "libiconv-2.dll;libwinpthread-1.dll" \ | |
-w ./wheelhouse/ psycopg_c/dist/psycopg*.whl | |
echo "DEPS=$DEPS $(ls ./wheelhouse/*.whl)" >> $GITHUB_ENV | |
- name: Install Python packages | |
run: pip install $DEPS | |
- name: Run tests | |
run: ./tools/build/ci_test.sh | |
# }}} | |
crdb: # {{{ | |
runs-on: ubuntu-latest | |
if: true | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- {impl: c, crdb: "latest-v23.1", python: "3.10", libpq: newest} | |
- {impl: python, crdb: "latest-v22.2", python: "3.12"} | |
env: | |
PSYCOPG_IMPL: ${{ matrix.impl }} | |
DEPS: ./psycopg[test] ./psycopg_pool | |
PSYCOPG_TEST_DSN: "host=127.0.0.1 port=26257 user=root dbname=defaultdb" | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python }} | |
- name: Start CockroachDB service | |
# Note: this would love to be a service, but I don't see a way to pass | |
# the args to the docker run command line. | |
run: | | |
docker pull cockroachdb/cockroach:${{ matrix.crdb }} | |
docker run --rm -d --name crdb -p 26257:26257 \ | |
cockroachdb/cockroach:${{ matrix.crdb }} start-single-node --insecure | |
- name: Install the wanted libpq version | |
run: sudo ./tools/build/ci_install_libpq.sh ${{ matrix.libpq }} | |
- name: Include psycopg-c to the packages to install | |
if: ${{ matrix.impl == 'c' }} | |
run: | | |
echo "DEPS=$DEPS ./psycopg_c" >> $GITHUB_ENV | |
- name: Install Python packages | |
run: pip install $DEPS | |
- name: Run tests | |
run: ./tools/build/ci_test.sh | |
# }}} |