Skip to content

Commit 9768589

Browse files
szb640Bence Szikszaibkeryanmshafer-NI
authored
Use temporary directory for Poetry installs (#41)
* Use temporary directory. * Convert to bash. * Add a poetry_config variable Co-authored-by: mshafer-NI <[email protected]> --------- Co-authored-by: Bence Szikszai <[email protected]> Co-authored-by: Brad Keryan <[email protected]> Co-authored-by: mshafer-NI <[email protected]>
1 parent f6f8738 commit 9768589

File tree

1 file changed

+17
-27
lines changed

1 file changed

+17
-27
lines changed

setup-poetry/action.yml

Lines changed: 17 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -24,34 +24,24 @@ runs:
2424
exit 1
2525
fi
2626
shell: bash
27-
- name: Set paths (Linux/Mac)
28-
if: runner.os != 'Windows'
27+
- name: Set paths
2928
run: |
30-
# Use the "pipeline directory" so that tools that search the workspace
31-
# directory for Python files will not find the Poetry cache. Use
32-
# realpath to normalize the "../".
33-
PIPELINE_DIR="$(realpath $GITHUB_WORKSPACE/..)"
34-
POETRY_ROOT="$PIPELINE_DIR/.cache/poetry"
35-
echo "POETRY_BIN_DIR=$POETRY_ROOT/bin" >> "$GITHUB_ENV"
36-
echo "POETRY_CONFIG_DIR=$POETRY_ROOT/config" >> "$GITHUB_ENV"
37-
echo "POETRY_HOME=$POETRY_ROOT/home" >> "$GITHUB_ENV"
38-
echo "POETRY_HOME_BIN=$POETRY_ROOT/home/bin" >> "$GITHUB_ENV"
39-
echo "$POETRY_ROOT/bin" >> "$GITHUB_PATH"
29+
poetry_root="$RUNNER_TEMP/poetry"
30+
poetry_home="$poetry_root/home"
31+
poetry_bin="$poetry_root/bin"
32+
poetry_config="$poetry_root/config"
33+
if [[ "$RUNNER_OS" == "Windows" ]]; then
34+
binary_folder_name="Scripts"
35+
else
36+
binary_folder_name="bin"
37+
fi
38+
39+
echo "POETRY_BIN_DIR=$poetry_bin" >> "$GITHUB_ENV"
40+
echo "POETRY_CONFIG_DIR=$poetry_config" >> "$GITHUB_ENV"
41+
echo "POETRY_HOME=$poetry_home" >> "$GITHUB_ENV"
42+
echo "POETRY_HOME_BIN=$poetry_home/$binary_folder_name" >> "$GITHUB_ENV"
43+
echo "$poetry_bin" >> "$GITHUB_PATH"
4044
shell: bash
41-
- name: Set paths (Windows)
42-
if: runner.os == 'Windows'
43-
run: |
44-
# Use the "pipeline directory" so that tools that search the workspace
45-
# directory for Python files will not find the Poetry cache. Use
46-
# Resolve-Path to normalize the "../".
47-
$PIPELINE_DIR = (Resolve-Path -Path "$env:GITHUB_WORKSPACE\..").Path
48-
$POETRY_ROOT = "$PIPELINE_DIR\.cache\poetry"
49-
Add-Content $env:GITHUB_ENV "POETRY_BIN_DIR=$POETRY_ROOT\bin"
50-
Add-Content $env:GITHUB_ENV "POETRY_CONFIG_DIR=$POETRY_ROOT\config"
51-
Add-Content $env:GITHUB_ENV "POETRY_HOME=$POETRY_ROOT\home"
52-
Add-Content $env:GITHUB_ENV "POETRY_HOME_BIN=$POETRY_ROOT\home\Scripts"
53-
Add-Content $env:GITHUB_PATH "$POETRY_ROOT\bin"
54-
shell: pwsh
5545
- name: Copy paths from $GITHUB_ENV to $GITHUB_OUTPUT
5646
id: copy-paths
5747
run: |
@@ -88,4 +78,4 @@ runs:
8878
echo "RUNNER_TEMP=$RUNNER_TEMP"
8979
echo "RUNNER_TOOL_CACHE=$RUNNER_TOOL_CACHE"
9080
ls -al "$POETRY_BIN_DIR" "$POETRY_HOME" "$POETRY_HOME_BIN" || true
91-
shell: bash
81+
shell: bash

0 commit comments

Comments
 (0)