test cache #56
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: test cache | |
on: | |
workflow_call: | |
outputs: | |
path: | |
value: ${{ jobs.cache.outputs.path }} | |
testing_cache: | |
value: ${{ jobs.cache.outputs.testing_cache }} | |
key: | |
value: ${{ jobs.cache.outputs.key }} | |
workflow_dispatch: | |
schedule: | |
# Weekly Monday midnight | |
- cron: "0 0 * * 1" | |
env: | |
CRDS_TEST_ROOT: /tmp | |
CRDS_PATH: /tmp/crds-cache-default-test | |
CRDS_TESTING_CACHE: /tmp/crds-cache-test | |
CRDS_CLIENT_RETRY_COUNT: 3 | |
CRDS_CLIENT_RETRY_DELAY_SECONDS: 20 | |
LD_LIBRARY_PATH: /usr/local/lib | |
defaults: | |
run: | |
shell: bash -leo pipefail {0} {0} | |
jobs: | |
contexts: | |
uses: ./.github/workflows/contexts.yml | |
cache: | |
needs: [ contexts ] | |
name: download and cache CRDS test files | |
runs-on: ubuntu-latest | |
outputs: | |
path: ${{ env.CRDS_PATH }} | |
testing_cache: ${{ env.CRDS_TESTING_CACHE }} | |
key: ${{ steps.key.outputs.key }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
repository: spacetelescope/crds | |
- id: key | |
run: echo "key=test-cache-${{ needs.contexts.outputs.hst }}-${{ needs.contexts.outputs.jwst }}" >> $GITHUB_OUTPUT | |
- id: lookup-combined-cache | |
name: check for existence of combined CRDS cache (`${{ steps.key.outputs.key }}`) | |
uses: actions/cache/restore@v4 | |
with: | |
path: | | |
${{ env.CRDS_PATH }} | |
${{ 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 | |
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' | |
uses: mamba-org/setup-micromamba@v1 | |
with: | |
environment-name: crds-testing | |
create-args: >- | |
python=3.11 | |
asdf | |
astropy | |
filelock | |
fitsverify | |
numpy | |
parsley | |
requests | |
init-shell: bash | |
cache-environment: true | |
cache-downloads: true | |
- if: steps.lookup-combined-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' | |
name: save combined CRDS cache (`${{ steps.key.outputs.key }}`) | |
uses: actions/cache/save@v4 | |
with: | |
path: | | |
${{ env.CRDS_PATH }} | |
${{ env.CRDS_TESTING_CACHE }} | |
key: ${{ steps.key.outputs.key }} | |