@@ -11,7 +11,7 @@ inputs:
1111 poetry-version :
1212 description : ' Poetry version to use'
1313 required : true
14- default : " 2.1.2 "
14+ default : " 2.1.4 "
1515
1616 working-directory :
1717 description : ' Working directory to use'
@@ -32,29 +32,61 @@ runs:
3232 using : " composite"
3333 steps :
3434
35- - name : Set up pipx if not present
35+
36+ - name : Set up Python (${{ inputs.python-version}})
37+ uses : actions/setup-python@v5
38+ with :
39+ python-version : ${{ inputs.python-version }}
40+
41+ - name : Ensure wget
42+ shell : bash
43+ run : sudo apt update && sudo apt install -y wget
44+
45+ - name : Set up Poetry (${{ inputs.poetry-version }})
3646 shell : bash
3747 run : |
38- sudo apt update && sudo apt install -y pipx
39- python3 -m pipx ensurepath
48+ wget --tries=10 --waitretry 10 --retry-connrefused --https-only -O - https://install.python-poetry.org | POETRY_VERSION="${{ inputs.poetry-version }}" "$PYTHON_BINARY" -
4049 echo "$HOME/.local/bin" >> $GITHUB_PATH
50+ env :
51+ PYTHON_BINARY : " python${{ inputs.python-version }}"
4152
42- - name : Set up Poetry (${{ inputs.poetry-version }})
53+ - name : Setup cache variables
54+ id : setup-cache-variables
4355 shell : bash
44- run : pipx install poetry==${{ inputs.poetry-version }}
56+ run : |
57+ echo "ImageOS=$ImageOS"
58+ echo "ImageVersion=$ImageVersion"
59+ POETRY_ENV_PATH=$(poetry config virtualenvs.path)
60+ POETRY_SHA=$(sha256sum poetry.lock | awk '{print $1}') #Remove trailing filename
61+ echo "POETRY_ENV_PATH=$POETRY_ENV_PATH" >> $GITHUB_OUTPUT
62+ echo "IMAGE_OS=$ImageOS" >> $GITHUB_OUTPUT
63+ echo "IMAGE_VERSION=$ImageVersion" >> $GITHUB_OUTPUT
64+ echo "POETRY_SHA=$POETRY_SHA" >> $GITHUB_OUTPUT
65+
4566
46- - name : Set up Python (${{ inputs.python-version}})
47- uses : actions/setup-python@v5
67+ - name : Cache Poetry environment
68+ if : inputs.use-cache == 'true'
69+ id : cache-poetry-env
70+ uses : actions/cache@v4
4871 with :
49- python-version : ${{ inputs.python-version }}
50- cache : ${{ inputs.use -cache == 'true' && ' poetry' || '' }}
72+ path : ${{ steps.setup-cache-variables.outputs.POETRY_ENV_PATH }}
73+ key : poetry-env- ${{ steps.setup -cache-variables.outputs.POETRY_SHA }}-${{ steps.setup-cache-variables.outputs.IMAGE_OS }}-${{ steps.setup-cache-variables.outputs.IMAGE_VERSION }}-${{ runner.arch }}-${{ inputs. poetry-version }}-${{ inputs.python-version }}-${{ inputs.extras }}
5174
5275 - name : Poetry install with extras
76+ if : inputs.use-cache != 'true' || steps.cache-poetry-env.outputs.cache-hit != 'true'
5377 working-directory : ${{ inputs.working-directory }}
5478 shell : bash
5579 run : |
80+ EXTRAS=$(echo "${{ inputs.extras }}" | tr -d ' ')
5681 if [[ -n "$EXTRAS" ]]; then
5782 poetry install --extras "$EXTRAS"
5883 else
5984 poetry install
6085 fi
86+
87+ - name : Validate Poetry environment
88+ working-directory : ${{ inputs.working-directory }}
89+ shell : bash
90+ run : |
91+ poetry run python --version
92+ poetry run python --version | grep "${{ inputs.python-version }}"
0 commit comments