Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/github_actions_linter.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Lint GitHub Actions workflows

on: [ push ]
on:
- push

jobs:
actionlint:
Expand Down
62 changes: 62 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,65 @@ jobs:

python --version 2>&1 | grep -F "3.11.5"
test "$(python3 -m pip --version)" = "$(pip --version)"

test_python_resolution_order:
runs-on: ubuntu-latest
container: amazonlinux:2023
steps:
- name: Setup runner
run: |
yum install -y git sudo tar gzip which

- name: Checkout
run: |
git clone --depth 1 -b "${GITHUB_HEAD_REF:-$GITHUB_REF_NAME}" "https://github.com/${GITHUB_REPOSITORY}.git" .

- name: Create python version file
run: |
echo '3.12' > .python-version

- name: Install python
uses: ./
with:
python-version: "3.13"

- name: Test python version
run: |
set -x

which python3
which python

python3 --version
python --version

python3 --version 2>&1 | grep -F "3.13"

test_invalid_action_input:
runs-on: ubuntu-latest
container: amazonlinux:2023
steps:
- name: Setup runner
run: |
yum install -y git sudo tar gzip which

- name: Checkout
run: |
git clone --depth 1 -b "${GITHUB_HEAD_REF:-$GITHUB_REF_NAME}" "https://github.com/${GITHUB_REPOSITORY}.git" .

- name: Install python
id: test-installation
continue-on-error: true
uses: ./

- name: Test python version
shell: bash
run: |
set -x

if [[ "${{ steps.test-installation.outcome }}" == "success" ]]; then
echo "error: The action should have failed because both python-version and python-version-file were not given but it has suceeded."
exit 1
else
echo "success: The action successfully failed because both python-version and python-version-file were not given"
fi
7 changes: 3 additions & 4 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: 'Setup python amazon linux'
description: 'setup-python action for amazon linux self hosted runners'
inputs:
python-version:
description: 'Version of python to be installed. Reads from .python-version if unset.'
description: 'Version of python to be installed. Reads from python-version-file if unset.'
python-version-file:
description: 'Version of python to be installed'
default: '.python-version'
Expand All @@ -26,9 +26,8 @@ runs:
run: |
installation_directory="${{ github.action_path }}/.setup-python-amazon-linux/uv"
echo "Installing uv.. installation_directory=${installation_directory}"
uv_version="0.8.18"
# HOME is set to foobar till this is resolved https://github.com/astral-sh/uv/issues/6965#issuecomment-2915796022
curl -LsSf "https://github.com/astral-sh/uv/releases/download/${uv_version}/uv-installer.sh" | HOME="foobar" UV_UNMANAGED_INSTALL="${installation_directory}" bash --login
uv_version="0.9.13"
curl -LsSf "https://github.com/astral-sh/uv/releases/download/${uv_version}/uv-installer.sh" | UV_UNMANAGED_INSTALL="${installation_directory}" bash --login
echo "${installation_directory}" >> "${GITHUB_PATH}"

- name: Find desired python version
Expand Down
8 changes: 7 additions & 1 deletion find-desired-python-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,14 @@ specified_version="$1"
specified_version_file="$2"

desired_python_version="${specified_version}"
if [ -f "${specified_version_file}" ]; then

if [[ -z "${desired_python_version}" && -f "${specified_version_file}" ]]; then
desired_python_version=$(cat "${specified_version_file}")
fi

if [[ -z "${desired_python_version}" ]]; then
echo "❌ error: Both inputs .python-version and .python-version-file are not given. Kindly provide one of them." >&2
exit 1
fi

echo "${desired_python_version}"
Loading