Skip to content

Commit

Permalink
Compute cache key based on hash of ./pytest_cache
Browse files Browse the repository at this point in the history
pytest_cache should be saved whenever its contents changes. Cache saving only
triggers if the associated cache key changes; thus the cache key should
automatically update based on the contents of pytest_cache, which is
uniquely represented by its hash.
  • Loading branch information
kvrigor committed Oct 24, 2024
1 parent 70eeff4 commit 45d25b1
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ jobs:
id: cache-pytest-restore
uses: actions/cache/restore@v4
with:
key: pytest-${{ matrix.os }}-${{ matrix.python-version }}
key: pytest-${{ matrix.os }}-${{ matrix.python-version }}-${{ hashFiles('.pytest_cache/**') }}
path: "./.pytest_cache"

- name: Run coverage tests on macOS
Expand Down Expand Up @@ -226,10 +226,10 @@ jobs:
- name: Save Pytest cache
id: cache-pytest-save
if: always()
if: always() && steps.cache-primes-restore.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
key: ${{ steps.cache-pytest-restore.outputs.cache-primary-key }}
key: pytest-${{ matrix.os }}-${{ matrix.python-version }}-${{ hashFiles('.pytest_cache/**') }}
path: "./.pytest_cache"

- name: Remove test directory
Expand Down

0 comments on commit 45d25b1

Please sign in to comment.