Skip to content

Commit 0b9e717

Browse files
[CI] if latest contexts have changed, retrieve the previous contexts' test cache and then use ./setup_test_cache u to update (#1099)
* use `./setup_test_cache u` to update a previous existing cache * only clone cache test repo if cache not hit * don't uninstall crds just to install it again * always run `./setup_test_cache` with `u`
1 parent 21316d5 commit 0b9e717

File tree

1 file changed

+21
-25
lines changed

1 file changed

+21
-25
lines changed

.github/workflows/cache.yml

+21-25
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: test cache
1+
name: download CRDS test cache
22

33
on:
44
workflow_call:
@@ -43,7 +43,7 @@ jobs:
4343
repository: spacetelescope/crds
4444
- id: key
4545
run: echo "key=test-cache-${{ needs.contexts.outputs.hst }}-${{ needs.contexts.outputs.jwst }}" >> $GITHUB_OUTPUT
46-
- id: lookup-combined-cache
46+
- id: lookup-cache
4747
name: check for existence of combined CRDS cache (`${{ steps.key.outputs.key }}`)
4848
uses: actions/cache/restore@v4
4949
with:
@@ -52,26 +52,22 @@ jobs:
5252
${{ env.CRDS_TESTING_CACHE }}
5353
key: ${{ steps.key.outputs.key }}
5454
lookup-only: true
55-
- if: steps.lookup-combined-cache.outputs.cache-hit != 'true'
56-
id: crds-cache-test
55+
- if: steps.lookup-cache.outputs.cache-hit != 'true'
56+
id: retrieve-previous-cache
57+
name: retrieve a previous combined CRDS cache
58+
uses: actions/cache/restore@v4
59+
with:
60+
path: |
61+
${{ env.CRDS_PATH }}
62+
${{ env.CRDS_TESTING_CACHE }}
63+
key: ${{ steps.key.outputs.key }}
64+
restore-keys: |
65+
test-cache-
66+
- if: steps.retrieve-previous-cache.outputs.cache-matched-key == ''
5767
run: |
5868
git clone https://github.com/spacetelescope/crds-cache-test.git
5969
mv crds-cache-test ${{ env.CRDS_TEST_ROOT }}
60-
- if: steps.lookup-combined-cache.outputs.cache-hit != 'true'
61-
id: retrieve-hst-cache
62-
name: retrieve HST CRDS cache (`test-cache-${{ needs.contexts.outputs.hst }}`)
63-
uses: actions/cache@v4
64-
with:
65-
path: ${{ env.CRDS_PATH }}/**/hst*
66-
key: test-cache-${{ needs.contexts.outputs.hst }}
67-
- if: steps.lookup-combined-cache.outputs.cache-hit != 'true'
68-
id: retrieve-jwst-cache
69-
name: retrieve JWST CRDS cache (`test-cache-${{ needs.contexts.outputs.jwst }}`)
70-
uses: actions/cache@v4
71-
with:
72-
path: ${{ env.CRDS_PATH }}/**/jwst*
73-
key: test-cache-${{ needs.contexts.outputs.jwst }}
74-
- if: steps.lookup-combined-cache.outputs.cache-hit != 'true'
70+
- if: steps.lookup-cache.outputs.cache-hit != 'true'
7571
uses: mamba-org/setup-micromamba@v2
7672
with:
7773
environment-name: crds-testing
@@ -87,13 +83,13 @@ jobs:
8783
init-shell: bash
8884
cache-environment: true
8985
cache-downloads: true
90-
- if: steps.lookup-combined-cache.outputs.cache-hit != 'true'
86+
- if: steps.lookup-cache.outputs.cache-hit != 'true'
87+
run: ./install
88+
- if: steps.lookup-cache.outputs.cache-hit != 'true'
9189
run: pip install git+https://github.com/spacetelescope/jwst roman-datamodels
92-
- if: steps.lookup-combined-cache.outputs.cache-hit != 'true'
93-
run: pip uninstall --yes crds && ./install && pip install .
94-
- if: steps.lookup-combined-cache.outputs.cache-hit != 'true'
95-
run: ./setup_test_cache ${{ env.CRDS_TEST_ROOT }} ${{ (steps.retrieve-hst-cache.outputs.cache-hit == 'true' || steps.retrieve-jwst-cache.outputs.cache-hit == 'true') && 'u' || 'c' }}
96-
- if: steps.lookup-combined-cache.outputs.cache-hit != 'true'
90+
- if: steps.lookup-cache.outputs.cache-hit != 'true'
91+
run: ./setup_test_cache ${{ env.CRDS_TEST_ROOT }} u
92+
- if: steps.lookup-cache.outputs.cache-hit != 'true'
9793
name: save combined CRDS cache (`${{ steps.key.outputs.key }}`)
9894
uses: actions/cache/save@v4
9995
with:

0 commit comments

Comments
 (0)