@@ -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,8 +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
187
+ with :
188
+ source-tarball-name : ${{ needs.build.outputs.sdist-artifact-name }}
189
+ workflow-artifact-name : ${{ env.dists-artifact-name }}
63
190
- name : Setup python
64
191
uses : actions/setup-python@v5
65
192
with :
94
221
95
222
Ubuntu :
96
223
name : ' Ubuntu (${{ matrix.python }}${{ matrix.extra_name }})'
224
+ needs :
225
+ - build
226
+
97
227
timeout-minutes : 10
98
228
runs-on : ' ubuntu-latest'
99
229
strategy :
@@ -121,7 +251,14 @@ jobs:
121
251
|| false
122
252
}}
123
253
steps :
124
- - 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'
125
262
uses : actions/checkout@v4
126
263
- name : Setup python
127
264
uses : actions/setup-python@v5
@@ -146,6 +283,9 @@ jobs:
146
283
147
284
macOS :
148
285
name : ' macOS (${{ matrix.python }})'
286
+ needs :
287
+ - build
288
+
149
289
timeout-minutes : 15
150
290
runs-on : ' macos-latest'
151
291
strategy :
@@ -162,8 +302,11 @@ jobs:
162
302
|| false
163
303
}}
164
304
steps :
165
- - name : Checkout
166
- uses : actions/checkout@v4
305
+ - name : Retrieve the project source from an sdist inside the GHA artifact
306
+ uses : re-actors/checkout-python-sdist@release/v2
307
+ with :
308
+ source-tarball-name : ${{ needs.build.outputs.sdist-artifact-name }}
309
+ workflow-artifact-name : ${{ env.dists-artifact-name }}
167
310
- name : Setup python
168
311
uses : actions/setup-python@v5
169
312
with :
@@ -183,17 +326,24 @@ jobs:
183
326
# run CI on a musl linux
184
327
Alpine :
185
328
name : " Alpine"
329
+ needs :
330
+ - build
331
+
186
332
runs-on : ubuntu-latest
187
333
container : alpine
188
334
steps :
189
- - name : Checkout
190
- uses : actions/checkout@v4
191
335
- name : Install necessary packages
192
336
# can't use setup-python because that python doesn't seem to work;
193
337
# `python3-dev` (rather than `python:alpine`) for some ctypes reason,
194
338
# `nodejs` for pyright (`node-env` pulls in nodejs but that takes a while and can time out the test).
195
339
# `perl` for a platform independent `sed -i` alternative
196
340
run : apk update && apk add python3-dev bash nodejs perl
341
+ - name : Retrieve the project source from an sdist inside the GHA artifact
342
+ # must be after `apk add` because it relies on `bash` existing
343
+ uses : re-actors/checkout-python-sdist@release/v2
344
+ with :
345
+ source-tarball-name : ${{ needs.build.outputs.sdist-artifact-name }}
346
+ workflow-artifact-name : ${{ env.dists-artifact-name }}
197
347
- name : Enter virtual environment
198
348
run : python -m venv .venv
199
349
- name : Run tests
@@ -211,6 +361,9 @@ jobs:
211
361
212
362
Cython :
213
363
name : " Cython"
364
+ needs :
365
+ - build
366
+
214
367
runs-on : ubuntu-latest
215
368
strategy :
216
369
fail-fast : false
@@ -225,8 +378,11 @@ jobs:
225
378
- python : ' 3.13' # We support running cython3 on 3.13
226
379
cython : ' >=3' # cython 3 (or greater)
227
380
steps :
228
- - name : Checkout
229
- uses : actions/checkout@v4
381
+ - name : Retrieve the project source from an sdist inside the GHA artifact
382
+ uses : re-actors/checkout-python-sdist@release/v2
383
+ with :
384
+ source-tarball-name : ${{ needs.build.outputs.sdist-artifact-name }}
385
+ workflow-artifact-name : ${{ env.dists-artifact-name }}
230
386
- name : Setup python
231
387
uses : actions/setup-python@v5
232
388
with :
0 commit comments