Skip to content

Commit 18e2d2f

Browse files
Add test for python version file support
1 parent aeab159 commit 18e2d2f

File tree

3 files changed

+40
-2
lines changed

3 files changed

+40
-2
lines changed

.github/workflows/test.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,38 @@ jobs:
100100
101101
pip install requests
102102
pip3 install s4cmd
103+
104+
test_python_version_file:
105+
runs-on: ubuntu-latest
106+
container: amazonlinux:2023
107+
steps:
108+
- name: Setup runner
109+
run: |
110+
yum install -y git tar gzip sudo
111+
112+
- uses: actions/checkout@v3
113+
114+
- name: Create python version file
115+
run: |
116+
echo '3.11.5' > .python-version
117+
118+
- name: Install python
119+
uses: ./
120+
with:
121+
python-version-file: ".python-version"
122+
123+
- name: Test installation
124+
run: |
125+
set -x
126+
127+
which python3
128+
which python
129+
130+
python3 --version
131+
python --version
132+
133+
python3 --version 2>&1 | grep -F "3.11.5"
134+
test "$(python3 -m pip --version)" = "$(pip3 --version)"
135+
136+
python --version 2>&1 | grep -F "3.11.5"
137+
test "$(python3 -m pip --version)" = "$(pip --version)"

action.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ name: 'Setup python amazon linux'
22
description: 'setup-python action for amazon linux self hosted runners'
33
inputs:
44
python-version:
5+
description: 'Version of python to be installed. Reads from .python-version if unset.'
6+
python-version-file:
57
description: 'Version of python to be installed'
6-
required: true
8+
default: ".python-version"
79
cache:
810
description: Used to specify whether caching is needed. Set to true, if you'd like to enable caching.
911
required: true
@@ -20,7 +22,7 @@ runs:
2022
id: find-exact-python-version
2123
shell: bash
2224
run: |
23-
exact_python_version=$(${GITHUB_ACTION_PATH}/find-exact-python-version.sh "${{ inputs.python-version }}")
25+
exact_python_version=$(${GITHUB_ACTION_PATH}/find-exact-python-version.sh "${{ inputs.python-version }}" "${{ inputs.python-version-file }}")
2426
echo "exact_python_version=${exact_python_version}" >> $GITHUB_OUTPUT
2527
2628
- name: Set installation directory

find-exact-python-version.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
set -euo pipefail
44

55
specified_version="$1"
6+
specified_version_file="$2"
67

78
# This versions map should be kept in sync with
89
# - https://www.python.org/downloads/

0 commit comments

Comments
 (0)