Skip to content

Commit

Permalink
Explicitly save cache in primer jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobtylerwalls committed Sep 18, 2024
1 parent 67acc96 commit 46a37ed
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 5 deletions.
27 changes: 24 additions & 3 deletions .github/workflows/primer_run_main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ jobs:
check-latest: true

# Create a re-usable virtual environment
- name: Create Python virtual environment cache
- name: Restore Python virtual environment cache
id: cache-venv
uses: actions/[email protected]
uses: actions/cache/restore@v4.0.2
with:
path: venv
key:
Expand All @@ -60,6 +60,18 @@ jobs:
. venv/bin/activate
python -m pip install -U pip setuptools wheel
pip install -U -r requirements_test.txt
# Save cached Python environment (explicit because cancel-in-progress: true)
- name: Save Python virtual environment to cache
if: steps.cache-venv.outputs.cache-hit != 'true'
id: cache-venv
uses: actions/cache/[email protected]
with:
path: venv
key:
${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{
env.KEY_PREFIX }}-${{ env.CACHE_VERSION }}-${{ hashFiles('pyproject.toml',
'requirements_test.txt', 'requirements_test_min.txt',
'requirements_test_pre_commit.txt') }}

# Cache primer packages
- name: Get commit string
Expand All @@ -71,7 +83,7 @@ jobs:
echo "commitstring=$output" >> $GITHUB_OUTPUT
- name: Restore projects cache
id: cache-projects
uses: actions/[email protected]
uses: actions/cache/restore@v4.0.2
with:
path: tests/.pylint_primer_tests/
key: >-
Expand All @@ -82,6 +94,15 @@ jobs:
run: |
. venv/bin/activate
python tests/primer/__main__.py prepare --clone
- name: Save projects cache
if: steps.cache-projects.outputs.cache-hit != 'true'
id: cache-projects
uses: actions/cache/[email protected]
with:
path: tests/.pylint_primer_tests/
key: >-
${{ runner.os }}-${{ matrix.python-version }}-${{
steps.commitstring.outputs.commitstring }}-primer
- name: Upload commit string
uses: actions/[email protected]
if: matrix.batchIdx == 0
Expand Down
24 changes: 22 additions & 2 deletions .github/workflows/primer_run_pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
# Restore cached Python environment
- name: Restore Python virtual environment
id: cache-venv
uses: actions/[email protected]
uses: actions/cache/restore@v4.0.2
with:
path: venv
key:
Expand All @@ -72,6 +72,18 @@ jobs:
. venv/bin/activate
python -m pip install -U pip setuptools wheel
pip install -U -r requirements_test.txt
# Save cached Python environment (explicit because cancel-in-progress: true)
- name: Save Python virtual environment
if: steps.cache-venv.outputs.cache-hit != 'true'
id: cache-venv
uses: actions/cache/[email protected]
with:
path: venv
key:
${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{
env.KEY_PREFIX }}-${{ env.CACHE_VERSION }}-${{ hashFiles('pyproject.toml',
'requirements_test.txt', 'requirements_test_min.txt',
'requirements_test_pre_commit.txt') }}

# Cache primer packages
- name: Download last 'main' run info
Expand Down Expand Up @@ -140,7 +152,7 @@ jobs:
echo "commitstring=$output" >> $GITHUB_OUTPUT
- name: Restore projects cache
id: cache-projects
uses: actions/[email protected]
uses: actions/cache/restore@v4.0.2
with:
path: tests/.pylint_primer_tests/
key: >-
Expand All @@ -151,6 +163,14 @@ jobs:
run: |
. venv/bin/activate
python tests/primer/__main__.py prepare --clone
- name: Save projects cache
if: steps.cache-projects.outputs.cache-hit != 'true'
uses: actions/cache/[email protected]
with:
path: tests/.pylint_primer_tests/
key: >-
${{ runner.os }}-${{ matrix.python-version }}-${{
steps.commitstring.outputs.commitstring }}-primer
- name: Check cache
run: |
. venv/bin/activate
Expand Down

0 comments on commit 46a37ed

Please sign in to comment.