Skip to content

Cookpa patch 6

Cookpa patch 6 #2

Workflow file for this run

name: ci-pytest
on: pull_request
env:
# Changing either of these two things will invalidate the cache and cause a full re-install
# of ANTsPy and its dependencies
# Update this hash whenever there is a change that affects ANTsPy libraries or dependencies
# Updates or changes to the runner OS or arch will also invalidate the cache
python_version: '3.9' # Python version to use for testing - update when needed
jobs:
test:
runs-on: ubuntu-22.04
steps:
- name: Setup Miniconda
uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: true
python-version: ${{ env.python_version }}
activate-environment: antspy-env
- name: Load conda environment from cache if available
id: cache-env
uses: actions/cache@v4
with:
path: ~/conda-env.tar.gz
key: >-
${{ runner.os }}-conda-${{ env.python_version }}-
${{ hashFiles('environment.yml', 'requirements.txt', 'setup.py',
'scripts/configure_ITK.sh', 'scripts/configure_ANTsPy.sh') }}
- name: Unpack cached environment
if: steps.cache-env.outputs.cache-hit == 'true'
run: |
tar -xzf ~/conda-env.tar.gz -C ${CONDA}/envs/antspy-env
- name: Checkout ANTsPy at specific commit
if: steps.cache-env.outputs.cache-hit != 'true'
uses: actions/checkout@v4
with:
repository: ANTsX/ANTsPy
ref: ${{ env.antspy_ref_hash }}
token: ${{ secrets.GITHUB_TOKEN }}
path: antspy-temp
- name: Install dependencies and ANTsPy from commit
if: steps.cache-env.outputs.cache-hit != 'true'
run: |
source $CONDA/etc/profile.d/conda.sh
conda install -c conda-forge conda-pack
conda create -n antspy-env python=${{ env.python_version }} -y
conda activate antspy-env
pip install ./antspy-temp
# Pack the environment
conda deactivate
conda pack -n antspy-env -o ~/conda-env.tar.gz
- name: Cache Conda environment
if: steps.cache-env.outputs.cache-hit != 'true'
uses: actions/cache@v4
with:
path: ~/conda-env.tar.gz
key: >-
${{ runner.os }}-conda-${{ env.python_version }}-
${{ hashFiles('environment.yml', 'requirements.txt', 'setup.py',
'scripts/configure_ITK.sh', 'scripts/configure_ANTsPy.sh') }}
- uses: actions/checkout@v4 # Checkout PR code to 'antspy-pr'
with:
path: antspy-pr
- name: Replace installed ANTsPy with PR code
run: |
source $CONDA/etc/profile.d/conda.sh
conda activate antspy-env
ANTS_SITE_PACKAGES=$(python -c "import os, ants; print(os.path.dirname(ants.__file__))")
rm -rf $ANTS_SITE_PACKAGES/ants
cp -r antspy-pr/ants $ANTS_SITE_PACKAGES/ants
- name: Run tests
run: |
source $CONDA/etc/profile.d/conda.sh
conda activate antspy-env
bash antspy-pr/tests/run_tests.sh