From 9a2c16bbc79ab3b269e301a9a7ae629850185c8f Mon Sep 17 00:00:00 2001 From: "Felt, Nicholas" Date: Wed, 11 Sep 2024 15:56:22 -0700 Subject: [PATCH 1/5] feat: Enable importing the built package during the `package-build` workflow --- .github/workflows/_reusable-package-build.yml | 13 ++++++++++--- CHANGELOG.md | 4 ++++ workflows/package-build.md | 10 +++++----- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/.github/workflows/_reusable-package-build.yml b/.github/workflows/_reusable-package-build.yml index ed566d60..72f4246c 100644 --- a/.github/workflows/_reusable-package-build.yml +++ b/.github/workflows/_reusable-package-build.yml @@ -4,7 +4,8 @@ on: workflow_call: inputs: package-name: - description: The name of the package to build and install. + description: The name of the package to build, install, and import (this must + be the package's importable name). required: true type: string python-versions-array: @@ -66,13 +67,19 @@ jobs: - name: Test installing wheel shell: bash run: pip install dist/*.whl + - name: Test importing ${{ env.PACKAGE_NAME }} + run: python -c "import ${{ env.PACKAGE_NAME }}" - name: Uninstall wheel - run: pip uninstall --yes "${{ env.PACKAGE_NAME }}" + shell: bash + run: pip freeze | xargs pip uninstall -y - name: Test installing tarball shell: bash run: pip install dist/*.tar.gz + - name: Test importing ${{ env.PACKAGE_NAME }} + run: python -c "import ${{ env.PACKAGE_NAME }}" - name: Uninstall tarball - run: pip uninstall --yes "${{ env.PACKAGE_NAME }}" + shell: bash + run: pip freeze | xargs pip uninstall -y # Check that all jobs passed check-build-and-install-passed: if: ${{ !cancelled() }} diff --git a/CHANGELOG.md b/CHANGELOG.md index f79b61e1..4a40c16e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,10 @@ Valid subsections within a version are: Things to be included in the next release go here. +### Added + +- Updated the `_reusable-package-build.yml` file to include a step that will test importing the built package to check for any missing dependencies. + ### Changed - Bumped dependency versions. diff --git a/workflows/package-build.md b/workflows/package-build.md index 2af9130b..ac76f65d 100644 --- a/workflows/package-build.md +++ b/workflows/package-build.md @@ -41,11 +41,11 @@ and operating system specified. ## Inputs -| Input variable | Necessity | Description | Default | -| ------------------------- | --------- | ----------------------------------------------------------------------------------------- | ---------------------------------- | -| `package-name` | required | The name of the package to build and install. | | -| `python-versions-array` | required | A valid JSON array of Python versions to validate the package can be installed with. | | -| `operating-systems-array` | optional | A valid JSON array of operating system names to validate the package can be installed on. | `'["ubuntu", "windows", "macos"]'` | +| Input variable | Necessity | Description | Default | +| ------------------------- | --------- | --------------------------------------------------------------------------------------------------- | ---------------------------------- | +| `package-name` | required | The name of the package to build, install, and import (this must be the package's importable name). | | +| `python-versions-array` | required | A valid JSON array of Python versions to validate the package can be installed with. | | +| `operating-systems-array` | optional | A valid JSON array of operating system names to validate the package can be installed on. | `'["ubuntu", "windows", "macos"]'` | ## Example From 15314f21b9dff4f9ac14ee0da21af8e9cf1996eb Mon Sep 17 00:00:00 2001 From: "Felt, Nicholas" Date: Wed, 11 Sep 2024 16:12:24 -0700 Subject: [PATCH 2/5] chore: testing --- .github/workflows/_reusable-package-build.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/_reusable-package-build.yml b/.github/workflows/_reusable-package-build.yml index 72f4246c..b71de265 100644 --- a/.github/workflows/_reusable-package-build.yml +++ b/.github/workflows/_reusable-package-build.yml @@ -71,7 +71,9 @@ jobs: run: python -c "import ${{ env.PACKAGE_NAME }}" - name: Uninstall wheel shell: bash - run: pip freeze | xargs pip uninstall -y + run: | + pip freeze + pip freeze | xargs pip uninstall -y - name: Test installing tarball shell: bash run: pip install dist/*.tar.gz From 9efe1da33260f8f9132f823313ad690237f03881 Mon Sep 17 00:00:00 2001 From: "Felt, Nicholas" Date: Wed, 11 Sep 2024 16:17:18 -0700 Subject: [PATCH 3/5] fix: Uninstall the package by name first, to avoid issues uninstalling the dependencies using pip freeze --- .github/workflows/_reusable-package-build.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/_reusable-package-build.yml b/.github/workflows/_reusable-package-build.yml index b71de265..729b7373 100644 --- a/.github/workflows/_reusable-package-build.yml +++ b/.github/workflows/_reusable-package-build.yml @@ -72,6 +72,8 @@ jobs: - name: Uninstall wheel shell: bash run: | + pip freeze + pip uninstall -y ${{ env.PACKAGE_NAME }} pip freeze pip freeze | xargs pip uninstall -y - name: Test installing tarball @@ -81,7 +83,9 @@ jobs: run: python -c "import ${{ env.PACKAGE_NAME }}" - name: Uninstall tarball shell: bash - run: pip freeze | xargs pip uninstall -y + run: | + pip uninstall -y ${{ env.PACKAGE_NAME }} + pip freeze | xargs pip uninstall -y # Check that all jobs passed check-build-and-install-passed: if: ${{ !cancelled() }} From 5f9fe031b4a8812418d4954fcbe6b96e06f1b68e Mon Sep 17 00:00:00 2001 From: "Felt, Nicholas" Date: Wed, 11 Sep 2024 16:20:49 -0700 Subject: [PATCH 4/5] chore: remove debugging printouts --- .github/workflows/_reusable-package-build.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/_reusable-package-build.yml b/.github/workflows/_reusable-package-build.yml index 729b7373..af2de13b 100644 --- a/.github/workflows/_reusable-package-build.yml +++ b/.github/workflows/_reusable-package-build.yml @@ -72,9 +72,7 @@ jobs: - name: Uninstall wheel shell: bash run: | - pip freeze pip uninstall -y ${{ env.PACKAGE_NAME }} - pip freeze pip freeze | xargs pip uninstall -y - name: Test installing tarball shell: bash From 92c38e7759980ff1ff7465e62dd8f84eeab3b90b Mon Sep 17 00:00:00 2001 From: "Felt, Nicholas" Date: Wed, 11 Sep 2024 16:24:27 -0700 Subject: [PATCH 5/5] docs: Update changelog with more details for users --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a40c16e..da0b49f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ Things to be included in the next release go here. ### Added - Updated the `_reusable-package-build.yml` file to include a step that will test importing the built package to check for any missing dependencies. + - IMPORTANT: This workflow now requires the `package-name` input be the python-importable name of the package to be built, e.g. `python -c "import package_name"`. ### Changed