-
Notifications
You must be signed in to change notification settings - Fork 5
372 lines (359 loc) · 10.5 KB
/
ci.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
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
name: CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
release:
types: [ published ]
jobs:
Merge-Dependabot:
if: github.event_name == 'pull_request'
timeout-minutes: 1
runs-on: ubuntu-latest
permissions:
pull-requests: write
contents: write
steps:
- uses: fastify/[email protected]
with:
merge-method: merge
use-github-auto-merge: true
Verify:
name: 'Verify requirement pinning'
timeout-minutes: 2
runs-on: 'ubuntu-latest'
steps:
- name: Checkout
uses: actions/[email protected]
- name: Setup python
uses: actions/[email protected]
with:
python-version: "3.12"
- name: Install requirements
run: |
python -m pip install -U pip
# Optimistically assume SHA checks won't change much
python -m pip install pip-compile-multi
- name: Verify requirements
run: pip-compile-multi verify
Blacken:
name: 'Formatting and linting'
timeout-minutes: 2
runs-on: 'ubuntu-latest'
steps:
- name: Checkout
uses: actions/[email protected]
- name: Setup python
uses: actions/[email protected]
with:
cache: pip
cache-dependency-path: requirements/lint.txt
python-version: "3.12"
- name: Install requirements
run: |
python -m pip install -U pip
python -m pip install -r requirements/lint.txt
- name: Run Black
id: black
run: black --check --diff trio_parallel _trio_parallel_workers
continue-on-error: true
- name: Run flake8
id: flake8
run: |
flake8 --extend-ignore=D,E,W,F401,F403,F405,F821,F822,TRIO114 \
--extend-select=TRIO900,TRIO910,TRIO911
continue-on-error: true
- name: Fail on error
if: steps.black.outcome != 'success' || steps.flake8.outcome != 'success'
run: exit 1
Build:
name: Build
timeout-minutes: 5
runs-on: ubuntu-latest
outputs:
wheelname: ${{ steps.outputs.outputs.wheelname }}
settings: ${{ steps.outputs.outputs.settings }}
steps:
- name: Checkout
uses: actions/[email protected]
with:
fetch-depth: 0
- name: Setup python
uses: actions/[email protected]
with:
cache: pip
cache-dependency-path: requirements/build.txt
python-version: "3.12"
- name: Install requirements
run: |
python -m pip install -U pip
python -m pip install -r requirements/build.txt
- name: Build sdist wheel
run: |
SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct) \
python -m build --no-isolation # already isolated & build deps pinned
- name: Check distribution
run: |
python -m pip install twine
twine check --strict dist/*
- name: Set outputs
id: outputs
run: |
echo "wheelname=$( echo ./dist/*.whl )" >> $GITHUB_OUTPUT
echo "settings=$(
tar cz \
pyproject.toml \
requirements/install.txt \
requirements/test.txt \
| base64 -w 0
)" >> $GITHUB_OUTPUT
cd dist && sha256sum * >> $GITHUB_STEP_SUMMARY
- name: Upload build artifact
uses: actions/[email protected]
with:
name: Build
# by default build puts sdist and wheel here
path: dist/
if-no-files-found: error
Test:
name: 'Test ${{ matrix.os }} (${{ matrix.python }} ${{ matrix.arch }})'
needs: Build
timeout-minutes: 10
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.experimental }}
strategy:
fail-fast: false
matrix:
experimental: [ false ]
test-timeout: [ 10 ]
os:
- windows-latest
- ubuntu-latest
- macos-latest
python:
- '3.8'
- '3.9'
- '3.10'
- '3.11'
- '3.12'
- 'pypy-3.8'
- 'pypy-3.9'
- 'pypy-3.10'
arch: [ x64 ]
include:
- os: ubuntu-latest
python: 'pypy-3.10-nightly'
arch: x64
experimental: true
test-timeout: 10
# - os: ubuntu-latest
# python: '3.13-dev'
# arch: x64
# experimental: true
# test-timeout: 3
- os: windows-latest
python: '3.8'
arch: x86
experimental: false
test-timeout: 10
exclude:
- os: macos-latest
python: '3.8'
- os: macos-latest
python: 'pypy-3.8'
- os: macos-latest
python: 'pypy-3.9'
steps:
- name: Input settings
run: echo "${{ needs.Build.outputs.settings }}" | base64 -d | tar xz
shell: bash
- name: Setup python
uses: actions/[email protected]
with:
cache: pip
cache-dependency-path: requirements/test.txt
python-version: '${{ matrix.python }}'
architecture: '${{ matrix.arch }}'
- name: Download build artifact
uses: actions/[email protected]
with:
name: Build
path: dist
- name: Install requirements
run: |
python -m pip install -U pip
python -m pip install -r requirements/test.txt
- name: Install wheel
run: |
python -m pip install ${{ needs.Build.outputs.wheelname }} --no-deps
- name: Run tests
timeout-minutes: ${{ matrix.test-timeout }}
run: |
pytest trio_parallel --cov-report xml:coverage-${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.python }}.xml
coverage report
mv .coverage .coverage.${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.python }}
shell: bash
- name: Upload coverage
if: always()
uses: actions/[email protected]
with:
name: Coverage
path: "*coverage*${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.python }}*"
if-no-files-found: error
Examples:
name: 'Test examples ${{ matrix.os }} (${{ matrix.python }} ${{ matrix.arch }})'
timeout-minutes: 10
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- windows-latest
- ubuntu-latest
- macos-latest
python:
- '3.12'
arch:
- x64
steps:
- name: Checkout
uses: actions/[email protected]
- name: Setup python
uses: actions/[email protected]
with:
cache: pip
cache-dependency-path: requirements/test.txt
python-version: '${{ matrix.python }}'
architecture: '${{ matrix.arch }}'
- name: Install requirements
run: |
python -m pip install -U pip
python -m pip install -r requirements/test.txt
- name: Install editable source
run: |
python -m pip install -e . --no-deps
- name: Run tests
run: |
python -m pytest --no-cov docs/source
Extras:
name: 'Test [test] extra'
timeout-minutes: 5
runs-on: ubuntu-latest
needs: Build
steps:
- name: Setup python
uses: actions/[email protected]
with:
python-version: '3.12'
- name: Download build artifact
uses: actions/[email protected]
with:
name: Build
path: dist
- name: Run tests
run: |
python -m pip install ${{ needs.Build.outputs.wheelname }}[test]
pytest --pyargs trio_parallel
Codecov: # Codecov is naughty and will be forever isolated
name: Codecov
if: always()
needs: Test
timeout-minutes: 1
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/[email protected]
- name: Download coverage artifact
uses: actions/[email protected]
with:
name: Coverage
- name: Upload to Codecov
uses: codecov/[email protected]
with:
fail_ci_if_error: true
Coverage:
name: Coverage
if: always()
needs: Test
timeout-minutes: 1
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/[email protected]
- name: Download coverage artifact
uses: actions/[email protected]
with:
name: Coverage
- name: Setup python
uses: actions/[email protected]
with:
cache: pip
cache-dependency-path: requirements/coverage.txt
python-version: "3.12"
- name: Install coverage
run: |
pip install -U pip
pip install -r requirements/coverage.txt
- name: Run coverage
run: |
coverage combine
coverage html
coverage report --fail-under=100 --show-missing --format markdown \
>> $GITHUB_STEP_SUMMARY
- name: Upload report
if: always()
uses: actions/[email protected]
with:
name: Report
path: htmlcov/
if-no-files-found: error
All:
name: All checks and tests
if: always()
timeout-minutes: 1
needs: [ Verify, Blacken, Build, Examples, Test, Extras, Codecov, Coverage ]
runs-on: ubuntu-latest
steps:
- name: Check all needs have passed
uses: re-actors/[email protected]
with:
jobs: ${{ toJSON(needs) }}
Release:
name: Release on PyPI
if: github.event_name == 'release'
needs: All
timeout-minutes: 1
runs-on: ubuntu-latest
environment:
name: release
url: https://pypi.org/p/trio-parallel
permissions:
id-token: write
steps:
- name: Download build artifact
uses: actions/[email protected]
with:
name: Build
path: dist
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
Update:
name: Update GitHub Release
if: github.event_name == 'release'
needs: All
timeout-minutes: 1
runs-on: ubuntu-latest
# permissions:
# contents: write #TODO this should be default but maybe must be set
steps:
- name: Download build artifact
uses: actions/[email protected]
with:
name: Build
path: dist
- name: Upload to GitHub
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release upload ${{ github.ref_name }} dist/* --repo ${{ github.repository }}