Skip to content

Commit

Permalink
[CI] if latest contexts have changed, retrieve the previous contexts'…
Browse files Browse the repository at this point in the history
… 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`
  • Loading branch information
zacharyburnett authored Nov 27, 2024
1 parent 21316d5 commit 0b9e717
Showing 1 changed file with 21 additions and 25 deletions.
46 changes: 21 additions & 25 deletions .github/workflows/cache.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: test cache
name: download CRDS test cache

on:
workflow_call:
Expand Down Expand Up @@ -43,7 +43,7 @@ jobs:
repository: spacetelescope/crds
- id: key
run: echo "key=test-cache-${{ needs.contexts.outputs.hst }}-${{ needs.contexts.outputs.jwst }}" >> $GITHUB_OUTPUT
- id: lookup-combined-cache
- id: lookup-cache
name: check for existence of combined CRDS cache (`${{ steps.key.outputs.key }}`)
uses: actions/cache/restore@v4
with:
Expand All @@ -52,26 +52,22 @@ jobs:
${{ env.CRDS_TESTING_CACHE }}
key: ${{ steps.key.outputs.key }}
lookup-only: true
- if: steps.lookup-combined-cache.outputs.cache-hit != 'true'
id: crds-cache-test
- if: steps.lookup-cache.outputs.cache-hit != 'true'
id: retrieve-previous-cache
name: retrieve a previous combined CRDS cache
uses: actions/cache/restore@v4
with:
path: |
${{ env.CRDS_PATH }}
${{ env.CRDS_TESTING_CACHE }}
key: ${{ steps.key.outputs.key }}
restore-keys: |
test-cache-
- if: steps.retrieve-previous-cache.outputs.cache-matched-key == ''
run: |
git clone https://github.com/spacetelescope/crds-cache-test.git
mv crds-cache-test ${{ env.CRDS_TEST_ROOT }}
- if: steps.lookup-combined-cache.outputs.cache-hit != 'true'
id: retrieve-hst-cache
name: retrieve HST CRDS cache (`test-cache-${{ needs.contexts.outputs.hst }}`)
uses: actions/cache@v4
with:
path: ${{ env.CRDS_PATH }}/**/hst*
key: test-cache-${{ needs.contexts.outputs.hst }}
- if: steps.lookup-combined-cache.outputs.cache-hit != 'true'
id: retrieve-jwst-cache
name: retrieve JWST CRDS cache (`test-cache-${{ needs.contexts.outputs.jwst }}`)
uses: actions/cache@v4
with:
path: ${{ env.CRDS_PATH }}/**/jwst*
key: test-cache-${{ needs.contexts.outputs.jwst }}
- if: steps.lookup-combined-cache.outputs.cache-hit != 'true'
- if: steps.lookup-cache.outputs.cache-hit != 'true'
uses: mamba-org/setup-micromamba@v2
with:
environment-name: crds-testing
Expand All @@ -87,13 +83,13 @@ jobs:
init-shell: bash
cache-environment: true
cache-downloads: true
- if: steps.lookup-combined-cache.outputs.cache-hit != 'true'
- if: steps.lookup-cache.outputs.cache-hit != 'true'
run: ./install
- if: steps.lookup-cache.outputs.cache-hit != 'true'
run: pip install git+https://github.com/spacetelescope/jwst roman-datamodels
- if: steps.lookup-combined-cache.outputs.cache-hit != 'true'
run: pip uninstall --yes crds && ./install && pip install .
- if: steps.lookup-combined-cache.outputs.cache-hit != 'true'
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' }}
- if: steps.lookup-combined-cache.outputs.cache-hit != 'true'
- if: steps.lookup-cache.outputs.cache-hit != 'true'
run: ./setup_test_cache ${{ env.CRDS_TEST_ROOT }} u
- if: steps.lookup-cache.outputs.cache-hit != 'true'
name: save combined CRDS cache (`${{ steps.key.outputs.key }}`)
uses: actions/cache/save@v4
with:
Expand Down

0 comments on commit 0b9e717

Please # to comment.