-
-
Notifications
You must be signed in to change notification settings - Fork 147
279 lines (221 loc) · 9.3 KB
/
tests.yml
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
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, pytest_opts: "--anyio=asyncio"}
- {impl: python, python: "3.8", postgres: "postgres:12", pytest_opts: ""}
- {impl: python, python: "3.9", postgres: "postgres:13", pytest_opts: "--anyio=trio"}
- {impl: python, python: "3.10", postgres: "postgres:14", pytest_opts: ""}
- {impl: python, python: "3.11", postgres: "postgres:15", libpq: oldest, pytest_opts: ""}
- {impl: c, python: "3.7", postgres: "postgres:15", libpq: newest, pytest_opts: ""}
- {impl: c, python: "3.8", postgres: "postgres:13", pytest_opts: "--anyio=asyncio"}
- {impl: c, python: "3.9", postgres: "postgres:14", pytest_opts: ""}
- {impl: c, python: "3.10", postgres: "postgres:11", libpq: oldest, pytest_opts: "--anyio=trio"}
- {impl: c, python: "3.11", postgres: "postgres:10", libpq: newest, pytest_opts: ""}
- {impl: python, python: "3.9", ext: dns, postgres: "postgres:14", pytest_opts: ""}
- {impl: python, python: "3.9", ext: postgis, postgres: "postgis/postgis", pytest_opts: ""}
# Test with minimum dependencies versions
- {impl: c, python: "3.7", ext: min, postgres: "postgres:15", pytest_opts: ""}
env:
PSYCOPG_IMPL: ${{ matrix.impl }}
DEPS: ./psycopg[test] ./psycopg_pool
PSYCOPG_TEST_DSN: "host=127.0.0.1 user=postgres password=password"
PYTEST_ADDOPTS: ${{ matrix.pytest_opts }}
MARKERS: ""
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
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 dnspython to the packages to install
if: ${{ matrix.ext == 'dns' }}
run: |
echo "DEPS=$DEPS anyio[trio] 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: Configure to use the oldest dependencies
if: ${{ matrix.ext == 'min' }}
run: |
echo "DEPS=$DEPS dnspython shapely" >> $GITHUB_ENV
echo "PIP_CONSTRAINT=${{ github.workspace }}/tests/constraints.txt" \
>> $GITHUB_ENV
- name: Install Python packages
run: pip install $DEPS
- name: Run tests
run: ./tools/build/ci_test.sh
# }}}
macos: # {{{
runs-on: macos-latest
if: true
strategy:
fail-fast: false
matrix:
include:
- {impl: python, python: "3.7", pytest_opts: ""}
- {impl: python, python: "3.8", pytest_opts: "--anyio=asyncio"}
- {impl: python, python: "3.9", pytest_opts: ""}
- {impl: python, python: "3.10", pytest_opts: "--anyio=trio"}
- {impl: python, python: "3.11", pytest_opts: ""}
- {impl: c, python: "3.7", pytest_opts: "--anyio=trio"}
- {impl: c, python: "3.8", pytest_opts: ""}
- {impl: c, python: "3.9", pytest_opts: "--anyio=asyncio"}
- {impl: c, python: "3.10", pytest_opts: ""}
- {impl: c, python: "3.11", pytest_opts: ""}
env:
PSYCOPG_IMPL: ${{ matrix.impl }}
DEPS: ./psycopg[test] ./psycopg_pool
PSYCOPG_TEST_DSN: "host=127.0.0.1 user=runner dbname=postgres"
PYTEST_ADDOPTS: ${{ matrix.pytest_opts }}
# 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"
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
- name: Install PostgreSQL on the runner
run: brew install postgresql@14
- name: Start PostgreSQL service
run: brew services start postgresql
- 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", pytest_opts: "--anyio=asyncio"}
- {impl: python, python: "3.8", pytest_opts: ""}
- {impl: python, python: "3.9", pytest_opts: "--anyio=trio"}
- {impl: python, python: "3.10", pytest_opts: ""}
- {impl: python, python: "3.11", pytest_opts: ""}
- {impl: c, python: "3.7", pytest_opts: ""}
- {impl: c, python: "3.8", pytest_opts: "--anyio=trio"}
- {impl: c, python: "3.9", pytest_opts: ""}
- {impl: c, python: "3.10", pytest_opts: "--anyio=asyncio"}
- {impl: c, python: "3.11", pytest_opts: ""}
env:
PSYCOPG_IMPL: ${{ matrix.impl }}
DEPS: ./psycopg[test] ./psycopg_pool
PSYCOPG_TEST_DSN: "host=127.0.0.1 dbname=postgres"
PYTEST_ADDOPTS: ${{ matrix.pytest_opts }}
# 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@v3
- uses: actions/setup-python@v4
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/*.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-v22.1", python: "3.10", libpq: newest, pytest_opts: "--anyio=trio"}
- {impl: python, crdb: "latest-v22.2", python: "3.11", pytest_opts: ""}
env:
PSYCOPG_IMPL: ${{ matrix.impl }}
DEPS: ./psycopg[test] ./psycopg_pool
PSYCOPG_TEST_DSN: "host=127.0.0.1 port=26257 user=root dbname=defaultdb"
PYTEST_ADDOPTS: ${{ matrix.pytest_opts }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
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
# }}}