chore(ci): Move data cache into own job, key on test data repo HEAD #286
Workflow file for this run
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: Unit and integration tests | |
on: | |
push: | |
branches: | |
- main | |
- maint/* | |
pull_request: | |
branches: | |
- main | |
- maint/* | |
# Allow job to be triggered manually from GitHub interface | |
workflow_dispatch: | |
defaults: | |
run: | |
shell: bash | |
# Force tox and pytest to use color | |
env: | |
FORCE_COLOR: true | |
TEST_DATA_HOME: /home/runner/nifreeze-tests/ | |
ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS: 4 | |
ANTSPATH: /usr/share/miniconda/bin/ | |
NIFREEZE_WERRORS: 1 | |
TEST_DATA_REPO: https://gin.g-node.org/nipreps-data/tests-nifreeze | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
permissions: | |
contents: read | |
jobs: | |
cache-test-data: | |
runs-on: 'ubuntu-latest' | |
outputs: | |
SHA: ${{ steps.test-head.outputs.SHA }} | |
steps: | |
- name: Check remote HEAD | |
id: test-head | |
run: git ls-remote $TEST_DATA_REPO | awk '/HEAD/{ print "SHA=" $1 }' >> $GITHUB_OUTPUT | |
- uses: actions/cache@v4 | |
id: test-data | |
with: | |
path: /home/runner/nifreeze-tests/ | |
key: data-v1-${{ steps.test-head.outputs.SHA }} | |
restore-keys: | | |
data-v1 | |
data-v0 | |
- name: Install the latest version of uv | |
uses: astral-sh/setup-uv@v5 | |
if: steps.test-data.outputs.cache-hit != 'true' | |
- name: Install datalad | |
if: steps.test-data.outputs.cache-hit != 'true' | |
run: | | |
uvx datalad-installer --sudo ok git-annex | |
uv tool install --with=datalad-osf --with=datalad-next datalad | |
uv tool install --with=datalad-next datalad-osf | |
datalad wtf | |
- name: Get test data with DataLad | |
if: steps.test-data.outputs.cache-hit != 'true' | |
run: | | |
if [[ ! -d "${TEST_DATA_HOME}" ]]; then | |
datalad install -rg --source=${TEST_DATA_REPO} ${TEST_DATA_HOME} | |
else | |
cd ${TEST_DATA_HOME} | |
datalad update --merge -r . | |
datalad get -r -J4 * | |
fi | |
- name: Inspect data | |
run: | | |
set -x | |
ls -lR ${TEST_DATA_HOME} | |
cd ${TEST_DATA_HOME} | |
git status | |
git log -n 10 --graph --oneline | |
git ls-tree HEAD | |
git fsck | |
stable: | |
# Unit tests only on Linux/Python 3.12 | |
runs-on: 'ubuntu-latest' | |
needs: ['cache-test-data'] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
fetch-depth: 0 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.12' | |
- name: Install the latest version of uv | |
uses: astral-sh/setup-uv@v5 | |
- name: Install ANTs | |
run: | | |
conda install -c conda-forge ants=2.5 | |
- uses: actions/cache/restore@v4 | |
with: | |
path: /home/runner/nifreeze-tests/ | |
key: data-v1-${{ needs.cache-test-data.outputs.SHA }} | |
- name: Install TeX Live | |
run: | | |
sudo apt-get update | |
sudo apt install texlive texlive-latex-extra texlive-fonts-recommended cm-super dvipng | |
- name: Install tox | |
run: | | |
uv tool install --with=tox-uv --with=tox-gh-actions tox | |
- name: Show tox config | |
run: tox c | |
- name: Verify antsRegistration path | |
run: | | |
export PATH=$ANTSPATH:$PATH | |
which antsRegistration | |
antsRegistration --version | |
- name: Run tox | |
run: | | |
export PATH=$ANTSPATH:$PATH | |
tox -v --exit-and-dump-after 1200 -- test/test_registration.py -n 0 | |
- uses: codecov/codecov-action@v4 | |
if: ${{ always() }} | |
with: | |
files: cov.xml | |
token: ${{ secrets.CODECOV_TOKEN }} | |
checks: | |
runs-on: 'ubuntu-latest' | |
continue-on-error: true | |
strategy: | |
matrix: | |
check: ['spellcheck', 'typecheck'] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install the latest version of uv | |
uses: astral-sh/setup-uv@v4 | |
# Can remove this once there is a traits release that supports 3.13 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.12 | |
- name: Install tox | |
run: uv tool install tox --with=tox-uv | |
- name: Show tox config | |
run: tox c | |
- name: Show tox config (this call) | |
run: tox c -e ${{ matrix.check }} | |
- name: Run check | |
run: tox -e ${{ matrix.check }} |