-
Notifications
You must be signed in to change notification settings - Fork 137
326 lines (259 loc) · 8.57 KB
/
test.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
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
315
316
317
318
319
320
321
322
323
324
325
326
name: test
on:
push:
branches:
- master
pull_request:
branches:
- master
concurrency:
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
cancel-in-progress: true
env:
STABLE_PYTHON_VERSION: "3.13"
PYTEST_ADDOPTS: --color=yes
HATCH_VERBOSE: "1"
FORCE_COLOR: "1"
jobs:
complete:
name: Test completion check
if: always()
permissions:
contents: none
runs-on: ubuntu-latest
needs:
- test-linux
- test-other
- example
- format
- lint
- typecheck
- spelling
- pre-commit
steps:
- name: Failed
run: exit 1
if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') || contains(needs.*.result, 'skipped')
test-linux:
name: >-
Test Python ${{ matrix.python-version }}
on ${{ startsWith(matrix.os, 'macos-') && 'macOS' || startsWith(matrix.os, 'windows-') && 'Windows' || 'Linux' }}
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.experimental }}
services:
broker:
image: pactfoundation/pact-broker:latest@sha256:05e813c53cbc4d5fadb34a608baaf17348a50c669dc1e3e94dad55e364609912
ports:
- "9292:9292"
env:
# Basic auth credentials for the Broker
PACT_BROKER_ALLOW_PUBLIC_READ: "true"
PACT_BROKER_BASIC_AUTH_USERNAME: pactbroker
PACT_BROKER_BASIC_AUTH_PASSWORD: pactbroker
# Database
PACT_BROKER_DATABASE_URL: sqlite:////tmp/pact_broker.sqlite
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
experimental: [false]
include:
- # Run tests against the next Python version, but no need for the full list of OSes.
os: ubuntu-latest
python-version: "3.14"
experimental: true
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
submodules: true
- name: Apply temporary definitions update
shell: bash
run: |
cd tests/v3/compatibility_suite
patch -p1 -d definition < definition-update.diff
- name: Set up uv
uses: astral-sh/setup-uv@e779db74266a80753577425b0f4ee823649f251d # v3.2.3
with:
enable-cache: true
cache-dependency-glob: |
**/pyproject.toml
**/uv.lock
- name: Install Python
run: uv python install ${{ matrix.python-version }}
- name: Install Hatch
run: uv tool install hatch
- name: Ensure broker is live
run: |
i=0
until curl -sSf http://localhost:9292/diagnostic/status/heartbeat; do
i=$((i+1))
if [ $i -gt 120 ]; then
echo "Broker failed to start"
exit 1
fi
sleep 1
done
- name: Run tests
run: hatch run test --broker-url=http://pactbroker:pactbroker@localhost:9292 --container
- name: Upload coverage
if: matrix.python-version == env.STABLE_PYTHON_VERSION && matrix.os == 'ubuntu-latest'
uses: codecov/codecov-action@968872560f81e7bdde9272853e65f2507c0eca7c # v5.0.0
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: tests
test-other:
name: >-
Test Python ${{ matrix.python-version }}
on ${{ startsWith(matrix.os, 'macos-') && 'macOS' || startsWith(matrix.os, 'windows-') && 'Windows' || 'Linux' }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [windows-latest, macos-latest]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
# Python 3.9 aren't supported on macos-latest (ARM)
exclude:
- os: macos-latest
python-version: "3.9"
include:
- os: macos-13
python-version: "3.9"
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
submodules: true
- name: Apply temporary definitions update
shell: bash
run: |
cd tests/v3/compatibility_suite
patch -p1 -d definition < definition-update.diff
- name: Set up uv
uses: astral-sh/setup-uv@e779db74266a80753577425b0f4ee823649f251d # v3.2.3
with:
enable-cache: true
cache-dependency-glob: |
**/pyproject.toml
**/uv.lock
- name: Install Python
run: uv python install ${{ matrix.python-version }}
- name: Install Hatch
run: uv tool install hatch
- name: Run tests
run: hatch run test
example:
name: Example
runs-on: ubuntu-latest
if: github.event_name == 'push' || ! github.event.pull_request.draft
services:
broker:
image: pactfoundation/pact-broker:latest@sha256:05e813c53cbc4d5fadb34a608baaf17348a50c669dc1e3e94dad55e364609912
ports:
- "9292:9292"
env:
# Basic auth credentials for the Broker
PACT_BROKER_ALLOW_PUBLIC_READ: "true"
PACT_BROKER_BASIC_AUTH_USERNAME: pactbroker
PACT_BROKER_BASIC_AUTH_PASSWORD: pactbroker
# Database
PACT_BROKER_DATABASE_URL: sqlite:////tmp/pact_broker.sqlite
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: Set up uv
uses: astral-sh/setup-uv@e779db74266a80753577425b0f4ee823649f251d # v3.2.3
with:
enable-cache: true
cache-dependency-glob: |
**/pyproject.toml
**/uv.lock
- name: Install Python
run: uv python install ${{ env.STABLE_PYTHON_VERSION }}
- name: Install Hatch
run: uv tool install hatch
- name: Ensure broker is live
run: |
i=0
until curl -sSf http://localhost:9292/diagnostic/status/heartbeat; do
i=$((i+1))
if [ $i -gt 120 ]; then
echo "Broker failed to start"
exit 1
fi
sleep 1
done
- name: Examples
run: >
hatch run example --broker-url=http://pactbroker:pactbroker@localhost:9292
- name: Upload coverage
uses: codecov/codecov-action@968872560f81e7bdde9272853e65f2507c0eca7c # v5.0.0
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: examples
format:
name: Format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: Set up uv
uses: astral-sh/setup-uv@e779db74266a80753577425b0f4ee823649f251d # v3.2.3
with:
enable-cache: true
cache-dependency-glob: |
**/pyproject.toml
**/uv.lock
- name: Install Python
run: uv python install ${{ env.STABLE_PYTHON_VERSION }}
- name: Install Hatch
run: uv tool install hatch
- name: Format
run: hatch run format
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: Set up uv
uses: astral-sh/setup-uv@e779db74266a80753577425b0f4ee823649f251d # v3.2.3
with:
enable-cache: true
cache-dependency-glob: |
**/pyproject.toml
**/uv.lock
- name: Install Python
run: uv python install ${{ env.STABLE_PYTHON_VERSION }}
- name: Install Hatch
run: uv tool install hatch
- name: Format
run: hatch run lint
typecheck:
name: Typecheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: Set up uv
uses: astral-sh/setup-uv@e779db74266a80753577425b0f4ee823649f251d # v3.2.3
with:
enable-cache: true
cache-dependency-glob: |
**/pyproject.toml
**/uv.lock
- name: Install Python
run: uv python install ${{ env.STABLE_PYTHON_VERSION }}
- name: Install Hatch
run: uv tool install hatch
- name: Format
run: hatch run typecheck
spelling:
name: Spell check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: Spell Check Repo
uses: crate-ci/typos@master
pre-commit:
name: Pre-commit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: Run pre-commit
uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1