diff --git a/.github/workflows/github_actions_linter.yml b/.github/workflows/github_actions_linter.yml index 0d93cc4..d241b2f 100644 --- a/.github/workflows/github_actions_linter.yml +++ b/.github/workflows/github_actions_linter.yml @@ -1,6 +1,7 @@ name: Lint GitHub Actions workflows -on: [ push ] +on: + - push jobs: actionlint: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b8226a0..5dade9e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 \ No newline at end of file diff --git a/action.yml b/action.yml index 3073d93..c00475d 100644 --- a/action.yml +++ b/action.yml @@ -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' @@ -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 diff --git a/find-desired-python-version.sh b/find-desired-python-version.sh index a479b68..0c0dfd9 100755 --- a/find-desired-python-version.sh +++ b/find-desired-python-version.sh @@ -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}" \ No newline at end of file