Skip to content

Add support for installing extras to python-environment action #413

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
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
36 changes: 29 additions & 7 deletions .github/actions/python-environment/action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: 'SPPE'
description: 'Setup python and poetry environment'
description: 'Set up python and poetry environment'

inputs:

Expand All @@ -15,25 +15,47 @@ inputs:

working-directory:
description: 'Working directory to use'
required: true
required: false
default: "."

extras:
description: 'Comma-separated list of extras'
required: false

use-cache:
description: 'Use cache for poetry environment'
required: false
default: 'true'

runs:

using: "composite"
steps:

- name: Setup Poetry (${{ inputs.poetry-version }})
- name: Set up pipx if not present
shell: bash
run: |
python3 -m pip install --upgrade pipx
python3 -m pipx ensurepath
echo "$HOME/.local/bin" >> $GITHUB_PATH

- name: Set up Poetry (${{ inputs.poetry-version }})
shell: bash
run: pipx install poetry==${{ inputs.poetry-version }}

- name: Setup Python (${{ inputs.python-version}})
- name: Set up Python (${{ inputs.python-version}})
uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python-version }}
cache: 'poetry'
cache: ${{ inputs.use-cache == 'true' && 'poetry' || '' }}

- name: Poetry install
- name: Poetry install with extras
working-directory: ${{ inputs.working-directory }}
shell: bash
run: poetry install
run: |
EXTRAS=$(echo "${{ inputs.extras }}" | tr -d ' ')
if [[ -n "$EXTRAS" ]]; then
poetry install --extras "$EXTRAS"
else
poetry install
fi
7 changes: 6 additions & 1 deletion doc/changes/unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,9 @@ permissions to be increased for specific jobs.
## Security

* [#420](https://github.com/exasol/python-toolbox/issues/420): Replaced 3rd party action with GitHub actions for gh-pages
* [#422](https://github.com/exasol/python-toolbox/issues/422): Set permissions within the GitHub workflows to restrict usage of the default GitHub token
* [#422](https://github.com/exasol/python-toolbox/issues/422): Set permissions within the GitHub workflows to restrict usage of the default GitHub token

## ✨ Features

* [#161](https://github.com/exasol/python-toolbox/issues/161): Added support for installing extras & not using a cache to the python-environment action
* [#408](https://github.com/exasol/python-toolbox/issues/408): Added support for GitHub runners who do not per default have pipx to use the python-environment action
17 changes: 16 additions & 1 deletion doc/github_actions/python_environment.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@ Parameters
- Poetry version to use
- True
- 2.1.2
* - working-directory
- Working directory to use
- False
- .
* - extras
- Comma-separated list of extras
- False
- (not used by default)
* - use-cache
- Use cache for poetry environment
- False
- true

Example Usage
-------------
Expand All @@ -40,9 +52,12 @@ Example Usage
uses: actions/checkout@v4

- name: Setup Python & Poetry Environment
uses: exasol/python-toolbox/.github/actions/python-environment@0.21.0
uses: exasol/python-toolbox/.github/actions/python-environment@1.1.0
with:
python-version: 3.12
poetry-version: 2.1.2
working-directory: pytest-backend
use-cache: false
extras: 'numpy,pandas'

...