Skip to content

Commit

Permalink
Make caching feature node version agnostic
Browse files Browse the repository at this point in the history
  • Loading branch information
kishaningithub committed Aug 20, 2024
1 parent 543ccf0 commit 9859f7c
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 52 deletions.
24 changes: 18 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ on:
pull_request:
branches: [main]

env:
#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
# ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true

jobs:
test_python_installation:
Expand All @@ -32,7 +32,10 @@ jobs:
run: |
yum install -y git tar gzip sudo which
- uses: actions/checkout@v3
- name: Checkout
run: |
git clone --depth 1 "https://github.com/${GITHUB_REPOSITORY}.git" "${GITHUB_WORKSPACE}"
git checkout "${GITHUB_SHA}"
- name: Install python
uses: ./
Expand Down Expand Up @@ -79,7 +82,10 @@ jobs:
- name: Setup runner
run: yum install -y git tar gzip sudo

- uses: actions/checkout@v3
- name: Checkout
run: |
git clone --depth 1 "https://github.com/${GITHUB_REPOSITORY}.git" "${GITHUB_WORKSPACE}"
git checkout "${GITHUB_SHA}"
- name: Install python
uses: ./
Expand All @@ -105,7 +111,10 @@ jobs:
run: |
yum install -y git tar gzip sudo
- uses: actions/checkout@v3
- name: Checkout
run: |
git clone --depth 1 "https://github.com/${GITHUB_REPOSITORY}.git" "${GITHUB_WORKSPACE}"
git checkout "${GITHUB_SHA}"
- name: Install python
uses: ./
Expand All @@ -129,7 +138,10 @@ jobs:
run: |
yum install -y git tar gzip sudo
- uses: actions/checkout@v3
- name: Checkout
run: |
git clone --depth 1 "https://github.com/${GITHUB_REPOSITORY}.git" "${GITHUB_WORKSPACE}"
git checkout "${GITHUB_SHA}"
- name: Create python version file
run: |
Expand Down
92 changes: 46 additions & 46 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,53 +18,53 @@ runs:
run: |
${GITHUB_ACTION_PATH}/install-system-dependencies.sh
- name: Find exact python version
id: find-exact-python-version
shell: bash
run: |
exact_python_version=$(${GITHUB_ACTION_PATH}/find-exact-python-version.sh "${{ inputs.python-version }}" "${{ inputs.python-version-file }}")
echo "exact_python_version=${exact_python_version}" >> $GITHUB_OUTPUT
- name: Set installation directory
id: set-installation-directory
shell: bash
run: |
exact_python_version="${{ steps.find-exact-python-version.outputs.exact_python_version }}"
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 }}
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 }}"
exact_python_version="${{ steps.find-exact-python-version.outputs.exact_python_version }}"
# 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 }}"
echo "${installation_directory}/bin" >> "${GITHUB_PATH}"
# - name: Find exact python version
# id: find-exact-python-version
# shell: bash
# run: |
# exact_python_version=$(${GITHUB_ACTION_PATH}/find-exact-python-version.sh "${{ inputs.python-version }}" "${{ inputs.python-version-file }}")
# echo "exact_python_version=${exact_python_version}" >> $GITHUB_OUTPUT
#
# - name: Set installation directory
# id: set-installation-directory
# shell: bash
# run: |
# exact_python_version="${{ steps.find-exact-python-version.outputs.exact_python_version }}"
# 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 }}
# key: python-${{ steps.find-exact-python-version.outputs.exact_python_version }}-${{ runner.arch }}

echo "The following python binaries are now available in the PATH"
ls "${installation_directory}/bin"
echo "Linking python libraries..."
ls "${installation_directory}/lib"
sudo ldconfig "${installation_directory}/lib"
# - 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 }}"
# exact_python_version="${{ steps.find-exact-python-version.outputs.exact_python_version }}"
#
# # 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 }}"
# echo "${installation_directory}/bin" >> "${GITHUB_PATH}"
#
# echo "The following python binaries are now available in the PATH"
# ls "${installation_directory}/bin"
#
# echo "Linking python libraries..."
# ls "${installation_directory}/lib"
# sudo ldconfig "${installation_directory}/lib"

branding:
icon: 'code'
Expand Down

0 comments on commit 9859f7c

Please sign in to comment.