Skip to content

ENH: add support for PEP 735 dependency-groups via a new workflow input test_groups #21

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions .github/workflows/test_action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,27 @@ on:
jobs:
build_pure:
name: Test action (pure wheel)
runs-on: ubuntu-20.04
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- id: build
uses: ./
with:
pure_python_wheel: true
test_extras: test
test_groups: test, concurrency
test_extras: recommended
test_command: pytest --pyargs test_package
build_non_pure:
name: Test action (not pure wheel)
runs-on: ubuntu-20.04
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- id: build_not_pure
uses: ./
with:
pure_python_wheel: "false"
test_extras: test
test_groups: test
test_extras: recommended
test_command: pytest --pyargs test_package
18 changes: 14 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,19 @@ jobs:
- id: build
uses: OpenAstronomy/build-python-dist@v1
with:
test_extras: test
test_groups: test
test_extras: recommended
test_command: pytest --pyargs test_package
```

The ``test_extras`` option, if specified, should contain a string (e.g. ``test`` or ``test,all``) that will be used to determine which 'extras' should be installed when testing. The ``test_command`` option should contain the full command to use for testing the installed package (this is run from an empty temporary directory).
The ``test_groups`` option, if specified, should contain a comma-separated list
of [PEP 735 Dependency Groups](https://peps.python.org/pep-0735/) that should be
installed when testing (e.g. ``test``, or ``test, concurrency`` ...).
Similarily, the ``test_extras`` option specifies optional dependencies
(e.g. ``recommended`` or ``recommended, plotting``) that will be used to determine
which 'extras' should be installed when testing. The ``test_command`` option
should contain the full command to use for testing the installed package (this
is run from an empty temporary directory).

### Build a source distribution and wheel for a pure-Python package

Expand All @@ -55,7 +63,8 @@ jobs:
uses: OpenAstronomy/build-python-dist@v1
with:
pure_python_wheel: true
test_extras: test
test_groups: test
test_extras: recommended
test_command: pytest --pyargs test_package
```

Expand All @@ -73,7 +82,8 @@ jobs:
- id: build
uses: OpenAstronomy/build-python-dist@v1
with:
test_extras: test
test_groups: test
test_extras: recommended
test_command: pytest --pyargs test_package
python-version: '3.9'
```
Expand Down
23 changes: 17 additions & 6 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ branding:
icon: package
color: blue
inputs:
test_groups:
description: Comma-separated 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
Expand Down Expand Up @@ -44,24 +49,30 @@ runs:
shell: bash
run: python -m build --sdist .

- name: Test source distribution
- name: Create and activate a virtual environment
shell: bash
run: |
python -m venv test-sdist
source test-sdist/bin/activate
which python
python -m pip install --force-reinstall `find dist -name "*.tar.gz"`[${{ inputs.test_extras }}]

- name: Parse dependency groups
shell: bash
run: |
echo "group_flags=$( python -c "print(' '.join(f'--group {g.strip()}' for g in '${{ inputs.test_groups }}'.split(',')))" ) " >> "$GITHUB_ENV"

- name: Test source distribution
shell: bash
run: |
python -m pip install --force-reinstall `find dist -name "*.tar.gz"`[${{ inputs.test_extras }}] $group_flags
cd ${{ runner.temp }}
${{ inputs.test_command }}
if: ${{ inputs.test_command != '' && inputs.test_extras != '' }}

- name: Test source distribution
shell: bash
run: |
python -m venv test-sdist
source test-sdist/bin/activate
which python
python -m pip install --force-reinstall `find dist -name "*.tar.gz"`
python -m pip install --force-reinstall `find dist -name "*.tar.gz"` $group_flags
cd ${{ runner.temp }}
${{ inputs.test_command }}
if: ${{ inputs.test_command != '' && inputs.test_extras == '' }}
Expand Down
33 changes: 30 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,31 @@
[build-system]
requires = ["setuptools>=43.0.0",
"wheel"]
build-backend = 'setuptools.build_meta'
requires = ["setuptools>=61.2"]
build-backend = "setuptools.build_meta"

[project]
name = "test-package"
dynamic = ["version"]

[project.optional-dependencies]
recommended = [
# use small, pure-Python, extremely popular packages
"boto3",
"urllib3",
]

[dependency-groups]
concurrency = [
{include-group = "test"},
"pytest-repeat",
"pytest-run-parallel",
]
test = [
"hypothesis>=6.135.14",
"pytest>=8.4.1",
]

[tool.setuptools]
include-package-data = false

[tool.setuptools.packages]
find = {namespaces = false}
9 changes: 0 additions & 9 deletions setup.cfg

This file was deleted.