Install tools in a virtualenv

Signed-off-by: Pedro Algarvio <palgarvio@vmware.com>
This commit is contained in:
Pedro Algarvio 2023-11-17 20:05:33 +00:00 committed by Pedro Algarvio
parent a0127c04f7
commit 7294d8bc72

View file

@ -37,27 +37,38 @@ runs:
with:
python-binary: python3
- name: Set `TOOLS_VIRTUALENV_CACHE_SEED`
- name: Define Cache Hash
id: venv-hash
shell: bash
run: |
TOOLS_VIRTUALENV_CACHE_SEED="${{ inputs.cache-prefix }}|${{ steps.get-python-version.outputs.version-sha256sum }}|${{ inputs.cache-suffix || '' }}"
echo "TOOLS_VIRTUALENV_CACHE_SEED=${TOOLS_VIRTUALENV_CACHE_SEED}" | tee -a "${GITHUB_ENV}"
VENV_NAME_HASH=$(echo "${{ inputs.cache-prefix }}|${{ github.workflow }}|${{
steps.get-python-version.outputs.version-sha256sum }}|${{ hashFiles('requirements/**/*.txt', 'tools/**/*.py') }}${{
inputs.cache-suffix || '' }}" | sha256sum | cut -d ' ' -f 1)
echo "TOOLS_VIRTUALENV_CACHE_SEED=$VENV_NAME_HASH" | tee -a "${GITHUB_ENV}"
echo "venv-hash=$VENV_NAME_HASH" | tee -a "${GITHUB_OUTPUT}"
- uses: ./.github/actions/cached-virtualenv
id: tools-virtualenv
with:
name: tools.${{ steps.venv-hash.outputs.venv-hash }}
cache-seed: tools|${{ steps.venv-hash.outputs.venv-hash }}
- name: Restore Python Tools Virtualenvs Cache
uses: actions/cache@v3
with:
path: ${{ inputs.cwd }}/.tools-venvs
key: ${{ inputs.cache-prefix }}|${{ github.workflow }}|tools-venvs|${{ steps.get-python-version.outputs.version-sha256sum }}|${{ hashFiles('requirements/**/*.txt', 'tools/**/*.py') }}${{ inputs.cache-suffix && format('|{0}', inputs.cache-suffix) || '' }}
key: ${{ inputs.cache-prefix }}|${{ steps.venv-hash.outputs.venv-hash }}
- name: Install 'python-tools-scripts'
shell: bash
working-directory: ${{ inputs.cwd }}
run: |
(python3 -m pip install --help | grep break-system-packages > /dev/null 2>&1) && exitcode=0 || exitcode=1
PYTHON_EXE=${{ steps.tools-virtualenv.outputs.python-executable }}
(${PYTHON_EXE} -m pip install --help | grep break-system-packages > /dev/null 2>&1) && exitcode=0 || exitcode=1
if [ $exitcode -eq 0 ]; then
python3 -m pip install --break-system-packages -r requirements/static/ci/py${{ steps.get-python-version.outputs.version }}/tools.txt
${PYTHON_EXE} -m pip install --break-system-packages -r requirements/static/ci/py${{ steps.get-python-version.outputs.version }}/tools.txt
else
python3 -m pip install -r requirements/static/ci/py${{ steps.get-python-version.outputs.version }}/tools.txt
${PYTHON_EXE} -m pip install -r requirements/static/ci/py${{ steps.get-python-version.outputs.version }}/tools.txt
fi
- name: Get 'python-tools-scripts' Version