6363 description : ' A label to add to the pooch cache key.'
6464 default : ' pooch'
6565 type : string
66+ RSCIIO_CACHE_POOCH_LABEL :
67+ description : |
68+ 'The label to retrieve the RosettaSciIO test data cache - only used when `ROSETTASCIIO_VERSION` is "release".'
69+ 'The output of the `download_rsciio_test_data.yml` reusable workflow should be passed to this input to get the correct cache.'
70+ default : ' '
71+ type : string
6672 PYTEST_ARGS :
6773 description : ' Additional arguments to pass to pytest.
6874 If not provided, defaults to "--reruns 3 -n <number_of_cpus>".'
96102 env :
97103 MPLBACKEND : agg
98104 PYTEST_ARGS : ${{ inputs.PYTEST_ARGS }}
105+ RSCIIO_CACHE_POOCH_LABEL : ${{ inputs.RSCIIO_CACHE_POOCH_LABEL }}
99106 steps :
100107 - uses : actions/checkout@v6
101108 with :
@@ -112,13 +119,6 @@ jobs:
112119 git remote add upstream https://github.com/hyperspy/${{ env.REPOSITORY_NAME }}.git
113120 git fetch upstream --tags
114121
115- - uses : ssciwr/pooch-cache@v1
116- if : ${{ contains(inputs.EXTENSIONS, 'exspy')}}
117- with :
118- # to restore the pooch cache use for eXSpy for example
119- name : pooch
120- fail-on-cache-miss : true
121-
122122 - uses : conda-incubator/setup-miniconda@v3
123123 with :
124124 miniforge-version : latest
@@ -346,27 +346,51 @@ jobs:
346346 restore-keys : |
347347 ${{ runner.os }}-${{ inputs.CACHE_POOCH_LABEL }}-${{ env.CACHE_NUMBER }}
348348
349- - name : Conda list
349+ - uses : ssciwr/pooch-cache@v1
350+ if : ${{ contains(inputs.EXTENSIONS, 'exspy')}}
351+ with :
352+ # to restore the pooch cache use for eXSpy for example
353+ name : pooch
354+ fail-on-cache-miss : true
355+
356+ - name : Set RSCIIO_CACHE_POOCH_LABEL environment variable
357+ if : ${{ env.REPOSITORY_NAME != 'rosettasciio' && inputs.ROSETTASCIIO_VERSION == 'dev' }}
350358 run : |
351- conda list
359+ # overwrite the RSCIIO_CACHE_POOCH_LABEL to "main" to get the latest test data cache for the dev version of RosettaSciIO
360+ echo "RSCIIO_CACHE_POOCH_LABEL=main" >> $GITHUB_ENV
361+
362+ - uses : ssciwr/pooch-cache@v1
363+ if : ${{ env.REPOSITORY_NAME != 'rosettasciio' }}
364+ with :
365+ # to restore the RosettaSciIO test data cache
366+ name : rsciio-${{ env.RSCIIO_CACHE_POOCH_LABEL }}
367+ fail-on-cache-miss : true
352368
353- - name : Get rosettasciio tests data location
354- if : ${{ env.REPOSITORY_NAME != 'rosettasciio' }} # only for repositories that are not rosettasciio
369+ # Need https://github.com/hyperspy/rosettasciio/pull/482 to be released
370+ # and remove the next step
371+ # - name: Set RSCIIO_TEST_DATA_SOURCE environment variable
372+ # if: ${{ env.REPOSITORY_NAME != 'rosettasciio' }}
373+ # run: |
374+ # # Get the value `RSCIIO_TEST_DATA_SOURCE` from the pooch cache path
375+ # python -c "import pooch; print(f'RSCIIO_TEST_DATA_SOURCE={str(pooch.os_cache(\"rsciio-${{ env.RSCIIO_CACHE_POOCH_LABEL }}\"))}')" >> $GITHUB_ENV
376+
377+ - name : Copy RosettaSciIO test data from pooch cache
378+ if : ${{ env.REPOSITORY_NAME != 'rosettasciio' }}
355379 run : |
356- python -c "from rsciio.tests import registry; print(f'ROSETTASCIIO_TEST_DATA={str(registry.TESTS_PATH / \"data\") }')" >> $GITHUB_ENV
380+ python -c "
381+ import importlib.util, os, shutil, sys
382+ from pathlib import Path
383+ import pooch
384+ src = pooch.os_cache('rsciio-${{ env.RSCIIO_CACHE_POOCH_LABEL }}')
385+ dest = Path(importlib.util.find_spec('rsciio').origin).parent / 'tests' / 'data'
386+ print(f'Copying from {src} to {dest}')
387+ shutil.copytree(str(src), str(dest), dirs_exist_ok=True)
388+ print(os.listdir(dest))
389+ "
357390
358- - name : Cache rosettasciio data
359- if : ${{ always() && env.REPOSITORY_NAME != 'rosettasciio' }} # only for repositories that are not rosettasciio
360- uses : actions/cache@v5
361- env :
362- # Increase this value to reset cache
363- CACHE_NUMBER : 0
364- with :
365- path : ${{ env.ROSETTASCIIO_TEST_DATA }}
366- key :
367- ${{ runner.os }}-integration-rosettasciio-${{ env.CACHE_NUMBER }}
368- restore-keys : |
369- ${{ runner.os }}-integration-rosettasciio-${{ env.CACHE_NUMBER }}
391+ - name : Conda list
392+ run : |
393+ conda list
370394
371395 - name : Run HyperSpy Test Suite
372396 if : ${{ always() }}
0 commit comments