Skip to content

Commit da90f5c

Browse files
committed
chore(ci): Key the test data cache on the data repo HEAD
1 parent 410a1bb commit da90f5c

File tree

1 file changed

+20
-23
lines changed

1 file changed

+20
-23
lines changed

.github/workflows/test.yml

+20-23
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ env:
2323
ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS: 4
2424
ANTSPATH: /usr/share/miniconda/bin/
2525
NIFREEZE_WERRORS: 1
26+
TEST_DATA_REPO: https://gin.g-node.org/nipreps-data/tests-nifreeze
2627

2728
concurrency:
2829
group: ${{ github.workflow }}-${{ github.ref }}
@@ -32,30 +33,37 @@ permissions:
3233
contents: read
3334

3435
jobs:
35-
cache-data:
36+
cache-test-data:
3637
runs-on: 'ubuntu-latest'
38+
outputs:
39+
SHA: ${{ steps.test-head.outputs.SHA }}
3740
steps:
41+
- name: Check remote HEAD
42+
id: test-head
43+
run: git ls-remote $TEST_DATA_REPO | awk '/HEAD/{ print "SHA=" $1 }' >> $GITHUB_OUTPUT
44+
- uses: actions/cache@v4
45+
id: test-data
46+
with:
47+
path: /home/runner/nifreeze-tests/
48+
key: data-v1-${{ steps.test-head.outputs.SHA }}
49+
restore-keys: |
50+
data-v1
51+
data-v0
3852
- name: Install the latest version of uv
3953
uses: astral-sh/setup-uv@v5
54+
if: steps.test-data.outputs.cache-hit != 'true'
4055
- name: Install datalad
56+
if: steps.test-data.outputs.cache-hit != 'true'
4157
run: |
4258
uvx datalad-installer --sudo ok git-annex
4359
uv tool install --with=datalad-osf --with=datalad-next datalad
4460
uv tool install --with=datalad-next datalad-osf
4561
datalad wtf
46-
- uses: actions/cache@v4
47-
id: test-data
48-
with:
49-
path: /home/runner/nifreeze-tests/
50-
key: data-v1
51-
restore-keys: |
52-
data-v1
53-
data-v0
5462
- name: Get test data with DataLad
5563
if: steps.test-data.outputs.cache-hit != 'true'
5664
run: |
5765
if [[ ! -d "${TEST_DATA_HOME}" ]]; then
58-
datalad install -rg --source=https://gin.g-node.org/nipreps-data/tests-nifreeze.git ${TEST_DATA_HOME}
66+
datalad install -rg --source=${TEST_DATA_REPO} ${TEST_DATA_HOME}
5967
else
6068
cd ${TEST_DATA_HOME}
6169
datalad update --merge -r .
@@ -65,7 +73,7 @@ jobs:
6573
stable:
6674
# Unit tests only on Linux/Python 3.12
6775
runs-on: 'ubuntu-latest'
68-
needs: ['cache-data']
76+
needs: ['cache-test-data']
6977
steps:
7078
- uses: actions/checkout@v4
7179
with:
@@ -78,21 +86,10 @@ jobs:
7886
- name: Install ANTs
7987
run: |
8088
conda install -c conda-forge ants=2.5
81-
- name: Install datalad
82-
run: |
83-
python -m pip install datalad-installer
84-
datalad-installer --sudo ok git-annex
85-
python -m pip install datalad datalad-osf
86-
datalad wtf
8789
- uses: actions/cache/restore@v4
8890
with:
8991
path: /home/runner/nifreeze-tests/
90-
key: data-v1
91-
- name: Update test data
92-
run: |
93-
cd ${TEST_DATA_HOME}
94-
datalad update --merge -r .
95-
datalad get -r -J4 *
92+
key: data-v1-${{ needs.cache-test-data.outputs.SHA }}
9693
- name: Install TeX Live
9794
run: |
9895
sudo apt-get update

0 commit comments

Comments
 (0)