From 3d9e30ff2eb50569d33d46de69752ff9c45bc523 Mon Sep 17 00:00:00 2001 From: Sviatoslav Sydorenko Date: Thu, 19 Jan 2023 03:14:18 +0100 Subject: [PATCH] Test sdist contents instead of Git checkout in CI This patch helps make sure that sdist contents is enough to run tests downstream. --- .github/workflows/ci.yml | 96 +++++++++++++++++++++++++++++++++++++--- MANIFEST.in | 5 +++ 2 files changed, 95 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 42e872be34..53de67b6cc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,9 +10,78 @@ 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@v4 + with: + python-version: 3.11 + + - name: Grab the source from Git + uses: actions/checkout@v3 + + - name: Get the dist version + id: dist-version + run: >- + echo "version=$( + grep ^__version__ 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 -m + pip install + --user + 'build ~= 0.10.0' + + - name: Build dists + run: python -m 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@v3 + 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: @@ -54,8 +123,11 @@ jobs: || false }} steps: - - name: Checkout - uses: actions/checkout@v3 + - name: Retrieve the project source from an sdist inside the GHA artifact + uses: re-actors/checkout-python-sdist@release/v1 + with: + source-tarball-name: ${{ needs.build.outputs.sdist-artifact-name }} + workflow-artifact-name: ${{ env.dists-artifact-name }} - name: Setup python uses: actions/setup-python@v4 with: @@ -86,6 +158,9 @@ jobs: Ubuntu: name: 'Ubuntu (${{ matrix.python }}${{ matrix.extra_name }})' + needs: + - build + timeout-minutes: 10 runs-on: 'ubuntu-latest' strategy: @@ -109,8 +184,11 @@ jobs: || false }} steps: - - name: Checkout - uses: actions/checkout@v3 + - name: Retrieve the project source from an sdist inside the GHA artifact + uses: re-actors/checkout-python-sdist@release/v1 + with: + source-tarball-name: ${{ needs.build.outputs.sdist-artifact-name }} + workflow-artifact-name: ${{ env.dists-artifact-name }} - name: Setup python uses: actions/setup-python@v4 if: "!endsWith(matrix.python, '-dev')" @@ -136,6 +214,9 @@ jobs: macOS: name: 'macOS (${{ matrix.python }})' + needs: + - build + timeout-minutes: 15 runs-on: 'macos-latest' strategy: @@ -152,8 +233,11 @@ jobs: || false }} steps: - - name: Checkout - uses: actions/checkout@v3 + - name: Retrieve the project source from an sdist inside the GHA artifact + uses: re-actors/checkout-python-sdist@release/v1 + with: + source-tarball-name: ${{ needs.build.outputs.sdist-artifact-name }} + workflow-artifact-name: ${{ env.dists-artifact-name }} - name: Setup python uses: actions/setup-python@v4 with: diff --git a/MANIFEST.in b/MANIFEST.in index 8b92523fb7..955975c61a 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,7 +1,12 @@ +include .coveragerc +include check.sh +include ci.sh include LICENSE LICENSE.MIT LICENSE.APACHE2 +include mypy.ini include README.rst include CODE_OF_CONDUCT.md CONTRIBUTING.md include test-requirements.txt +include trio/_tests/astrill-codesigning-cert.cer recursive-include trio/_tests/test_ssl_certs *.pem recursive-include docs * prune docs/build