summaryrefslogtreecommitdiffstats
path: root/.github/workflows/tests.yml
diff options
context:
space:
mode:
Diffstat (limited to '.github/workflows/tests.yml')
-rw-r--r--.github/workflows/tests.yml314
1 files changed, 314 insertions, 0 deletions
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
new file mode 100644
index 0000000..9f6a7f5
--- /dev/null
+++ b/.github/workflows/tests.yml
@@ -0,0 +1,314 @@
+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:12"}
+ - {impl: python, python: "3.9", postgres: "postgres:13"}
+ - {impl: python, python: "3.10", postgres: "postgres:14"}
+ - {impl: python, python: "3.11", postgres: "postgres:15", libpq: oldest}
+
+ - {impl: c, python: "3.7", postgres: "postgres:15", libpq: newest}
+ - {impl: c, python: "3.8", postgres: "postgres:13"}
+ - {impl: c, python: "3.9", postgres: "postgres:14"}
+ - {impl: c, python: "3.10", postgres: "postgres:13", libpq: oldest}
+ - {impl: c, python: "3.11", postgres: "postgres:10", libpq: newest}
+
+ - {impl: python, python: "3.9", ext: dns, postgres: "postgres:14"}
+ - {impl: python, python: "3.9", ext: postgis, postgres: "postgis/postgis"}
+
+ env:
+ PSYCOPG_IMPL: ${{ matrix.impl }}
+ DEPS: ./psycopg[test] ./psycopg_pool
+ PSYCOPG_TEST_DSN: "host=127.0.0.1 user=postgres"
+ PGPASSWORD: password
+ MARKERS: ""
+
+ # Enable to run tests using the minimum version of dependencies.
+ # PIP_CONSTRAINT: ${{ github.workspace }}/tests/constraints.txt
+
+ steps:
+ - uses: actions/checkout@v3
+
+ - uses: actions/setup-python@v4
+ with:
+ python-version: ${{ matrix.python }}
+
+ - name: Install the newest libpq version available
+ if: ${{ matrix.libpq == 'newest' }}
+ run: |
+ set -x
+
+ curl -sL https://www.postgresql.org/media/keys/ACCC4CF8.asc \
+ | gpg --dearmor \
+ | sudo tee /etc/apt/trusted.gpg.d/apt.postgresql.org.gpg > /dev/null
+
+ # NOTE: in order to test with a preview release, add its number to
+ # the deb entry. For instance, to test on preview Postgres 16, use:
+ # "deb http://apt.postgresql.org/pub/repos/apt ${rel}-pgdg main 16"
+ rel=$(lsb_release -c -s)
+ echo "deb http://apt.postgresql.org/pub/repos/apt ${rel}-pgdg main" \
+ | sudo tee -a /etc/apt/sources.list.d/pgdg.list > /dev/null
+ sudo apt-get -qq update
+
+ pqver=$(apt-cache show libpq5 | grep ^Version: | head -1 \
+ | awk '{print $2}')
+ sudo apt-get -qq -y install "libpq-dev=${pqver}" "libpq5=${pqver}"
+
+ - name: Install the oldest libpq version available
+ if: ${{ matrix.libpq == 'oldest' }}
+ run: |
+ set -x
+ pqver=$(apt-cache show libpq5 | grep ^Version: | tail -1 \
+ | awk '{print $2}')
+ sudo apt-get -qq -y --allow-downgrades install \
+ "libpq-dev=${pqver}" "libpq5=${pqver}"
+
+ - if: ${{ matrix.ext == 'dns' }}
+ run: |
+ echo "DEPS=$DEPS dnspython" >> $GITHUB_ENV
+ echo "MARKERS=$MARKERS dns" >> $GITHUB_ENV
+
+ - if: ${{ matrix.ext == 'postgis' }}
+ run: |
+ echo "DEPS=$DEPS shapely" >> $GITHUB_ENV
+ echo "MARKERS=$MARKERS postgis" >> $GITHUB_ENV
+
+ - if: ${{ matrix.impl == 'c' }}
+ run: |
+ echo "DEPS=$DEPS ./psycopg_c" >> $GITHUB_ENV
+
+ - name: Install Python dependencies
+ run: pip install $DEPS
+
+ - name: Run tests
+ run: ./tools/build/ci_test.sh
+
+ services:
+ postgresql:
+ image: ${{ matrix.postgres }}
+ env:
+ POSTGRES_PASSWORD: password
+ ports:
+ - 5432:5432
+ # Set health checks to wait until postgres has started
+ options: >-
+ --health-cmd pg_isready
+ --health-interval 10s
+ --health-timeout 5s
+ --health-retries 5
+
+
+ # }}}
+
+ macos: # {{{
+ runs-on: macos-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: c, python: "3.7"}
+ - {impl: c, python: "3.8"}
+ - {impl: c, python: "3.9"}
+ - {impl: c, python: "3.10"}
+ - {impl: c, python: "3.11"}
+
+ 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"
+ # PIP_CONSTRAINT: ${{ github.workspace }}/tests/constraints.txt
+
+ steps:
+ - uses: actions/checkout@v3
+
+ - name: Install PostgreSQL on the runner
+ run: brew install postgresql@14
+
+ - name: Start PostgreSQL service for test
+ run: brew services start postgresql
+
+ - uses: actions/setup-python@v4
+ with:
+ python-version: ${{ matrix.python }}
+
+ - if: ${{ matrix.impl == 'c' }}
+ # skip tests failing on importing psycopg_c.pq on subprocess
+ # they only fail on Travis, work ok locally under tox too.
+ # TODO: check the same on GitHub Actions
+ run: |
+ echo "DEPS=$DEPS ./psycopg_c" >> $GITHUB_ENV
+
+ - name: Install Python dependencies
+ 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: c, python: "3.7"}
+ - {impl: c, python: "3.8"}
+ - {impl: c, python: "3.9"}
+ - {impl: c, python: "3.10"}
+ - {impl: c, python: "3.11"}
+
+ 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"
+ # PIP_CONSTRAINT: ${{ github.workspace }}/tests/constraints.txt
+
+ steps:
+ - uses: actions/checkout@v3
+
+ - name: Start PostgreSQL service for test
+ run: |
+ $PgSvc = Get-Service "postgresql*"
+ Set-Service $PgSvc.Name -StartupType manual
+ $PgSvc.Start()
+
+ - uses: actions/setup-python@v4
+ with:
+ python-version: ${{ matrix.python }}
+
+ # Build a wheel package of the C extensions.
+ # If the wheel is not delocated, import fails with some dll not found
+ # (but it won't tell which one).
+ - name: Build the C wheel
+ if: ${{ matrix.impl == 'c' }}
+ run: |
+ pip install delvewheel wheel
+ $env:Path = "C:\Program Files\PostgreSQL\14\bin\;$env:Path"
+ python ./psycopg_c/setup.py bdist_wheel
+ &"delvewheel" repair `
+ --no-mangle "libiconv-2.dll;libwinpthread-1.dll" `
+ @(Get-ChildItem psycopg_c\dist\*.whl)
+ &"pip" install @(Get-ChildItem wheelhouse\*.whl)
+
+ - name: Run tests
+ run: |
+ pip install $DEPS
+ ./tools/build/ci_test.sh
+ shell: bash
+
+
+ # }}}
+
+ crdb: # {{{
+ runs-on: ubuntu-latest
+ if: true
+
+ strategy:
+ fail-fast: false
+ matrix:
+ include:
+ - {impl: c, crdb: "latest-v22.1", python: "3.10", libpq: newest}
+ - {impl: python, crdb: "latest-v22.2", python: "3.11"}
+ 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@v3
+
+ - uses: actions/setup-python@v4
+ with:
+ python-version: ${{ matrix.python }}
+
+ - name: Run CockroachDB
+ # 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 newest libpq version available
+ if: ${{ matrix.libpq == 'newest' }}
+ run: |
+ set -x
+
+ curl -sL https://www.postgresql.org/media/keys/ACCC4CF8.asc \
+ | gpg --dearmor \
+ | sudo tee /etc/apt/trusted.gpg.d/apt.postgresql.org.gpg > /dev/null
+
+ # NOTE: in order to test with a preview release, add its number to
+ # the deb entry. For instance, to test on preview Postgres 16, use:
+ # "deb http://apt.postgresql.org/pub/repos/apt ${rel}-pgdg main 16"
+ rel=$(lsb_release -c -s)
+ echo "deb http://apt.postgresql.org/pub/repos/apt ${rel}-pgdg main" \
+ | sudo tee -a /etc/apt/sources.list.d/pgdg.list > /dev/null
+ sudo apt-get -qq update
+
+ pqver=$(apt-cache show libpq5 | grep ^Version: | head -1 \
+ | awk '{print $2}')
+ sudo apt-get -qq -y install "libpq-dev=${pqver}" "libpq5=${pqver}"
+
+ - if: ${{ matrix.impl == 'c' }}
+ run: |
+ echo "DEPS=$DEPS ./psycopg_c" >> $GITHUB_ENV
+
+ - name: Install Python dependencies
+ run: pip install $DEPS
+
+ - name: Run tests
+ run: ./tools/build/ci_test.sh
+
+ - name: Stop CockroachDB
+ run: docker kill crdb
+
+
+ # }}}