Skip to content

Commit

Permalink
Test sdist contents instead of Git checkout in CI
Browse files Browse the repository at this point in the history
This patch helps make sure that sdist contents is enough to run tests
downstream.
  • Loading branch information
webknjaz committed Dec 19, 2024
1 parent 4f66fab commit bf144f6
Show file tree
Hide file tree
Showing 2 changed files with 111 additions and 11 deletions.
114 changes: 104 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,75 @@ concurrency:
group: ${{ github.ref }}-${{ github.workflow }}-${{ github.event_name }}${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) && format('-{0}', github.sha) || '' }}
cancel-in-progress: true

env:
dists-artifact-name: python-package-distributions
dist-name: trio

jobs:
build:
name: 👷 dists

runs-on: ubuntu-latest

outputs:
dist-version: ${{ steps.dist-version.outputs.version }}
sdist-artifact-name: ${{ steps.artifact-name.outputs.sdist }}
wheel-artifact-name: ${{ steps.artifact-name.outputs.wheel }}

steps:
- name: Switch to using Python 3.11
uses: actions/setup-python@v5
with:
python-version: 3.11

- name: Grab the source from Git
uses: actions/checkout@v4

- name: Get the dist version
id: dist-version
run: >-
echo "version=$(
grep ^__version__ src/trio/_version.py
| sed 's#__version__ = "\([^"]\+\)"#\1#'
)"
>> "${GITHUB_OUTPUT}"
- name: Set the expected dist artifact names
id: artifact-name
run: |
echo 'sdist=${{ env.dist-name }}-*.tar.gz' >> "${GITHUB_OUTPUT}"
echo 'wheel=${{
env.dist-name
}}-*-py3-none-any.whl' >> "${GITHUB_OUTPUT}"
- name: Install build
run: python -Im pip install build

- name: Build dists
run: python -Im build
- name: Verify that the artifacts with expected names got created
run: >-
ls -1
dist/${{ steps.artifact-name.outputs.sdist }}
dist/${{ steps.artifact-name.outputs.wheel }}
- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: ${{ env.dists-artifact-name }}
# NOTE: Exact expected file names are specified here
# NOTE: as a safety measure — if anything weird ends
# NOTE: up being in this dir or not all dists will be
# NOTE: produced, this will fail the workflow.
path: |
dist/${{ steps.artifact-name.outputs.sdist }}
dist/${{ steps.artifact-name.outputs.wheel }}
retention-days: 5

Windows:
name: 'Windows (${{ matrix.python }}, ${{ matrix.arch }}${{ matrix.extra_name }})'
needs:
- build

timeout-minutes: 20
runs-on: 'windows-latest'
strategy:
Expand Down Expand Up @@ -58,8 +124,11 @@ jobs:
|| false
}}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Retrieve the project source from an sdist inside the GHA artifact
uses: re-actors/checkout-python-sdist@release/v2
with:
source-tarball-name: ${{ needs.build.outputs.sdist-artifact-name }}
workflow-artifact-name: ${{ env.dists-artifact-name }}
- name: Setup python
uses: actions/setup-python@v5
with:
Expand Down Expand Up @@ -94,6 +163,9 @@ jobs:

Ubuntu:
name: 'Ubuntu (${{ matrix.python }}${{ matrix.extra_name }})'
needs:
- build

timeout-minutes: 10
runs-on: 'ubuntu-latest'
strategy:
Expand Down Expand Up @@ -121,8 +193,11 @@ jobs:
|| false
}}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Retrieve the project source from an sdist inside the GHA artifact
uses: re-actors/checkout-python-sdist@release/v2
with:
source-tarball-name: ${{ needs.build.outputs.sdist-artifact-name }}
workflow-artifact-name: ${{ env.dists-artifact-name }}
- name: Setup python
uses: actions/setup-python@v5
with:
Expand All @@ -146,6 +221,9 @@ jobs:
macOS:
name: 'macOS (${{ matrix.python }})'
needs:
- build

timeout-minutes: 15
runs-on: 'macos-latest'
strategy:
Expand All @@ -162,8 +240,11 @@ jobs:
|| false
}}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Retrieve the project source from an sdist inside the GHA artifact
uses: re-actors/checkout-python-sdist@release/v2
with:
source-tarball-name: ${{ needs.build.outputs.sdist-artifact-name }}
workflow-artifact-name: ${{ env.dists-artifact-name }}
- name: Setup python
uses: actions/setup-python@v5
with:
Expand All @@ -183,17 +264,24 @@ jobs:
# run CI on a musl linux
Alpine:
name: "Alpine"
needs:
- build

runs-on: ubuntu-latest
container: alpine
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install necessary packages
# can't use setup-python because that python doesn't seem to work;
# `python3-dev` (rather than `python:alpine`) for some ctypes reason,
# `nodejs` for pyright (`node-env` pulls in nodejs but that takes a while and can time out the test).
# `perl` for a platform independent `sed -i` alternative
run: apk update && apk add python3-dev bash nodejs perl
- name: Retrieve the project source from an sdist inside the GHA artifact
# must be after `apk add` because it relies on `bash` existing
uses: re-actors/checkout-python-sdist@release/v2
with:
source-tarball-name: ${{ needs.build.outputs.sdist-artifact-name }}
workflow-artifact-name: ${{ env.dists-artifact-name }}
- name: Enter virtual environment
run: python -m venv .venv
- name: Run tests
Expand All @@ -211,6 +299,9 @@ jobs:

Cython:
name: "Cython"
needs:
- build

runs-on: ubuntu-latest
strategy:
fail-fast: false
Expand All @@ -225,8 +316,11 @@ jobs:
- python: '3.13' # We support running cython3 on 3.13
cython: '>=3' # cython 3 (or greater)
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Retrieve the project source from an sdist inside the GHA artifact
uses: re-actors/checkout-python-sdist@release/v2
with:
source-tarball-name: ${{ needs.build.outputs.sdist-artifact-name }}
workflow-artifact-name: ${{ env.dists-artifact-name }}
- name: Setup python
uses: actions/setup-python@v5
with:
Expand Down
8 changes: 7 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
include .codecov.yml
include check.sh
include ci.sh
include LICENSE LICENSE.MIT LICENSE.APACHE2
include README.rst
include CODE_OF_CONDUCT.md CONTRIBUTING.md
include test-requirements.txt
include *-requirements.in
include *-requirements.txt
include src/trio/py.typed
include src/trio/_tests/astrill-codesigning-cert.cer
recursive-include src/trio/_tests/test_ssl_certs *.pem
recursive-include docs *
recursive-include tests *
prune docs/build

0 comments on commit bf144f6

Please sign in to comment.