Skip to content

Commit a2d6eac

Browse files
authored
Merge pull request #80 from effigies/ci/fix-cache
chore(ci): Move data cache into own job, key on test data repo HEAD
2 parents 9a143e4 + 1848869 commit a2d6eac

File tree

2 files changed

+64
-24
lines changed

2 files changed

+64
-24
lines changed

.github/workflows/test.yml

+62-22
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,9 +33,58 @@ permissions:
3233
contents: read
3334

3435
jobs:
36+
cache-test-data:
37+
runs-on: 'ubuntu-latest'
38+
outputs:
39+
SHA: ${{ steps.test-head.outputs.SHA }}
40+
steps:
41+
- name: Check remote HEAD
42+
id: test-head
43+
run: |
44+
SHA=$( git ls-remote $TEST_DATA_REPO HEAD | cut -f 1 )
45+
echo SHA=$SHA >> $GITHUB_OUTPUT
46+
echo SHA7=${SHA:0:7} >> $GITHUB_OUTPUT
47+
- name: Check for data-v1-${{ steps.test-head.outputs.SHA }}
48+
uses: actions/cache@v4
49+
id: test-data
50+
with:
51+
path: /home/runner/nifreeze-tests/
52+
key: data-v1-${{ steps.test-head.outputs.SHA }}
53+
lookup-only: true
54+
- name: Create data-v1-${{ steps.test-head.outputs.SHA }}
55+
uses: actions/cache@v4
56+
if: steps.test-data.outputs.cache-hit != 'true'
57+
with:
58+
path: /home/runner/nifreeze-tests/
59+
key: data-v1-${{ steps.test-head.outputs.SHA }}
60+
restore-keys: |
61+
data-v1
62+
data-v0
63+
- name: Install the latest version of uv
64+
uses: astral-sh/setup-uv@v5
65+
if: steps.test-data.outputs.cache-hit != 'true'
66+
- name: Install datalad
67+
if: steps.test-data.outputs.cache-hit != 'true'
68+
run: |
69+
uvx datalad-installer --sudo ok git-annex
70+
uv tool install --with=datalad-osf --with=datalad-next datalad
71+
uv tool install --with=datalad-next datalad-osf
72+
datalad wtf
73+
- name: Checkout commit ${{ steps.test-head.outputs.SHA7 }}
74+
if: steps.test-data.outputs.cache-hit != 'true'
75+
run: |
76+
if [[ ! -d "${TEST_DATA_HOME}" ]]; then
77+
datalad install -rg --source=${TEST_DATA_REPO} ${TEST_DATA_HOME}
78+
else
79+
cd ${TEST_DATA_HOME}
80+
datalad update --merge -r .
81+
datalad get -r -J4 *
82+
fi
83+
3584
stable:
3685
# Unit tests only on Linux/Python 3.12
3786
runs-on: 'ubuntu-latest'
87+
needs: ['cache-test-data']
3888
steps:
3989
- uses: actions/checkout@v4
4090
with:
@@ -44,40 +94,30 @@ jobs:
4494
uses: actions/setup-python@v5
4595
with:
4696
python-version: '3.12'
97+
- name: Install the latest version of uv
98+
uses: astral-sh/setup-uv@v5
4799
- name: Install ANTs
48100
run: |
49-
conda install -c conda-forge ants=2.5
50-
- name: Install datalad
101+
# Override libiconv pre-installed from anaconda channel
102+
# See https://github.com/conda-forge/libitk-feedstock/issues/98
103+
# Since we're not creating a new environment, we must be explicit
104+
conda install -c conda-forge ants=2.5 libiconv
105+
- name: Verify antsRegistration path
51106
run: |
52-
python -m pip install datalad-installer
53-
datalad-installer --sudo ok git-annex
54-
python -m pip install datalad datalad-osf
55-
datalad wtf
107+
export PATH=$ANTSPATH:$PATH
108+
which antsRegistration
109+
antsRegistration --version
56110
- uses: actions/cache/restore@v4
57111
with:
58112
path: /home/runner/nifreeze-tests/
59-
key: data-v0
60-
- name: Get test data with DataLad
61-
run: |
62-
if [[ ! -d "${TEST_DATA_HOME}" ]]; then
63-
datalad install -rg --source=https://gin.g-node.org/nipreps-data/tests-nifreeze.git ${TEST_DATA_HOME}
64-
else
65-
cd ${TEST_DATA_HOME}
66-
datalad update --merge -r .
67-
datalad get -r -J4 *
68-
fi
69-
- uses: actions/cache/save@v4
70-
with:
71-
path: /home/runner/nifreeze-tests/
72-
key: data-v0
113+
key: data-v1-${{ needs.cache-test-data.outputs.SHA }}
73114
- name: Install TeX Live
74115
run: |
75116
sudo apt-get update
76117
sudo apt install texlive texlive-latex-extra texlive-fonts-recommended cm-super dvipng
77118
- name: Install tox
78119
run: |
79-
python -m pip install --upgrade pip
80-
python -m pip install tox tox-gh-actions
120+
uv tool install --with=tox-uv --with=tox-gh-actions tox
81121
- name: Show tox config
82122
run: tox c
83123
- name: Run tox

tox.ini

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ pass_env =
3636
NIFREEZE_WERRORS
3737
extras = test
3838
commands =
39-
pytest --doctest-modules --cov nifreeze -n auto --cov-report xml \
40-
--junitxml=test-results.xml -v src test {posargs}
39+
pytest -svx --doctest-modules --cov nifreeze --cov-report xml \
40+
--junitxml=test-results.xml -v src test {posargs:-n auto}
4141

4242
[testenv:notebooks]
4343
description = Run notebooks

0 commit comments

Comments
 (0)