Skip to content

Commit eb0170a

Browse files
committed
Test sdist contents instead of Git checkout in CI
This patch helps make sure that sdist contents is enough to run tests downstream.
1 parent 0f270f9 commit eb0170a

File tree

2 files changed

+114
-10
lines changed

2 files changed

+114
-10
lines changed

.github/workflows/ci.yml

Lines changed: 107 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,75 @@ concurrency:
1414
group: ${{ github.ref }}-${{ github.workflow }}-${{ github.event_name }}${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) && format('-{0}', github.sha) || '' }}
1515
cancel-in-progress: true
1616

17+
env:
18+
dists-artifact-name: python-package-distributions
19+
dist-name: trio
20+
1721
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+
1881
Windows:
1982
name: 'Windows (${{ matrix.python }}, ${{ matrix.arch }}${{ matrix.extra_name }})'
83+
needs:
84+
- build
85+
2086
timeout-minutes: 20
2187
runs-on: 'windows-latest'
2288
strategy:
@@ -58,8 +124,11 @@ jobs:
58124
|| false
59125
}}
60126
steps:
61-
- name: Checkout
62-
uses: actions/checkout@v4
127+
- name: Retrieve the project source from an sdist inside the GHA artifact
128+
uses: re-actors/checkout-python-sdist@release/v2
129+
with:
130+
source-tarball-name: ${{ needs.build.outputs.sdist-artifact-name }}
131+
workflow-artifact-name: ${{ env.dists-artifact-name }}
63132
- name: Setup python
64133
uses: actions/setup-python@v5
65134
with:
@@ -94,6 +163,9 @@ jobs:
94163

95164
Ubuntu:
96165
name: 'Ubuntu (${{ matrix.python }}${{ matrix.extra_name }})'
166+
needs:
167+
- build
168+
97169
timeout-minutes: 10
98170
runs-on: 'ubuntu-latest'
99171
strategy:
@@ -121,7 +193,14 @@ jobs:
121193
|| false
122194
}}
123195
steps:
124-
- name: Checkout
196+
- name: Retrieve the project source from an sdist inside the GHA artifact
197+
if: matrix.check_formatting != '1'
198+
uses: re-actors/checkout-python-sdist@release/v2
199+
with:
200+
source-tarball-name: ${{ needs.build.outputs.sdist-artifact-name }}
201+
workflow-artifact-name: ${{ env.dists-artifact-name }}
202+
- name: Grab the source from Git
203+
if: matrix.check_formatting == '1'
125204
uses: actions/checkout@v4
126205
- name: Setup python
127206
uses: actions/setup-python@v5
@@ -146,6 +225,9 @@ jobs:
146225
147226
macOS:
148227
name: 'macOS (${{ matrix.python }})'
228+
needs:
229+
- build
230+
149231
timeout-minutes: 15
150232
runs-on: 'macos-latest'
151233
strategy:
@@ -162,8 +244,11 @@ jobs:
162244
|| false
163245
}}
164246
steps:
165-
- name: Checkout
166-
uses: actions/checkout@v4
247+
- name: Retrieve the project source from an sdist inside the GHA artifact
248+
uses: re-actors/checkout-python-sdist@release/v2
249+
with:
250+
source-tarball-name: ${{ needs.build.outputs.sdist-artifact-name }}
251+
workflow-artifact-name: ${{ env.dists-artifact-name }}
167252
- name: Setup python
168253
uses: actions/setup-python@v5
169254
with:
@@ -183,17 +268,24 @@ jobs:
183268
# run CI on a musl linux
184269
Alpine:
185270
name: "Alpine"
271+
needs:
272+
- build
273+
186274
runs-on: ubuntu-latest
187275
container: alpine
188276
steps:
189-
- name: Checkout
190-
uses: actions/checkout@v4
191277
- name: Install necessary packages
192278
# can't use setup-python because that python doesn't seem to work;
193279
# `python3-dev` (rather than `python:alpine`) for some ctypes reason,
194280
# `nodejs` for pyright (`node-env` pulls in nodejs but that takes a while and can time out the test).
195281
# `perl` for a platform independent `sed -i` alternative
196282
run: apk update && apk add python3-dev bash nodejs perl
283+
- name: Retrieve the project source from an sdist inside the GHA artifact
284+
# must be after `apk add` because it relies on `bash` existing
285+
uses: re-actors/checkout-python-sdist@release/v2
286+
with:
287+
source-tarball-name: ${{ needs.build.outputs.sdist-artifact-name }}
288+
workflow-artifact-name: ${{ env.dists-artifact-name }}
197289
- name: Enter virtual environment
198290
run: python -m venv .venv
199291
- name: Run tests
@@ -211,6 +303,9 @@ jobs:
211303

212304
Cython:
213305
name: "Cython"
306+
needs:
307+
- build
308+
214309
runs-on: ubuntu-latest
215310
strategy:
216311
fail-fast: false
@@ -225,8 +320,11 @@ jobs:
225320
- python: '3.13' # We support running cython3 on 3.13
226321
cython: '>=3' # cython 3 (or greater)
227322
steps:
228-
- name: Checkout
229-
uses: actions/checkout@v4
323+
- name: Retrieve the project source from an sdist inside the GHA artifact
324+
uses: re-actors/checkout-python-sdist@release/v2
325+
with:
326+
source-tarball-name: ${{ needs.build.outputs.sdist-artifact-name }}
327+
workflow-artifact-name: ${{ env.dists-artifact-name }}
230328
- name: Setup python
231329
uses: actions/setup-python@v5
232330
with:

MANIFEST.in

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
1+
include .codecov.yml
2+
include check.sh
3+
include ci.sh
14
include LICENSE LICENSE.MIT LICENSE.APACHE2
25
include README.rst
36
include CODE_OF_CONDUCT.md CONTRIBUTING.md
4-
include test-requirements.txt
7+
include *-requirements.in
8+
include *-requirements.txt
59
include src/trio/py.typed
10+
include src/trio/_tests/astrill-codesigning-cert.cer
611
recursive-include src/trio/_tests/test_ssl_certs *.pem
712
recursive-include docs *
13+
recursive-include tests *
814
prune docs/build

0 commit comments

Comments
 (0)