@@ -14,9 +14,133 @@ concurrency:
14
14
group : ${{ github.ref }}-${{ github.workflow }}-${{ github.event_name }}${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) && format('-{0}', github.sha) || '' }}
15
15
cancel-in-progress : true
16
16
17
+ env :
18
+ dists-artifact-name : python-package-distributions
19
+ dist-name : trio
20
+
17
21
jobs :
22
+ build :
23
+ name : 👷 dists
24
+
25
+ runs-on : ubuntu-latest
26
+
27
+ outputs :
28
+ dist-version : ${{ steps.dist-version.outputs.version }}
29
+ sdist-artifact-name : ${{ steps.artifact-name.outputs.sdist }}
30
+ wheel-artifact-name : ${{ steps.artifact-name.outputs.wheel }}
31
+
32
+ steps :
33
+ - name : Switch to using Python 3.11
34
+ uses : actions/setup-python@v5
35
+ with :
36
+ python-version : 3.11
37
+
38
+ - name : Grab the source from Git
39
+ uses : actions/checkout@v4
40
+
41
+ - name : Get the dist version
42
+ id : dist-version
43
+ run : >-
44
+ echo "version=$(
45
+ grep ^__version__ src/trio/_version.py
46
+ | sed 's#__version__ = "\([^"]\+\)"#\1#'
47
+ )"
48
+ >> "${GITHUB_OUTPUT}"
49
+
50
+ - name : Set the expected dist artifact names
51
+ id : artifact-name
52
+ run : |
53
+ echo 'sdist=${{ env.dist-name }}-*.tar.gz' >> "${GITHUB_OUTPUT}"
54
+ echo 'wheel=${{
55
+ env.dist-name
56
+ }}-*-py3-none-any.whl' >> "${GITHUB_OUTPUT}"
57
+
58
+ - name : Install build
59
+ run : python -Im pip install build
60
+
61
+ - name : Build dists
62
+ run : python -Im build
63
+ - name : Verify that the artifacts with expected names got created
64
+ run : >-
65
+ ls -1
66
+ dist/${{ steps.artifact-name.outputs.sdist }}
67
+ dist/${{ steps.artifact-name.outputs.wheel }}
68
+ - name : Store the distribution packages
69
+ uses : actions/upload-artifact@v4
70
+ with :
71
+ name : ${{ env.dists-artifact-name }}
72
+ # NOTE: Exact expected file names are specified here
73
+ # NOTE: as a safety measure — if anything weird ends
74
+ # NOTE: up being in this dir or not all dists will be
75
+ # NOTE: produced, this will fail the workflow.
76
+ path : |
77
+ dist/${{ steps.artifact-name.outputs.sdist }}
78
+ dist/${{ steps.artifact-name.outputs.wheel }}
79
+ retention-days : 5
80
+
81
+ - name : >-
82
+ Smoke-test:
83
+ retrieve the project source from an sdist inside the GHA artifact
84
+ uses: re-actors/checkout-python-sdist@release/v2
85
+ with:
86
+ source-tarball-name: ${{ steps.artifact-name.outputs.sdist }}
87
+ workflow-artifact-name: ${{ env.dists-artifact-name }}
88
+
89
+ - name : >-
90
+ Smoke-test: move the sdist-retrieved dir into sdist-src
91
+ run: |
92
+ mv -v '${{ github.workspace }}' '${{ runner.temp }}/sdist-src'
93
+ mkdir -pv '${{ github.workspace }}'
94
+ mv -v '${{ runner.temp }}/sdist-src' '${{ github.workspace }}/sdist-src'
95
+ shell: bash -eEuo pipefail {0}
96
+
97
+ - name : >-
98
+ Smoke-test: grab the source from Git into git-src
99
+ uses: actions/checkout@v4
100
+ with:
101
+ path: git-src
102
+
103
+ - name : >-
104
+ Smoke-test: install test requirements from the Git repo
105
+ run: >-
106
+ python -Im
107
+ pip install -c test-requirements.txt -r test-requirements.txt
108
+ shell: bash -eEuo pipefail {0}
109
+ working-directory: git-src
110
+
111
+ - name : >-
112
+ Smoke-test: collect tests from the Git repo
113
+ env:
114
+ PYTHONPATH: src/
115
+ run: >-
116
+ pytest --collect-only -qq .
117
+ | sort
118
+ | tee collected-tests
119
+ shell: bash -eEuo pipefail {0}
120
+ working-directory: git-src
121
+
122
+ - name : >-
123
+ Smoke-test: collect tests from the sdist tarball
124
+ env:
125
+ PYTHONPATH: src/
126
+ run: >-
127
+ pytest --collect-only -qq .
128
+ | sort
129
+ | tee collected-tests
130
+ shell: bash -eEuo pipefail {0}
131
+ working-directory: sdist-src
132
+
133
+ - name : >-
134
+ Smoke-test:
135
+ verify that all the tests from Git are included in the sdist
136
+ run: diff --unified sdist-src/collected-tests git-src/collected-tests
137
+ shell: bash -eEuo pipefail {0}
138
+
18
139
Windows :
19
140
name : ' Windows (${{ matrix.python }}, ${{ matrix.arch }}${{ matrix.extra_name }})'
141
+ needs :
142
+ - build
143
+
20
144
timeout-minutes : 20
21
145
runs-on : ' windows-latest'
22
146
strategy :
@@ -58,10 +182,11 @@ jobs:
58
182
|| false
59
183
}}
60
184
steps :
61
- - name : Checkout
62
- uses : actions /checkout@v4
185
+ - name : Retrieve the project source from an sdist inside the GHA artifact
186
+ uses : re-actors /checkout-python-sdist@release/v2
63
187
with :
64
- persist-credentials : false
188
+ source-tarball-name : ${{ needs.build.outputs.sdist-artifact-name }}
189
+ workflow-artifact-name : ${{ env.dists-artifact-name }}
65
190
- name : Setup python
66
191
uses : actions/setup-python@v5
67
192
with :
@@ -87,12 +212,18 @@ jobs:
87
212
uses : codecov/codecov-action@v3
88
213
with :
89
214
directory : empty
90
- token : 87cefb17-c44b-4f2f-8b30-1fff5769ce46
91
215
name : Windows (${{ matrix.python }}, ${{ matrix.arch }}${{ matrix.extra_name }})
216
+ # multiple flags is marked as an error in codecov UI, but is actually fine
217
+ # https://github.com/codecov/feedback/issues/567
92
218
flags : Windows,${{ matrix.python }}
219
+ # this option cannot be set in .codecov.yml
220
+ fail_ci_if_error : true
93
221
94
222
Ubuntu :
95
223
name : ' Ubuntu (${{ matrix.python }}${{ matrix.extra_name }})'
224
+ needs :
225
+ - build
226
+
96
227
timeout-minutes : 10
97
228
runs-on : ' ubuntu-latest'
98
229
strategy :
@@ -120,7 +251,14 @@ jobs:
120
251
|| false
121
252
}}
122
253
steps :
123
- - name : Checkout
254
+ - name : Retrieve the project source from an sdist inside the GHA artifact
255
+ if : matrix.check_formatting != '1'
256
+ uses : re-actors/checkout-python-sdist@release/v2
257
+ with :
258
+ source-tarball-name : ${{ needs.build.outputs.sdist-artifact-name }}
259
+ workflow-artifact-name : ${{ env.dists-artifact-name }}
260
+ - name : Grab the source from Git
261
+ if : matrix.check_formatting == '1'
124
262
uses : actions/checkout@v4
125
263
with :
126
264
persist-credentials : false
@@ -135,16 +273,21 @@ jobs:
135
273
env :
136
274
CHECK_FORMATTING : ' ${{ matrix.check_formatting }}'
137
275
NO_TEST_REQUIREMENTS : ' ${{ matrix.no_test_requirements }}'
138
- - if : always()
276
+ - if : >-
277
+ always()
278
+ && matrix.check_formatting != '1'
139
279
uses: codecov/codecov-action@v3
140
280
with:
141
281
directory: empty
142
- token : 87cefb17-c44b-4f2f-8b30-1fff5769ce46
143
282
name: Ubuntu (${{ matrix.python }}${{ matrix.extra_name }})
144
283
flags: Ubuntu,${{ matrix.python }}
284
+ fail_ci_if_error: true
145
285
146
286
macOS :
147
287
name : ' macOS (${{ matrix.python }})'
288
+ needs :
289
+ - build
290
+
148
291
timeout-minutes : 15
149
292
runs-on : ' macos-latest'
150
293
strategy :
@@ -161,10 +304,11 @@ jobs:
161
304
|| false
162
305
}}
163
306
steps :
164
- - name : Checkout
165
- uses : actions /checkout@v4
307
+ - name : Retrieve the project source from an sdist inside the GHA artifact
308
+ uses : re-actors /checkout-python-sdist@release/v2
166
309
with :
167
- persist-credentials : false
310
+ source-tarball-name : ${{ needs.build.outputs.sdist-artifact-name }}
311
+ workflow-artifact-name : ${{ env.dists-artifact-name }}
168
312
- name : Setup python
169
313
uses : actions/setup-python@v5
170
314
with :
@@ -177,40 +321,51 @@ jobs:
177
321
uses : codecov/codecov-action@v3
178
322
with :
179
323
directory : empty
180
- token : 87cefb17-c44b-4f2f-8b30-1fff5769ce46
181
324
name : macOS (${{ matrix.python }})
182
325
flags : macOS,${{ matrix.python }}
326
+ fail_ci_if_error : true
183
327
184
328
# run CI on a musl linux
185
329
Alpine :
186
330
name : " Alpine"
331
+ needs :
332
+ - build
333
+
187
334
runs-on : ubuntu-latest
188
335
container : alpine
189
336
steps :
190
- - name : Checkout
191
- uses : actions/checkout@v4
192
- with :
193
- persist-credentials : false
194
337
- name : Install necessary packages
195
338
# can't use setup-python because that python doesn't seem to work;
196
339
# `python3-dev` (rather than `python:alpine`) for some ctypes reason,
197
340
# `nodejs` for pyright (`node-env` pulls in nodejs but that takes a while and can time out the test).
198
341
# `perl` for a platform independent `sed -i` alternative
199
342
run : apk update && apk add python3-dev bash nodejs perl
343
+ - name : Retrieve the project source from an sdist inside the GHA artifact
344
+ # must be after `apk add` because it relies on `bash` existing
345
+ uses : re-actors/checkout-python-sdist@release/v2
346
+ with :
347
+ source-tarball-name : ${{ needs.build.outputs.sdist-artifact-name }}
348
+ workflow-artifact-name : ${{ env.dists-artifact-name }}
200
349
- name : Enter virtual environment
201
350
run : python -m venv .venv
202
351
- name : Run tests
203
352
run : source .venv/bin/activate && ./ci.sh
353
+ - name : Get Python version for codecov flag
354
+ id : get-version
355
+ run : echo "version=$(python -V | cut -d' ' -f2 | cut -d'.' -f1,2)" >> "${GITHUB_OUTPUT}"
204
356
- if : always()
205
357
uses : codecov/codecov-action@v3
206
358
with :
207
359
directory : empty
208
- token : 87cefb17-c44b-4f2f-8b30-1fff5769ce46
209
360
name : Alpine
210
- flags : Alpine,3.12
361
+ flags : Alpine,${{ steps.get-version.outputs.version }}
362
+ fail_ci_if_error : true
211
363
212
364
Cython :
213
365
name : " Cython"
366
+ needs :
367
+ - build
368
+
214
369
runs-on : ubuntu-latest
215
370
strategy :
216
371
fail-fast : false
@@ -225,26 +380,46 @@ jobs:
225
380
- python : ' 3.13' # We support running cython3 on 3.13
226
381
cython : ' >=3' # cython 3 (or greater)
227
382
steps :
228
- - name : Checkout
229
- uses : actions /checkout@v4
383
+ - name : Retrieve the project source from an sdist inside the GHA artifact
384
+ uses : re-actors /checkout-python-sdist@release/v2
230
385
with :
231
- persist-credentials : false
386
+ source-tarball-name : ${{ needs.build.outputs.sdist-artifact-name }}
387
+ workflow-artifact-name : ${{ env.dists-artifact-name }}
232
388
- name : Setup python
233
389
uses : actions/setup-python@v5
234
390
with :
235
391
python-version : ' ${{ matrix.python }}'
236
392
cache : pip
237
393
# setuptools is needed to get distutils on 3.12, which cythonize requires
238
394
- name : install trio and setuptools
239
- run : python -m pip install --upgrade pip . setuptools
395
+ run : python -m pip install --upgrade pip . setuptools 'coverage[toml]'
396
+
397
+ - name : add cython plugin to the coveragepy config
398
+ run : >-
399
+ sed -i 's#plugins\s=\s\[\]#plugins = ["Cython.Coverage"]#'
400
+ pyproject.toml
240
401
241
402
- name : install cython & compile pyx file
403
+ env :
404
+ CFLAGS : ${{ env.CFLAGS }} -DCYTHON_TRACE_NOGIL=1
242
405
run : |
243
406
python -m pip install "cython${{ matrix.cython }}"
244
- cythonize --inplace tests/cython/test_cython.pyx
407
+ cythonize --inplace -X linetrace=True tests/cython/test_cython.pyx
245
408
246
409
- name : import & run module
247
- run : python -c 'import tests.cython.test_cython'
410
+ run : coverage run -m tests.cython.run_test_cython
411
+
412
+ - name : get Python version for codecov flag
413
+ id : get-version
414
+ run : >-
415
+ echo "version=$(python -V | cut -d' ' -f2 | cut -d'.' -f1,2)"
416
+ >> "${GITHUB_OUTPUT}"
417
+ - if : always()
418
+ uses : codecov/codecov-action@v5
419
+ with :
420
+ name : Cython
421
+ flags : Cython,${{ steps.get-version.outputs.version }}
422
+ fail_ci_if_error : true
248
423
249
424
# https://github.com/marketplace/actions/alls-green#why
250
425
check : # This job does nothing and is only used for the branch protection
0 commit comments