diff --git a/.github/actions/python-environment/action.yml b/.github/actions/python-environment/action.yml index e078f8d24..cce664dff 100644 --- a/.github/actions/python-environment/action.yml +++ b/.github/actions/python-environment/action.yml @@ -1,5 +1,5 @@ name: 'SPPE' -description: 'Setup python and poetry environment' +description: 'Set up python and poetry environment' inputs: @@ -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 diff --git a/doc/changes/unreleased.md b/doc/changes/unreleased.md index c63b59f0b..0552e8d46 100644 --- a/doc/changes/unreleased.md +++ b/doc/changes/unreleased.md @@ -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 \ No newline at end of file +* [#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 \ No newline at end of file diff --git a/doc/github_actions/python_environment.rst b/doc/github_actions/python_environment.rst index 276d3698c..0da7edad8 100644 --- a/doc/github_actions/python_environment.rst +++ b/doc/github_actions/python_environment.rst @@ -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 ------------- @@ -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' ...