Skip to content

Commit 7f86caf

Browse files
committed
Use other pyenv in workflow.
1 parent de7a2ce commit 7f86caf

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

.github/actions/unittests/action.yml

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,30 @@ runs:
1111
- name: Checkout code
1212
uses: actions/checkout@v4
1313

14-
- name: Install .python-version and ${{ inputs.python-version }}
15-
uses: "gabrielfalcao/pyenv-action@v18"
16-
with:
17-
default: 3.7.17
18-
versions: ${{ inputs.python-version }}
14+
- name: Install pyenv from source
15+
run: |
16+
git clone https://github.com/pyenv/pyenv.git ~/.pyenv
17+
echo "PYENV_ROOT=$HOME/.pyenv" >> $GITHUB_ENV
18+
echo "$HOME/.pyenv/bin" >> $GITHUB_PATH
19+
shell: bash
1920

20-
- name: Switch to .python-version
21+
- name: Install Python ${{ inputs.python-version }} via pyenv
2122
run: |
22-
pyenv local "$(cat .python-version)"
23-
if python -V | grep -q "$(cat .python-version)"; then
24-
echo "Python version is '$(python -V)'"
25-
else
26-
echo "Python version is '$(python -V)', but should be '$(cat .python-version)'. Exiting workflow."
23+
export PYENV_ROOT="$HOME/.pyenv"
24+
export PATH="$PYENV_ROOT/bin:$PATH"
25+
eval "$(pyenv init --path)"
26+
pyenv install -s ${{ inputs.python-version }}
27+
pyenv global ${{ inputs.python-version }}
28+
echo "${{ inputs.python-version }}" > .python-version
29+
shell: bash
30+
31+
- name: Verify installed Python version
32+
run: |
33+
ACTUAL=$(python -V)
34+
EXPECTED=${{ inputs.python-version }}
35+
echo "Python version installed: $ACTUAL"
36+
if ! python -V | grep -q "$EXPECTED"; then
37+
echo "Python version is not correct. Exiting."
2738
exit 1
2839
fi
2940
shell: bash

0 commit comments

Comments
 (0)