Skip to content

Commit f57e8c0

Browse files
Add support for installing extras to python-environment action (#413)
* changed github action python env to skip cache & all install extras
1 parent 6a9e851 commit f57e8c0

File tree

3 files changed

+51
-9
lines changed

3 files changed

+51
-9
lines changed

.github/actions/python-environment/action.yml

+29-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: 'SPPE'
2-
description: 'Setup python and poetry environment'
2+
description: 'Set up python and poetry environment'
33

44
inputs:
55

@@ -15,25 +15,47 @@ inputs:
1515

1616
working-directory:
1717
description: 'Working directory to use'
18-
required: true
18+
required: false
1919
default: "."
2020

21+
extras:
22+
description: 'Comma-separated list of extras'
23+
required: false
24+
25+
use-cache:
26+
description: 'Use cache for poetry environment'
27+
required: false
28+
default: 'true'
29+
2130
runs:
2231

2332
using: "composite"
2433
steps:
2534

26-
- name: Setup Poetry (${{ inputs.poetry-version }})
35+
- name: Set up pipx if not present
36+
shell: bash
37+
run: |
38+
python3 -m pip install --upgrade pipx
39+
python3 -m pipx ensurepath
40+
echo "$HOME/.local/bin" >> $GITHUB_PATH
41+
42+
- name: Set up Poetry (${{ inputs.poetry-version }})
2743
shell: bash
2844
run: pipx install poetry==${{ inputs.poetry-version }}
2945

30-
- name: Setup Python (${{ inputs.python-version}})
46+
- name: Set up Python (${{ inputs.python-version}})
3147
uses: actions/setup-python@v5
3248
with:
3349
python-version: ${{ inputs.python-version }}
34-
cache: 'poetry'
50+
cache: ${{ inputs.use-cache == 'true' && 'poetry' || '' }}
3551

36-
- name: Poetry install
52+
- name: Poetry install with extras
3753
working-directory: ${{ inputs.working-directory }}
3854
shell: bash
39-
run: poetry install
55+
run: |
56+
EXTRAS=$(echo "${{ inputs.extras }}" | tr -d ' ')
57+
if [[ -n "$EXTRAS" ]]; then
58+
poetry install --extras "$EXTRAS"
59+
else
60+
poetry install
61+
fi

doc/changes/unreleased.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,9 @@ permissions to be increased for specific jobs.
2525
## Security
2626

2727
* [#420](https://github.com/exasol/python-toolbox/issues/420): Replaced 3rd party action with GitHub actions for gh-pages
28-
* [#422](https://github.com/exasol/python-toolbox/issues/422): Set permissions within the GitHub workflows to restrict usage of the default GitHub token
28+
* [#422](https://github.com/exasol/python-toolbox/issues/422): Set permissions within the GitHub workflows to restrict usage of the default GitHub token
29+
30+
## ✨ Features
31+
32+
* [#161](https://github.com/exasol/python-toolbox/issues/161): Added support for installing extras & not using a cache to the python-environment action
33+
* [#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

doc/github_actions/python_environment.rst

+16-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,18 @@ Parameters
1919
- Poetry version to use
2020
- True
2121
- 2.1.2
22+
* - working-directory
23+
- Working directory to use
24+
- False
25+
- .
26+
* - extras
27+
- Comma-separated list of extras
28+
- False
29+
- (not used by default)
30+
* - use-cache
31+
- Use cache for poetry environment
32+
- False
33+
- true
2234

2335
Example Usage
2436
-------------
@@ -40,9 +52,12 @@ Example Usage
4052
uses: actions/checkout@v4
4153
4254
- name: Setup Python & Poetry Environment
43-
uses: exasol/python-toolbox/.github/actions/python-environment@0.21.0
55+
uses: exasol/python-toolbox/.github/actions/python-environment@1.1.0
4456
with:
4557
python-version: 3.12
4658
poetry-version: 2.1.2
59+
working-directory: pytest-backend
60+
use-cache: false
61+
extras: 'numpy,pandas'
4762
4863
...

0 commit comments

Comments
 (0)