diff --git a/.github/workflows/test_action.yml b/.github/workflows/test_action.yml index fab1790..d31d2ed 100644 --- a/.github/workflows/test_action.yml +++ b/.github/workflows/test_action.yml @@ -7,7 +7,7 @@ on: jobs: build_pure: name: Test action (pure wheel) - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -15,11 +15,12 @@ jobs: 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 @@ -27,5 +28,6 @@ jobs: uses: ./ with: pure_python_wheel: "false" - test_extras: test + test_groups: test + test_extras: recommended test_command: pytest --pyargs test_package diff --git a/README.md b/README.md index 6bb9838..50d852c 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 ``` @@ -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' ``` diff --git a/action.yml b/action.yml index d14b67d..bed5d03 100644 --- a/action.yml +++ b/action.yml @@ -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 @@ -44,13 +49,22 @@ 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 != '' }} @@ -58,10 +72,7 @@ runs: - 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 == '' }} diff --git a/pyproject.toml b/pyproject.toml index 5b3e573..309b538 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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} diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 0d63b1d..0000000 --- a/setup.cfg +++ /dev/null @@ -1,9 +0,0 @@ -[metadata] -name = test-package - -[options] -packages = find: - -[options.extras_require] -test = - pytest