Debian Codegraph @

.github/workflows/ci.yml

raw
1 name: CI
2
3 permissions: {}
4
5 on:
6 push:
7 branches-ignore:
8 # these branches always have another event associated
9 - gh-readonly-queue/** # GitHub's merge queue uses `merge_group`
10 - autodeps/** # autodeps always makes a PR
11 - pre-commit-ci-update-config # pre-commit.ci's updates always have a PR
12 pull_request:
13 merge_group:
14
15 concurrency:
16 group: ${{ github.ref }}-${{ github.workflow }}-${{ github.event_name }}${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) && format('-{0}', github.sha) || '' }}
17 cancel-in-progress: true
18
19 env:
20 dists-artifact-name: python-package-distributions
21 dist-name: trio
22
23 jobs:
24 build:
25 name: 👷 dists
26
27 runs-on: ubuntu-latest
28
29 outputs:
30 dist-version: ${{ steps.dist-version.outputs.version }}
31 sdist-artifact-name: ${{ steps.artifact-name.outputs.sdist }}
32 wheel-artifact-name: ${{ steps.artifact-name.outputs.wheel }}
33
34 steps:
35 - name: Switch to using Python 3.11
36 uses: actions/setup-python@v6
37 with:
38 python-version: 3.11
39
40 - name: Grab the source from Git
41 uses: actions/checkout@v7
42 with:
43 persist-credentials: false
44
45 - name: Get the dist version
46 id: dist-version
47 run: >-
48 echo "version=$(
49 grep ^__version__ src/trio/_version.py
50 | sed 's#__version__ = "\([^"]\+\)"#\1#'
51 )"
52 >> "${GITHUB_OUTPUT}"
53
54 - name: Set the expected dist artifact names
55 id: artifact-name
56 run: |
57 echo "sdist=${DIST_NAME}-${VERSION}.tar.gz" >> "${GITHUB_OUTPUT}"
58 echo "wheel=${DIST_NAME}-${VERSION}-py3-none-any.whl" >> "${GITHUB_OUTPUT}"
59 env:
60 DIST_NAME: ${{ env.dist-name }}
61 VERSION: ${{ steps.dist-version.outputs.version }}
62
63 - name: Install build
64 run: python -Im pip install build
65
66 - name: Build dists
67 run: python -Im build
68 - name: Verify that the artifacts with expected names got created
69 run: >-
70 ls -1
71 dist/${SDIST}
72 dist/${WHEEL}
73 env:
74 SDIST: ${{ steps.artifact-name.outputs.sdist }}
75 WHEEL: ${{ steps.artifact-name.outputs.wheel }}
76 - name: Store the distribution packages
77 uses: actions/upload-artifact@v7
78 with:
79 name: ${{ env.dists-artifact-name }}
80 # NOTE: Exact expected file names are specified here
81 # NOTE: as a safety measure — if anything weird ends
82 # NOTE: up being in this dir or not all dists will be
83 # NOTE: produced, this will fail the workflow.
84 path: |
85 dist/${{ steps.artifact-name.outputs.sdist }}
86 dist/${{ steps.artifact-name.outputs.wheel }}
87 retention-days: 5
88
89 smoke-tests:
90 name: Smoke tests
91 needs:
92 - build
93
94 runs-on: ubuntu-latest
95
96 steps:
97 - name: Switch to using Python 3.11
98 uses: actions/setup-python@v6
99 with:
100 python-version: 3.11
101
102 - name: >-
103 Smoke-test:
104 retrieve the project source from an sdist inside the GHA artifact
105 uses: re-actors/checkout-python-sdist@release/v2
106 with:
107 source-tarball-name: ${{ needs.build.outputs.sdist-artifact-name }}
108 workflow-artifact-name: ${{ env.dists-artifact-name }}
109
110 - name: >-
111 Smoke-test: move the sdist-retrieved dir into sdist-src
112 run: |
113 mv -v '${{ github.workspace }}' '${{ runner.temp }}/sdist-src'
114 mkdir -pv '${{ github.workspace }}'
115 mv -v '${{ runner.temp }}/sdist-src' '${{ github.workspace }}/sdist-src'
116 shell: bash -eEuo pipefail {0}
117
118 - name: >-
119 Smoke-test: grab the source from Git into git-src
120 uses: actions/checkout@v7
121 with:
122 path: git-src
123 persist-credentials: false
124
125 - name: >-
126 Smoke-test: install test requirements from the Git repo
127 run: >-
128 python -Im
129 pip install -c test-requirements.txt -r test-requirements.txt
130 shell: bash -eEuo pipefail {0}
131 working-directory: git-src
132
133 - name: >-
134 Smoke-test: collect tests from the Git repo
135 env:
136 PYTHONPATH: src/
137 run: >-
138 pytest --collect-only -qq .
139 | sort
140 | tee collected-tests
141 shell: bash -eEuo pipefail {0}
142 working-directory: git-src
143
144 - name: >-
145 Smoke-test: collect tests from the sdist tarball
146 env:
147 PYTHONPATH: src/
148 run: >-
149 pytest --collect-only -qq .
150 | sort
151 | tee collected-tests
152 shell: bash -eEuo pipefail {0}
153 working-directory: sdist-src
154
155 - name: >-
156 Smoke-test:
157 verify that all the tests from Git are included in the sdist
158 run: diff --unified sdist-src/collected-tests git-src/collected-tests
159 shell: bash -eEuo pipefail {0}
160
161 Windows:
162 name: 'Windows (${{ matrix.python }}, ${{ matrix.arch }}${{ matrix.extra_name }})'
163 needs:
164 - build
165
166 timeout-minutes: 20
167 runs-on: 'windows-latest'
168 strategy:
169 fail-fast: false
170 matrix:
171 python: ['3.10', '3.11', '3.12', '3.13', '3.14', '3.14t', '3.15-dev']
172 arch: ['x86', 'x64']
173 lsp: ['']
174 lsp_extract_file: ['']
175 extra_name: ['']
176 include:
177 - python: '3.10'
178 arch: 'x64'
179 lsp: 'https://raw.githubusercontent.com/python-trio/trio-ci-assets/master/komodia-based-vpn-setup.zip'
180 lsp_extract_file: 'komodia-based-vpn-setup.exe'
181 extra_name: ', with Komodia LSP'
182 - python: '3.10'
183 arch: 'x64'
184 lsp: 'https://www.proxifier.com/download/legacy/ProxifierSetup342.exe'
185 lsp_extract_file: ''
186 extra_name: ', with IFS LSP'
187 - python: 'pypy-3.11'
188 arch: 'x64'
189 lsp: ''
190 lsp_extract_file: ''
191 extra_name: ''
192 #- python: '3.10'
193 # arch: 'x64'
194 # lsp: 'http://download.pctools.com/mirror/updates/9.0.0.2308-SDavfree-lite_en.exe'
195 # lsp_extract_file: ''
196 # extra_name: ', with non-IFS LSP'
197
198 continue-on-error: >-
199 ${{
200 (
201 endsWith(matrix.python, '-dev')
202 || endsWith(matrix.python, '-nightly')
203 )
204 && true
205 || false
206 }}
207 steps:
208 - name: Retrieve the project source from an sdist inside the GHA artifact
209 uses: re-actors/checkout-python-sdist@release/v2
210 with:
211 source-tarball-name: ${{ needs.build.outputs.sdist-artifact-name }}
212 workflow-artifact-name: ${{ env.dists-artifact-name }}
213 - name: Setup Python
214 uses: actions/setup-python@v6
215 with:
216 python-version: '${{ matrix.python }}'
217 architecture: '${{ matrix.arch }}'
218 allow-prereleases: true
219 check-latest: true
220 - name: Run tests
221 run: ./ci.sh
222 shell: bash
223 env:
224 LSP: '${{ matrix.lsp }}'
225 LSP_EXTRACT_FILE: '${{ matrix.lsp_extract_file }}'
226 - if: always()
227 uses: codecov/codecov-action@v7
228 with:
229 name: Windows (${{ matrix.python }}, ${{ matrix.arch }}${{ matrix.extra_name }})
230 # multiple flags is marked as an error in codecov UI, but is actually fine
231 # https://github.com/codecov/feedback/issues/567
232 flags: Windows,${{ matrix.python }}
233 fail_ci_if_error: true
234
235 Ubuntu:
236 name: 'Ubuntu (${{ matrix.python }}${{ matrix.extra_name }})'
237 needs:
238 - build
239
240 timeout-minutes: 10
241 runs-on: 'ubuntu-latest'
242 strategy:
243 fail-fast: false
244 matrix:
245 python: ['pypy-3.11', '3.10', '3.11', '3.12', '3.13', '3.14', '3.14t', '3.15-dev']
246 check_formatting: ['0']
247 no_test_requirements: ['0']
248 extra_name: ['']
249 include:
250 - python: '3.13'
251 check_formatting: '1'
252 extra_name: ', check formatting'
253 # separate test run that doesn't install test-requirements.txt
254 - python: '3.10'
255 no_test_requirements: '1'
256 extra_name: ', no test-requirements'
257 continue-on-error: >-
258 ${{
259 (
260 endsWith(matrix.python, '-dev')
261 || endsWith(matrix.python, '-nightly')
262 )
263 && true
264 || false
265 }}
266 steps:
267 - name: Retrieve the project source from an sdist inside the GHA artifact
268 if: matrix.check_formatting != '1'
269 uses: re-actors/checkout-python-sdist@release/v2
270 with:
271 source-tarball-name: ${{ needs.build.outputs.sdist-artifact-name }}
272 workflow-artifact-name: ${{ env.dists-artifact-name }}
273 - name: Grab the source from Git
274 if: matrix.check_formatting == '1'
275 uses: actions/checkout@v7
276 with:
277 persist-credentials: false
278 - name: Setup Python
279 uses: actions/setup-python@v6
280 with:
281 python-version: '${{ matrix.python }}'
282 cache: pip
283 cache-dependency-path: test-requirements.txt
284 allow-prereleases: true
285 check-latest: true
286 - name: Setup minimum Python version
287 if: matrix.check_formatting == '1'
288 uses: actions/setup-python@v6
289 with:
290 python-version: '3.10'
291 cache: pip
292 cache-dependency-path: test-requirements.txt
293 allow-prereleases: true
294 - name: Check Formatting
295 if: matrix.check_formatting == '1'
296 run:
297 python -m pip install tox &&
298 tox -m check
299 - name: Run tests
300 if: matrix.check_formatting == '0'
301 run: ./ci.sh
302 env:
303 NO_TEST_REQUIREMENTS: '${{ matrix.no_test_requirements }}'
304 - if: >-
305 always()
306 && matrix.check_formatting != '1'
307 uses: codecov/codecov-action@v7
308 with:
309 name: Ubuntu (${{ matrix.python }}${{ matrix.extra_name }})
310 flags: Ubuntu,${{ matrix.python }}
311 fail_ci_if_error: true
312
313 macOS:
314 name: 'macOS (${{ matrix.python }})'
315 needs:
316 - build
317
318 timeout-minutes: 15
319 runs-on: 'macos-latest'
320 strategy:
321 fail-fast: false
322 matrix:
323 python: ['pypy-3.11', '3.10', '3.11', '3.12', '3.13', '3.14', '3.14t', '3.15-dev']
324 continue-on-error: >-
325 ${{
326 (
327 endsWith(matrix.python, '-dev')
328 || endsWith(matrix.python, '-nightly')
329 )
330 && true
331 || false
332 }}
333 steps:
334 - name: Retrieve the project source from an sdist inside the GHA artifact
335 uses: re-actors/checkout-python-sdist@release/v2
336 with:
337 source-tarball-name: ${{ needs.build.outputs.sdist-artifact-name }}
338 workflow-artifact-name: ${{ env.dists-artifact-name }}
339 - name: Setup Python
340 uses: actions/setup-python@v6
341 with:
342 python-version: '${{ matrix.python }}'
343 cache: pip
344 cache-dependency-path: test-requirements.txt
345 allow-prereleases: true
346 check-latest: true
347 - name: Run tests
348 run: ./ci.sh
349 - if: always()
350 uses: codecov/codecov-action@v7
351 with:
352 name: macOS (${{ matrix.python }})
353 flags: macOS,${{ matrix.python }}
354 fail_ci_if_error: true
355
356 # run CI on a musl linux
357 Alpine:
358 name: "Alpine"
359 needs:
360 - build
361
362 runs-on: ubuntu-latest
363 container: alpine:3
364 steps:
365 - name: Install necessary packages
366 # can't use setup-python because that python doesn't seem to work;
367 # `python3-dev` (rather than `python:alpine`) for some ctypes reason,
368 # `curl`, `gpg`, `git` for codecov-action v4/v5 to work (https://github.com/codecov/codecov-action/issues/1320).
369 # `nodejs` for pyright (`node-env` pulls in nodejs but that takes a while and can time out the test).
370 # `perl` for a platform independent `sed -i` alternative
371 run: apk update && apk add python3-dev bash curl gpg git nodejs perl
372
373 - name: Retrieve the project source from an sdist inside the GHA artifact
374 # must be after `apk add` because it relies on `bash` existing
375 uses: re-actors/checkout-python-sdist@release/v2
376 with:
377 source-tarball-name: ${{ needs.build.outputs.sdist-artifact-name }}
378 workflow-artifact-name: ${{ env.dists-artifact-name }}
379
380 - name: Enter virtual environment
381 run: python -m venv .venv
382
383 - name: Run tests
384 run: source .venv/bin/activate && ./ci.sh
385
386 - name: Get Python version for codecov flag
387 id: get-version
388 shell: python
389 run: |
390 import sys, os
391 with open(os.environ["GITHUB_OUTPUT"], "a") as f:
392 f.write("version=" + ".".join(map(str, sys.version_info[:2])))
393 f.write("\n")
394
395 - if: always()
396 uses: codecov/codecov-action@v7
397 with:
398 name: Alpine
399 flags: Alpine,${{ steps.get-version.outputs.version }}
400 fail_ci_if_error: true
401
402 Cython:
403 name: "Cython"
404 needs:
405 - build
406
407 runs-on: ubuntu-latest
408 strategy:
409 fail-fast: false
410 matrix:
411 include:
412 # Cython 2 supports 3.10 and 3.11 and Cython 3 supports all versions we do,
413 # so test both the lowest and higher version for both
414 - python: '3.10'
415 cython: '<3'
416 - python: '3.11'
417 cython: '<3'
418 # TODO: technically we should pin cython versions
419 - python: '3.10'
420 cython: '>=3'
421 - python: '3.14'
422 cython: '>=3'
423 steps:
424 - name: Retrieve the project source from an sdist inside the GHA artifact
425 uses: re-actors/checkout-python-sdist@release/v2
426 with:
427 source-tarball-name: ${{ needs.build.outputs.sdist-artifact-name }}
428 workflow-artifact-name: ${{ env.dists-artifact-name }}
429 - name: Setup Python
430 uses: actions/setup-python@v6
431 with:
432 python-version: '${{ matrix.python }}'
433 cache: pip
434 # setuptools is needed to get distutils on 3.12, which cythonize requires
435 - name: install trio and setuptools
436 run: python -m pip install --upgrade pip . setuptools 'coverage[toml]'
437
438 - name: add cython plugin to the coveragepy config
439 run: >-
440 sed -i 's#plugins\s=\s\[\]#plugins = ["Cython.Coverage"]#'
441 pyproject.toml
442
443 - name: install cython & compile pyx file
444 env:
445 CFLAGS: ${{ env.CFLAGS }} -DCYTHON_TRACE_NOGIL=1
446 run: |
447 python -m pip install "cython${{ matrix.cython }}"
448 cythonize --inplace -X linetrace=True tests/cython/test_cython.pyx
449
450 - name: import & run module
451 run: coverage run -m tests.cython.run_test_cython
452
453 - name: Get Python version for codecov flag
454 id: get-version
455 shell: python
456 run: |
457 import sys, os
458 with open(os.environ["GITHUB_OUTPUT"], "a") as f:
459 f.write("version=" + ".".join(map(str, sys.version_info[:2])))
460 f.write("\n")
461
462 - run: |
463 coverage combine
464 coverage report
465
466 - if: always()
467 uses: codecov/codecov-action@v7
468 with:
469 name: Cython
470 flags: Cython,${{ steps.get-version.outputs.version }}
471 fail_ci_if_error: true
472
473 zizmor:
474 name: Run zizmor 🌈
475 runs-on: ubuntu-latest
476 permissions:
477 security-events: write # Required for upload-sarif (used by zizmor-action) to upload SARIF files.
478 steps:
479 - name: Checkout repository
480 uses: actions/checkout@v7
481 with:
482 persist-credentials: false
483
484 - name: Run zizmor 🌈
485 uses: zizmorcore/[email protected]
486
487 # https://github.com/marketplace/actions/alls-green#why
488 check: # This job does nothing and is only used for the branch protection
489
490 if: always()
491
492 needs:
493 - smoke-tests
494 - Windows
495 - Ubuntu
496 - macOS
497 - Alpine
498 - Cython
499 - zizmor
500
501 runs-on: ubuntu-latest
502
503 steps:
504 - name: Decide whether the needed jobs succeeded or failed
505 uses: re-actors/alls-green@release/v1
506 with:
507 jobs: ${{ toJSON(needs) }}