Skip to content

Commit

Permalink
Quote vars to support values with spaces (#571)
Browse files Browse the repository at this point in the history
  • Loading branch information
EnricoMi authored Feb 6, 2024
1 parent 5724834 commit af4a2cf
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions composite/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -158,22 +158,22 @@ runs:
# we check version here just to execute `python3` with an argument
# on Windows, there is a `python3.exe` that is a proxy to trigger installation from app store
# command `which python3` finds that, but `python3 -V` does not return the version on stdout
if ! which python3 || [[ $(python3 -V) != *"python 3."* && $(python3 -V) != *"Python 3."* ]]
if ! which python3 || [[ "$(python3 -V)" != *"python 3."* && "$(python3 -V)" != *"Python 3."* ]]
then
if ! which python || [[ $(python -V) != *"python 3."* && $(python -V) != *"Python 3."* ]]
if ! which python || [[ "$(python -V)" != *"python 3."* && "$(python -V)" != *"Python 3."* ]]
then
echo "::error::No python3 interpreter found. Please setup python before running this action. You could use https://github.com/actions/setup-python."
exit 1
fi
PYTHON_BIN=$(python -c 'import sys; print(sys.executable)')
PYTHON_BIN="$(python -c 'import sys; print(sys.executable)')"
else
PYTHON_BIN=$(python3 -c 'import sys; print(sys.executable)')
PYTHON_BIN="$(python3 -c 'import sys; print(sys.executable)')"
fi
echo "Python that creates venv: $PYTHON_BIN"
echo "PYTHON_BIN=$PYTHON_BIN" >> $GITHUB_ENV
echo "version=$($PYTHON_BIN -V)" >> $GITHUB_OUTPUT
echo "PYTHON_BIN=$PYTHON_BIN" >> "$GITHUB_ENV"
echo "version=$("$PYTHON_BIN" -V)" >> "$GITHUB_OUTPUT"
echo '##[endgroup]'
shell: bash

Expand All @@ -182,14 +182,14 @@ runs:
run: |
case "$RUNNER_OS" in
Linux*)
echo "pip-cache=~/.cache/pip" >> $GITHUB_OUTPUT
echo "pip-cache=~/.cache/pip" >> "$GITHUB_OUTPUT"
;;
macOS*)
echo "pip-cache=~/Library/Caches/pip" >> $GITHUB_OUTPUT
echo "pip-cache=~/Library/Caches/pip" >> "$GITHUB_OUTPUT"
;;
Windows*)
echo "pip-cache=~\\AppData\\Local\\pip\\Cache" >> $GITHUB_OUTPUT
echo "pip-options=--user" >> $GITHUB_OUTPUT
echo "pip-cache=~\\AppData\\Local\\pip\\Cache" >> "$GITHUB_OUTPUT"
echo "pip-options=--user" >> "$GITHUB_OUTPUT"
;;
esac
shell: bash
Expand All @@ -212,16 +212,16 @@ runs:
echo "Python that creates venv: $PYTHON_BIN"
echo "Creating virtual environment"
if ! $PYTHON_BIN -m virtualenv enricomi-publish-action-venv && ! $PYTHON_BIN -m venv enricomi-publish-action-venv
if ! "$PYTHON_BIN" -m virtualenv enricomi-publish-action-venv && ! "$PYTHON_BIN" -m venv enricomi-publish-action-venv
then
echo "Looks like there is neither virtualenv nor venv package installed"
if ! $PYTHON_BIN -m pip install $PIP_OPTIONS virtualenv && [ -n "$PIP_OPTIONS" ]
if ! "$PYTHON_BIN" -m pip install $PIP_OPTIONS virtualenv && [ -n "$PIP_OPTIONS" ]
then
echo "Installing virtualenv package with PIP options '$PIP_OPTIONS' failed, now trying without"
$PYTHON_BIN -m pip install virtualenv
"$PYTHON_BIN" -m pip install virtualenv
fi
if ! $PYTHON_BIN -m virtualenv enricomi-publish-action-venv
if ! "$PYTHON_BIN" -m virtualenv enricomi-publish-action-venv
then
echo "Still cannot create venv after installing virtualenv package"
exit 1
Expand All @@ -235,26 +235,26 @@ runs:
Windows*)
PYTHON_VENV="enricomi-publish-action-venv\\Scripts\\python";;
esac
PYTHON_VENV=$($PYTHON_VENV -c 'import sys; print(sys.executable)')
PYTHON_VENV="$("$PYTHON_VENV" -c 'import sys; print(sys.executable)')"
echo "Python in venv: $PYTHON_VENV"
echo "PYTHON_VENV=$PYTHON_VENV" >> $GITHUB_ENV
echo "PYTHON_VENV=$PYTHON_VENV" >> "$GITHUB_ENV"
echo '##[endgroup]'
shell: bash

- name: Install Python dependencies
run: |
echo '##[group]Install Python dependencies'
# make sure wheel is installed, which improves installing our dependencies
$PYTHON_VENV -m pip install wheel
$PYTHON_VENV -m pip install -r $GITHUB_ACTION_PATH/../python/requirements.txt
"$PYTHON_VENV" -m pip install wheel
"$PYTHON_VENV" -m pip install -r "$GITHUB_ACTION_PATH/../python/requirements.txt"
echo '##[endgroup]'
shell: bash

- name: Publish Test Results
id: test-results
run: |
echo '##[group]Publish Test Results'
$PYTHON_VENV $GITHUB_ACTION_PATH/../python/publish_test_results.py
"$PYTHON_VENV" "$GITHUB_ACTION_PATH/../python/publish_test_results.py"
echo '##[endgroup]'
env:
GITHUB_TOKEN: ${{ inputs.github_token }}
Expand Down

0 comments on commit af4a2cf

Please sign in to comment.