File tree Expand file tree Collapse file tree 4 files changed +74
-6
lines changed Expand file tree Collapse file tree 4 files changed +74
-6
lines changed Original file line number Diff line number Diff line change 11name : Lint GitHub Actions workflows
22
3- on : [ push ]
3+ on :
4+ - push
45
56jobs :
67 actionlint :
Original file line number Diff line number Diff line change @@ -119,3 +119,65 @@ jobs:
119119
120120 python --version 2>&1 | grep -F "3.11.5"
121121 test "$(python3 -m pip --version)" = "$(pip --version)"
122+
123+ test_python_resolution_order :
124+ runs-on : ubuntu-latest
125+ container : amazonlinux:2023
126+ steps :
127+ - name : Setup runner
128+ run : |
129+ yum install -y git sudo tar gzip which
130+
131+ - name : Checkout
132+ run : |
133+ git clone --depth 1 -b "${GITHUB_HEAD_REF:-$GITHUB_REF_NAME}" "https://github.com/${GITHUB_REPOSITORY}.git" .
134+
135+ - name : Create python version file
136+ run : |
137+ echo '3.12' > .python-version
138+
139+ - name : Install python
140+ uses : ./
141+ with :
142+ python-version : " 3.13"
143+
144+ - name : Test python version
145+ run : |
146+ set -x
147+
148+ which python3
149+ which python
150+
151+ python3 --version
152+ python --version
153+
154+ python3 --version 2>&1 | grep -F "3.13"
155+
156+ test_invalid_action_input :
157+ runs-on : ubuntu-latest
158+ container : amazonlinux:2023
159+ steps :
160+ - name : Setup runner
161+ run : |
162+ yum install -y git sudo tar gzip which
163+
164+ - name : Checkout
165+ run : |
166+ git clone --depth 1 -b "${GITHUB_HEAD_REF:-$GITHUB_REF_NAME}" "https://github.com/${GITHUB_REPOSITORY}.git" .
167+
168+ - name : Install python
169+ id : test-installation
170+ continue-on-error : true
171+ uses : ./
172+
173+ - name : Test python version
174+ shell : bash
175+ run : |
176+ set -x
177+
178+ if [[ "${{ steps.test-installation.outcome }}" == "success" ]]; then
179+ echo "error: The action should have failed because both python-version and python-version-file were not given but it has suceeded."
180+ exit 1
181+ else
182+ echo "success: The action successfully failed because both python-version and python-version-file were not given"
183+ fi
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ name: 'Setup python amazon linux'
22description : ' setup-python action for amazon linux self hosted runners'
33inputs :
44 python-version :
5- description : ' Version of python to be installed. Reads from . python-version if unset.'
5+ description : ' Version of python to be installed. Reads from python-version-file if unset.'
66 python-version-file :
77 description : ' Version of python to be installed'
88 default : ' .python-version'
2626 run : |
2727 installation_directory="${{ github.action_path }}/.setup-python-amazon-linux/uv"
2828 echo "Installing uv.. installation_directory=${installation_directory}"
29- uv_version="0.8.18"
30- # HOME is set to foobar till this is resolved https://github.com/astral-sh/uv/issues/6965#issuecomment-2915796022
31- curl -LsSf "https://github.com/astral-sh/uv/releases/download/${uv_version}/uv-installer.sh" | HOME="foobar" UV_UNMANAGED_INSTALL="${installation_directory}" bash --login
29+ uv_version="0.9.13"
30+ curl -LsSf "https://github.com/astral-sh/uv/releases/download/${uv_version}/uv-installer.sh" | UV_UNMANAGED_INSTALL="${installation_directory}" bash --login
3231 echo "${installation_directory}" >> "${GITHUB_PATH}"
3332
3433 - name : Find desired python version
Original file line number Diff line number Diff line change @@ -6,8 +6,14 @@ specified_version="$1"
66specified_version_file=" $2 "
77
88desired_python_version=" ${specified_version} "
9- if [ -f " ${specified_version_file} " ]; then
9+
10+ if [[ -z " ${desired_python_version} " && -f " ${specified_version_file} " ]]; then
1011 desired_python_version=$( cat " ${specified_version_file} " )
1112fi
1213
14+ if [[ -z " ${desired_python_version} " ]]; then
15+ echo " ❌ error: Both inputs .python-version and .python-version-file are not given. Kindly provide one of them." >&2
16+ exit 1
17+ fi
18+
1319echo " ${desired_python_version} "
You can’t perform that action at this time.
0 commit comments