1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
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
# }}}
|