Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cookpa patch 6 #575

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 86 additions & 0 deletions .github/workflows/ci-pytest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Advanced Normalization Tools in Python

Hashin'

[![Coverage Status](https://coveralls.io/repos/github/ANTsX/ANTsPy/badge.svg?branch=master)](https://coveralls.io/github/ANTsX/ANTsPy?branch=master)
<a href='http://antspyx.readthedocs.io/en/latest/?badge=latest'>
Expand Down
Loading