From 53bf62e8fbf20dd95816e21283c0aed1372299fd Mon Sep 17 00:00:00 2001 From: drew2a Date: Fri, 24 Jun 2022 17:59:38 +0200 Subject: [PATCH] Add `invalidate-cache` flag --- .github/actions/pyenv/action.yml | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/.github/actions/pyenv/action.yml b/.github/actions/pyenv/action.yml index bb63ef49180..67ffd355657 100644 --- a/.github/actions/pyenv/action.yml +++ b/.github/actions/pyenv/action.yml @@ -11,6 +11,11 @@ inputs: description: 'The path to requirements.txt file' required: false + invalidate-cache: + default: 'false' + description: 'Force create a virtualenv' + required: false + outputs: virtualenv-directory: description: 'The path to the restored or created virtualenv' @@ -24,13 +29,20 @@ runs: python-version: ${{inputs.python-version}} - name: Restore virtual env - uses: syphar/restore-virtualenv@v1 + uses: drew2a/restore-virtualenv@v1.2.1 id: cache-virtualenv with: requirement_files: ${{inputs.requirements}} + - name: Invalidate cache + if: inputs.invalidate-cache == 'true' + shell: bash + run: | + rm -rf ${{steps.cache-virtualenv.outputs.virtualenv-directory}} + python -m venv ${{steps.cache-virtualenv.outputs.virtualenv-directory}} + - name: Install pip dependencies - if: steps.cache-virtualenv.outputs.cache-hit != 'true' + if: steps.cache-virtualenv.outputs.cache-hit != 'true' || inputs.invalidate-cache == 'true' shell: bash run: | python -m pip install --upgrade pip