Skip to content

Commit 7176e94

Browse files
committed
composite iris-data-cache action
1 parent 4a7fdf0 commit 7176e94

File tree

4 files changed

+40
-29
lines changed

4 files changed

+40
-29
lines changed

.github/workflows/ci-docs-tests.yml

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -46,21 +46,11 @@ jobs:
4646
echo "LOCK_FILE=requirements/ci/nox.lock/py$(echo ${{ matrix.python-version }} | tr -d '.')-linux-64.lock" >> ${GITHUB_ENV}
4747
4848
- name: "data cache"
49-
uses: actions/cache@v3
50-
id: data-cache
51-
env:
52-
# Increment the build number to force a cache refresh.
53-
CACHE_BUILD: 0
49+
uses: ./.github/workflows/composite/iris-data-cache
5450
with:
55-
path: ~/iris-test-data
56-
key: ${{ runner.os }}-iris-test-data-${{ env.ENV_NAME }}-v${{ env.IRIS_TEST_DATA_VERSION }}-b${{ env.CACHE_BUILD }}
57-
58-
- name: "data cache populate"
59-
if: steps.data-cache.outputs.cache-hit != 'true'
60-
run: |
61-
wget --quiet https://github.com/SciTools/iris-test-data/archive/v${{ env.IRIS_TEST_DATA_VERSION }}.zip -O iris-test-data.zip
62-
unzip -q iris-test-data.zip
63-
mv iris-test-data-${{ env.IRIS_TEST_DATA_VERSION }} ${HOME}/iris-test-data
51+
# Increment the build number to force a cache refresh.
52+
cache_build: 0
53+
version: ${{ env.IRIS_TEST_DATA_VERSION }}
6454

6555
- name: "conda package cache"
6656
uses: actions/cache@v3

.github/workflows/ci-tests.yml

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -46,21 +46,11 @@ jobs:
4646
echo "LOCK_FILE=requirements/ci/nox.lock/py$(echo ${{ matrix.python-version }} | tr -d '.')-linux-64.lock" >> ${GITHUB_ENV}
4747
4848
- name: "data cache"
49-
uses: actions/cache@v3
50-
id: data-cache
51-
env:
52-
# Increment the build number to force a cache refresh.
53-
CACHE_BUILD: 0
49+
uses: ./.github/workflows/composite/iris-data-cache
5450
with:
55-
path: ~/iris-test-data
56-
key: ${{ runner.os }}-iris-test-data-${{ env.ENV_NAME }}-v${{ env.IRIS_TEST_DATA_VERSION }}-b${{ env.CACHE_BUILD }}
57-
58-
- name: "data cache populate"
59-
if: steps.data-cache.outputs.cache-hit != 'true'
60-
run: |
61-
wget --quiet https://github.com/SciTools/iris-test-data/archive/v${{ env.IRIS_TEST_DATA_VERSION }}.zip -O iris-test-data.zip
62-
unzip -q iris-test-data.zip
63-
mv iris-test-data-${{ env.IRIS_TEST_DATA_VERSION }} ${HOME}/iris-test-data
51+
# Increment the build number to force a cache refresh.
52+
cache_build: 0
53+
version: ${{ env.IRIS_TEST_DATA_VERSION }}
6454

6555
- name: "conda package cache"
6656
uses: actions/cache@v3
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: "iris-data-cache"
2+
description: "cache the iris test data"
3+
4+
#
5+
# Assumes the environment contains the following variables:
6+
# - ENV_NAME
7+
# - HOME
8+
#
9+
inputs:
10+
cache_build:
11+
description: "data cache version build number"
12+
required: false
13+
default: "0"
14+
version:
15+
description: "iris test data version"
16+
required: true
17+
18+
runs:
19+
using: "composite"
20+
steps:
21+
- uses: actions/cache@v3
22+
id: data-cache
23+
with:
24+
path: ~/iris-test-data
25+
key: ${{ runner.os }}-iris-test-data-${{ env.ENV_NAME }}-v${{ inputs.version }}-b${{ inputs.cache_build }}
26+
27+
- if: steps.data-cache.outputs.cache-hit != 'true'
28+
run: |
29+
wget --quiet https://github.com/SciTools/iris-test-data/archive/v${{ inputs.version }}.zip -O iris-test-data.zip
30+
unzip -q iris-test-data.zip
31+
mv iris-test-data-${{ inputs.version }} ${HOME}/iris-test-data

.github/workflows/composite/nox-cache/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ runs:
1818
- uses: actions/cache@v3
1919
with:
2020
path: ${{ github.workspace }}/.nox
21-
key: ${{ runner.os }}-nox-${{ env.ENV_NAME }}-py${{ matrix.python-version }}-b${{ inputs.cache_build }}-${{ hashFiles(env.LOCK_FILE) }}
21+
key: ${{ runner.os }}-nox-${{ env.ENV_NAME }}-py${{ matrix.python-version }}-b${{ inputs.cache_build }}-${{ hashFiles(env.LOCK_FILE) }}

0 commit comments

Comments
 (0)