From 848e825c01df4df346bd207cee4f3122755f69a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Robert?= Date: Sun, 22 Jun 2025 16:33:00 +0200 Subject: [PATCH] ENH: add support for PEP 735 dependency-groups via a new workflow input `test_groups` --- .github/workflows/publish.yml | 16 +++++++++- .github/workflows/publish_pure_python.yml | 8 ++++- .github/workflows/test_publish.yml | 9 ++++-- .../workflows/test_publish_pure_python.yml | 3 +- README.md | 6 ++-- docs/source/publish.rst | 8 ++++- docs/source/publish_pure_python.rst | 8 ++++- pyproject.toml | 31 +++++++++++++++++-- setup.cfg | 10 ------ 9 files changed, 77 insertions(+), 22 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 3154bef1..b1ae8b7b 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -16,6 +16,11 @@ on: required: false default: true type: boolean + test_groups: + description: PEP 735 dependency groups that should be installed for testing + required: false + default: '' + type: string test_extras: description: Any extras_requires modifier that should be used to install the package for testing required: false @@ -154,6 +159,10 @@ jobs: uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3.6.0 with: platforms: all + - name: Parse dependency groups + shell: bash + run: | + echo "space_sep_groups=$( python -c "print('${{ inputs.test_groups }}'.replace(',', ' '))" )" >> "$GITHUB_ENV" - name: Configure cibuildwheel shell: bash run: | @@ -161,6 +170,10 @@ jobs: then echo "CIBW_TEST_EXTRAS=${{ inputs.test_extras }}" >> $GITHUB_ENV fi + if [ -n "${{ inputs.test_groups }}" ]; + then + echo "CIBW_TEST_GROUPS=$space_sep_groups" >> $GITHUB_ENV + fi set +e IFS='' read -r -d '' test_command <<"EOF" ${{ inputs.test_command }} @@ -233,8 +246,9 @@ jobs: with: apt: ${{ inputs.libraries }} - id: build - uses: OpenAstronomy/build-python-dist@bbb0e1c5b132893999ea56d77bd4b526e0097c7d # v1.0.1 + uses: OpenAstronomy/build-python-dist@9a4b2bd6bda5c48ef3c12b53504ee2263ed032e3 # v1.1.0 with: + test_groups: ${{ inputs.test_groups }} test_extras: ${{ inputs.test_extras }} test_command: ${{ inputs.test_command }} pure_python_wheel: false diff --git a/.github/workflows/publish_pure_python.yml b/.github/workflows/publish_pure_python.yml index acf71584..1d06e1c4 100644 --- a/.github/workflows/publish_pure_python.yml +++ b/.github/workflows/publish_pure_python.yml @@ -3,6 +3,11 @@ name: Build and publish pure Python package on: workflow_call: inputs: + test_groups: + description: PEP 735 dependency groups that should be installed for testing + required: false + default: '' + type: string test_extras: description: Any extras_requires modifier that should be used to install the package for testing required: false @@ -118,8 +123,9 @@ jobs: with: apt: ${{ inputs.libraries }} - id: build - uses: OpenAstronomy/build-python-dist@bbb0e1c5b132893999ea56d77bd4b526e0097c7d # v1.0.1 + uses: OpenAstronomy/build-python-dist@9a4b2bd6bda5c48ef3c12b53504ee2263ed032e3 # v1.1.0 with: + test_groups: ${{ inputs.test_groups }} test_extras: ${{ inputs.test_extras }} test_command: ${{ inputs.test_command }} python-version: ${{ inputs.python-version }} diff --git a/.github/workflows/test_publish.yml b/.github/workflows/test_publish.yml index a5201469..423ffdd3 100644 --- a/.github/workflows/test_publish.yml +++ b/.github/workflows/test_publish.yml @@ -17,13 +17,15 @@ jobs: release_default: uses: ./.github/workflows/publish.yml with: - test_extras: test + test_groups: test, concurrency + test_extras: recommended test_command: pytest --pyargs test_package timeout-minutes: 30 release: uses: ./.github/workflows/publish.yml with: - test_extras: test + test_groups: test, concurrency + test_extras: recommended test_command: pytest --pyargs test_package targets: | - linux @@ -41,6 +43,7 @@ jobs: release_sdist_only: uses: ./.github/workflows/publish.yml with: - test_extras: test + test_groups: test, concurrency + test_extras: recommended test_command: pytest --pyargs test_package targets: '' diff --git a/.github/workflows/test_publish_pure_python.yml b/.github/workflows/test_publish_pure_python.yml index 5c815d46..8b2da075 100644 --- a/.github/workflows/test_publish_pure_python.yml +++ b/.github/workflows/test_publish_pure_python.yml @@ -17,7 +17,8 @@ jobs: release: uses: ./.github/workflows/publish_pure_python.yml with: - test_extras: test + test_groups: test, concurrency + test_extras: recommended test_command: pytest --pyargs test_package timeout-minutes: 5 diff --git a/README.md b/README.md index f64b43f7..0fe0862a 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,8 @@ jobs: publish: uses: OpenAstronomy/github-actions-workflows/.github/workflows/publish.yml@v1 with: - test_extras: test + test_groups: test + test_extras: recommended test_command: pytest --pyargs test_package targets: | - linux @@ -60,7 +61,8 @@ jobs: publish: uses: OpenAstronomy/github-actions-workflows/.github/workflows/publish_pure_python.yml@v1 with: - test_extras: test + test_groups: test + test_extras: recommended test_command: pytest --pyargs test_package secrets: pypi_token: ${{ secrets.pypi_token }} diff --git a/docs/source/publish.rst b/docs/source/publish.rst index 4d28328e..f17c3ef2 100644 --- a/docs/source/publish.rst +++ b/docs/source/publish.rst @@ -10,7 +10,8 @@ platform-dependent wheels. publish: uses: OpenAstronomy/github-actions-workflows/.github/workflows/publish.yml@v1 with: - test_extras: test + test_groups: test, concurrency + test_extras: recommended test_command: pytest --pyargs test_package targets: | - linux @@ -78,6 +79,11 @@ sdist-runs-on Choose an alternative image for the runner to use for building and testing the source distribution. By default, this is ``ubuntu-latest``. +test_groups +^^^^^^^^^^^ + +Comma-separated, PEP 735 dependency groups that should be installed for testing. + test_extras ^^^^^^^^^^^ diff --git a/docs/source/publish_pure_python.rst b/docs/source/publish_pure_python.rst index 8aa90966..7147cfff 100644 --- a/docs/source/publish_pure_python.rst +++ b/docs/source/publish_pure_python.rst @@ -11,7 +11,8 @@ source distribution are build, tested and published instead. publish: uses: OpenAstronomy/github-actions-workflows/.github/workflows/publish_pure_python.yml@v1 with: - test_extras: test + test_groups: test, concurrency + test_extras: recommended test_command: pytest --pyargs test_package secrets: pypi_token: ${{ secrets.pypi_token }} @@ -26,6 +27,11 @@ Choose an alternative image for the runner to use for building and testing the source distribution and wheel. By default, this is ``ubuntu-latest``. +test_groups +^^^^^^^^^^^ + +Comma-separated, PEP 735 dependency groups that should be installed for testing. + test_extras ^^^^^^^^^^^ diff --git a/pyproject.toml b/pyproject.toml index d83557f6..2d86e3ff 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,9 +1,36 @@ [build-system] -requires = ["setuptools", "wheel"] -build-backend = 'setuptools.build_meta' +requires = ["setuptools>=61.2"] +build-backend = "setuptools.build_meta" [tool.cibuildwheel.linux] environment-pass = ["GITHUB_WORKFLOW"] +[project] +name = "test-package" +dynamic = ["version"] + +[project.optional-dependencies] +recommended = [ + "boto3", + "urllib3", +] + +[dependency-groups] +concurrency = [ + {include-group = "test"}, + "pytest-repeat>=0.9.3", + "pytest-run-parallel>=0.4.4", +] +test = [ + "hypothesis>=6.113.0", + "pytest>=8.3.5", +] + +[tool.setuptools] +include-package-data = false + +[tool.setuptools.packages] +find = {namespaces = false} + [tool.ruff] line-length = 100 diff --git a/setup.cfg b/setup.cfg index daed63be..7da1f960 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,12 +1,2 @@ -[metadata] -name = test-package - -[options] -packages = find: - -[options.extras_require] -test = - pytest - [flake8] max-line-length = 100