Skip to content

CI: remove references to TestPyPI #109

CI: remove references to TestPyPI

CI: remove references to TestPyPI #109

Workflow file for this run

name: ANTsPyNet Unit Tests
on:
pull_request:
types: [opened, synchronize]
branches: [master]
workflow_call:
workflow_dispatch:
env:
USE_ANTSPY_SOURCE_BUILD: false
jobs:
###########################################
# Job 1 — Build ANTsXNet Data Cache
#
# This job downloads all ANTsXNet data and pretrained models and uploads as an artifact
# The data is too big for Github's cache and runner disk space to handle
#
# But we still avoid independent downloads from figshare for each build matrix job
#
###########################################
prepare-data:
name: Prepare ANTsXNet data and models
runs-on: ubuntu-22.04
outputs:
cache-key: ${{ steps.compute-key.outputs.cache-key }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Compute cache key
id: compute-key
run: |
KEY="antsxnet-${{ hashFiles(
'antspynet/utilities/get_antsxnet_data.py',
'antspynet/utilities/get_pretrained_network.py'
) }}"
echo "cache-key=$KEY" >> "$GITHUB_OUTPUT"
- name: Set up Python 3.11
uses: actions/setup-python@v6
with:
python-version: "3.11"
- name: Install ANTsPy for data download
run: |
echo "Installing ANTsPy from PyPI for cache preparation"
pip install antspyx
- name: Download ANTsXNet data and models
run: |
pip install -e .
python download_antsxnet_data.py --strict --cache-dir ${{ runner.temp }}/ANTsXNet
- name: Upload data to artifact
uses: actions/upload-artifact@v6
with:
name: ANTSXNet-data-${{ steps.compute-key.outputs.cache-key }}
path: ${{ runner.temp }}/ANTsXNet
retention-days: 7
###########################################
# Job 2 — Test Matrix
###########################################
test:
name: Test on Python ${{ matrix.python-version }}
runs-on: ubuntu-22.04
needs: prepare-data
strategy:
fail-fast: false
matrix:
python-version: ["3.11", "3.13"]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download ANTsXNet data and models artifact
uses: actions/download-artifact@v7
with:
name: ANTSXNet-data-${{ needs.prepare-data.outputs.cache-key }}
path: ~/.keras/ANTsXNet
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
- name: Install build tools
run: |
sudo apt-get update
sudo apt-get install -y cmake build-essential git
- name: Install ANTsPy
run: |
if [ "$USE_ANTSPY_SOURCE_BUILD" = "true" ]; then
echo "Installing ANTsPy from source..."
git clone https://github.com/ANTsX/ANTsPy.git
pip install scikit-build-core pybind11 nanobind
pip install ./ANTsPy --no-build-isolation --no-deps
else
echo "Installing ANTsPy from PyPI..."
pip install antspyx
fi
- name: Install ANTsPyNet and dependencies
run: |
pip install -e .
- name: Run tests (individually via pytest)
run: |
pip install pytest pytest-xdist pytest-forked psutil
for f in tests/test_*.py; do
echo "🔍 Running $f"
python -c "import psutil; print('Memory before:', psutil.virtual_memory().used // (1024*1024), 'MB')"
pytest -v -s --forked "$f" || exit 1
python -c "import psutil; print('Memory after :', psutil.virtual_memory().used // (1024*1024), 'MB')"
done