Skip to content

Commit

Permalink
Final poetry action fix: manually recreate softlinks broken by cachin…
Browse files Browse the repository at this point in the history
…g. (#10250)

It seems the caching action was not always correctly recreating
softlinks. At first glance, the softlinks it created seemed fine, but
they didn't always work. Possibly hitting some kind of underlying bug,
but not particularly worth debugging in depth -- we can manually create
the soft links we need.
  • Loading branch information
obi1kenobi authored Sep 5, 2023
1 parent 6195162 commit 7fe8bf0
Showing 1 changed file with 24 additions and 9 deletions.
33 changes: 24 additions & 9 deletions .github/actions/poetry_setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,28 +39,43 @@ runs:
with:
path: |
/opt/pipx/venvs/poetry
/opt/pipx_bin/poetry
# This step caches the poetry installation, so make sure it's keyed on the poetry version as well.
key: bin-poetry-${{ runner.os }}-${{ runner.arch }}-py-${{ inputs.python-version }}-${{ inputs.poetry-version }}

- name: Install poetry
if: steps.cache-bin-poetry.outputs.cache-hit != 'true'
- name: Refresh shell hashtable and fixup softlinks
if: steps.cache-bin-poetry.outputs.cache-hit == 'true'
shell: bash
env:
POETRY_VERSION: ${{ inputs.poetry-version }}
PYTHON_VERSION: ${{ inputs.python-version }}
run: pipx install "poetry==$POETRY_VERSION" --python "python$PYTHON_VERSION" --verbose

- name: Refresh shell hashtable and show python/poetry binaries and versions
shell: bash
run: |
set -eux
# Refresh the shell hashtable, to ensure correct `which` output.
hash -r
ls -alh /opt/pipx_bin/poetry
ls -alh /opt/pipx/venvs/poetry/bin/python
# `actions/cache@v3` doesn't always seem able to correctly unpack softlinks.
# Delete and recreate the softlinks pipx expects to have.
rm /opt/pipx/venvs/poetry/bin/python
cd /opt/pipx/venvs/poetry/bin
ln -s "$(which "python$PYTHON_VERSION")" python
chmod +x python
cd /opt/pipx_bin/
ln -s /opt/pipx/venvs/poetry/bin/poetry poetry
chmod +x poetry
# Ensure everything got set up correctly.
/opt/pipx/venvs/poetry/bin/python --version
/opt/pipx_bin/poetry --version
- name: Install poetry
if: steps.cache-bin-poetry.outputs.cache-hit != 'true'
shell: bash
env:
POETRY_VERSION: ${{ inputs.poetry-version }}
PYTHON_VERSION: ${{ inputs.python-version }}
run: pipx install "poetry==$POETRY_VERSION" --python "python$PYTHON_VERSION" --verbose

- name: Restore pip and poetry cached dependencies
uses: actions/cache@v3
env:
Expand Down

0 comments on commit 7fe8bf0

Please sign in to comment.