diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2cbb649..88ea2b9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -2,6 +2,13 @@ name: Test on: [ push ] +env: + # This is required to support GLIB versions present in amazon linux 2. Can be removed once amazon linux 2 is 💀 + # More info + # - https://github.com/actions/checkout/issues/1809#issuecomment-2208202462 + # - https://github.blog/changelog/2024-03-07-github-actions-all-actions-will-run-on-node20-instead-of-node16-by-default/ + ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true + jobs: test_python_installation: strategy: diff --git a/README.md b/README.md index 722e7b3..03fa0dd 100644 --- a/README.md +++ b/README.md @@ -59,4 +59,3 @@ will be used and hence will be very fast (4 to 5 seconds) ## Contributing Contributions are most welcome! See [CONTRIBUTING.md](./CONTRIBUTING.md) - diff --git a/action.yml b/action.yml index 8d23e57..e2507eb 100644 --- a/action.yml +++ b/action.yml @@ -30,30 +30,33 @@ runs: shell: bash run: | exact_python_version="${{ steps.find-exact-python-version.outputs.exact_python_version }}" - echo "installation_directory=~/setup-python-amazon-linux/.python-versions/${exact_python_version}" >> $GITHUB_OUTPUT + echo "installation_directory=${HOME}/.setup-python-amazon-linux/.python-versions/${exact_python_version}" >> $GITHUB_OUTPUT - name: Cache id: cache-python uses: actions/cache@v3 if: inputs.cache == 'true' with: - path: | - ${{ steps.set-installation-directory.outputs.installation_directory }} + path: ${{ steps.set-installation-directory.outputs.installation_directory }} key: python-${{ steps.find-exact-python-version.outputs.exact_python_version }}-${{ runner.arch }} - id: setup-python shell: bash if: inputs.cache == 'false' || (inputs.cache == 'true' && steps.cache-python.outputs.cache-hit != 'true') run: | - installation_directory=${{ steps.set-installation-directory.outputs.installation_directory }} - mkdir -p "${installation_directory}" + installation_directory="${{ steps.set-installation-directory.outputs.installation_directory }}" exact_python_version="${{ steps.find-exact-python-version.outputs.exact_python_version }}" - ${GITHUB_ACTION_PATH}/install-python.sh "${exact_python_version}" "${installation_directory}" + + # Using a separate tmp directory instead of /tmp because in some OS images set a noexec option for the mount + # this is a better way compared to changing the mount options of /tmp + tmp_directory="${HOME}/.setup-python-amazon-linux/tmp" + + ${GITHUB_ACTION_PATH}/install-python.sh "${exact_python_version}" "${installation_directory}" "${tmp_directory}" - name: Add python to PATH shell: bash run: | - installation_directory=${{ steps.set-installation-directory.outputs.installation_directory }} + installation_directory="${{ steps.set-installation-directory.outputs.installation_directory }}" echo "${installation_directory}/bin" >> "${GITHUB_PATH}" echo "The following python binaries are now available in the PATH" diff --git a/install-python.sh b/install-python.sh index d14ab32..1f3b066 100755 --- a/install-python.sh +++ b/install-python.sh @@ -9,11 +9,16 @@ function set_aliases() { # Reference - https://realpython.com/installing-python/#how-to-build-python-from-source-code function setup_python() { - python_version="$1" - python_installation_dir="$2" + python_version="${1:?}" + python_installation_dir="${2:?}" + temp_dir="${3:?}" mkdir -p "${python_installation_dir}" - temp_dir=$(mktemp -d) + mkdir -p "${temp_dir}" + rm -rf "${python_installation_dir:?}/*" + rm -rf "${temp_dir:?}/*" + + echo "Installing python from temporary directory ${temp_dir}" pushd "${temp_dir}" >/dev/null wget "https://www.python.org/ftp/python/${python_version}/Python-${python_version}.tgz" tar -zxf "Python-${python_version}.tgz" @@ -34,4 +39,4 @@ function setup_python() { set_aliases } -setup_python "$1" "$2" +setup_python "$1" "$2" "$3"