Skip to content

Commit

Permalink
Merge pull request #15 from HassanAbouelela/fix-cache
Browse files Browse the repository at this point in the history
Fix Caching Issues
  • Loading branch information
HassanAbouelela committed Dec 14, 2022
2 parents 855672d + 4611290 commit cd059e8
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 32 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/test_setup_python.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,14 @@ jobs:
cache_hit_pre:
name: Setup Cache
runs-on: ubuntu-latest
outputs:
python_version: ${{ steps.python.outputs.python-version }}

steps:
- uses: actions/checkout@v3

- name: Setup Python
id: python
uses: ./setup-python
with:
install_args: "--without dev"
Expand All @@ -90,7 +93,11 @@ jobs:
uses: ./setup-python
with:
install_args: "--without dev"
python_version: '3.10'
# The python version must explicitly be specified using the setup's version,
# since the underlying setup action can sometimes use different patch versions randomly.
# I.e: the setup-python action can use 3.10.9 on one run, and 3.10.8 on the next,
# even if both are specified as 3.10.
python_version: ${{ needs.cache_hit_pre.outputs.python_version }}
working_dir: setup-python/tests/

- name: Check For Cache hit
Expand Down
7 changes: 4 additions & 3 deletions setup-python/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ runs:
with:
path: |
~/.cache/pypoetry
~/.cache/py-user-base
~/.cache/pip
key: "python-${{ runner.os }}-v1.3.4b1-\
${{ steps.python_setup.outputs.python-version }}-${{ inputs.dev }}-${{ inputs.working_dir }}-${{ inputs.poetry_version }}-${{ inputs.install_args }}-\
${{ hashFiles(format('{0}/pyproject.toml', inputs.working_dir), format('{0}/poetry.lock', inputs.working_dir)) }}"
Expand Down Expand Up @@ -94,8 +94,9 @@ runs:
if [ "${{ steps.python_cache.outputs.cache-hit }}" = "true" ]; then
if [ "${{ inputs.use_cache }}" = "false" ]; then
echo "Caching not enbaled, deleting cache."
rm -rf ~/.cache/py-user-base
rm -rf ~/.cache/pre-commit
rm -rf ~/.cache/pypoetry
rm -rf ~/.cache/pip
rm -rf ~/.cache/pre-commit
else
echo "Cache hit, skipping install."
exit
Expand Down
47 changes: 19 additions & 28 deletions setup-python/tests/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit cd059e8

Please sign in to comment.