-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b66a640
commit c421823
Showing
12 changed files
with
493 additions
and
83 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,390 @@ | ||
version: 2 | ||
jobs: | ||
|
||
build: | ||
environment: | ||
TZ: "/usr/share/zoneinfo/America/New_York" | ||
SCRATCH: "/scratch" | ||
docker: | ||
- image: docker:18.06.1-ce-git | ||
working_directory: /tmp/src/BOnD | ||
steps: | ||
- checkout | ||
- run: | ||
name: Install parallel gzip and python3 | ||
command: | | ||
apk add --no-cache pigz python3 tar | ||
- restore_cache: | ||
keys: | ||
- docker-v1-{{ .Branch }}-{{ .Revision }} | ||
- docker-v1-{{ .Branch }}- | ||
- docker-v1-master- | ||
- docker-v1- | ||
paths: | ||
- /tmp/cache/docker.tar.gz | ||
- setup_remote_docker | ||
- run: | ||
name: Load Docker image layer cache | ||
no_output_timeout: 30m | ||
command: | | ||
docker info | ||
set +o pipefail | ||
if [ -f /tmp/cache/docker.tar.gz ]; then | ||
pigz -d --stdout /tmp/cache/docker.tar.gz | docker load | ||
docker images | ||
fi | ||
- run: | ||
name: Build Docker image | ||
no_output_timeout: 3h | ||
command: | | ||
# Build docker image | ||
e=1 && for i in {1..5}; do | ||
docker build \ | ||
--cache-from=pennlinc/bond \ | ||
--rm=false \ | ||
-t pennlinc/bond:latest \ | ||
--build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \ | ||
--build-arg VCS_REF=`git rev-parse --short HEAD` . \ | ||
&& e=0 && break || sleep 15 | ||
done && [ "$e" -eq "0" ] | ||
- run: | ||
name: Docker save | ||
no_output_timeout: 40m | ||
command: | | ||
mkdir -p /tmp/cache | ||
docker save pennlinc/bond:latest \ | ||
| pigz -3 > /tmp/cache/docker.tar.gz | ||
- save_cache: | ||
key: docker-v1-{{ .Branch }}-{{ .Revision }}-{{ epoch }} | ||
paths: | ||
- /tmp/cache/docker.tar.gz | ||
|
||
|
||
setup_conda: | ||
machine: | ||
image: ubuntu-1604:202004-01 | ||
steps: | ||
- run: | ||
name: install miniconda | ||
command: | | ||
cd /tmp | ||
export MINICONDA=/tmp/miniconda | ||
export PATH="$MINICONDA/bin:$PATH" | ||
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh | ||
bash miniconda.sh -b -f -p $MINICONDA | ||
conda config --set always_yes yes | ||
conda update conda | ||
conda info -a | ||
conda create -n bond python=3.7 | ||
source activate bond | ||
conda install -c conda-forge -y datalad | ||
- persist_to_workspace: | ||
root: /tmp | ||
paths: | ||
- miniconda | ||
|
||
|
||
install_and_test: | ||
machine: | ||
image: ubuntu-1604:202004-01 | ||
working_directory: /home/circleci/src/BOnD | ||
steps: | ||
- checkout: | ||
path: /home/circleci/src/BOnD | ||
|
||
- attach_workspace: | ||
at: /tmp | ||
|
||
- restore_cache: | ||
keys: | ||
- docker-v1-{{ .Branch }}-{{ .Revision }} | ||
|
||
- run: | ||
name: Load Docker image layer cache | ||
no_output_timeout: 30m | ||
command: | | ||
docker info | ||
set +o pipefail | ||
if [ -f /tmp/cache/docker.tar.gz ]; then | ||
sudo apt update && sudo apt -y install pigz | ||
pigz -d --stdout /tmp/cache/docker.tar.gz | docker load | ||
docker images | ||
fi | ||
- run: | ||
name: Install BOnD | ||
command: | | ||
export PATH=/tmp/miniconda/bin:$PATH | ||
source activate bond | ||
pip install .[all] | ||
- run: | ||
name: Run PyTest | ||
command: | | ||
export PATH=/tmp/miniconda/bin:$PATH | ||
source activate bond | ||
py.test -sv tests | ||
build_docs: | ||
docker: | ||
- image: circleci/python:3.7.4 | ||
working_directory: /tmp/src/BOnD | ||
steps: | ||
- checkout | ||
- run: | ||
name: Check whether build should be skipped | ||
command: | | ||
if [[ "$( git log --format=oneline -n 1 $CIRCLE_SHA1 | grep -i -E '\[skip[ _]?docs\]' )" != "" ]]; then | ||
echo "Skipping doc building job" | ||
circleci step halt | ||
fi | ||
- run: | ||
name: Check Python version and upgrade pip | ||
command: | | ||
python --version | ||
sudo python -m pip install -U pip | ||
sudo pip install flake8 | ||
- run: | ||
name: Lint code with flake8 | ||
command: | | ||
flake8 bond | ||
- run: | ||
name: Install BOnD. | ||
command: sudo python -m pip install ".[doc]" --no-cache-dir --progress-bar off | ||
|
||
- run: | ||
name: Build documentation | ||
no_output_timeout: 45m | ||
command: | | ||
make SPHINXOPTS="-W" -C docs html | ||
- store_artifacts: | ||
path: /tmp/src/BOnD/docs/_build/html | ||
|
||
deploy_docker: | ||
machine: | ||
image: circleci/classic:201711-01 | ||
working_directory: /tmp/src/BOnD | ||
steps: | ||
- checkout: | ||
path: /home/circleci/src/BOnD | ||
- run: | ||
name: Check whether build should be skipped | ||
command: | | ||
cd /home/circleci/src/BOnD | ||
if [[ "$( git log --format='format:%s' -n 1 $CIRCLE_SHA1 | grep -i -E '^docs?(\(\w+\))?:' )" != "" ]]; then | ||
echo "Only docs build" | ||
circleci step halt | ||
fi | ||
- restore_cache: | ||
keys: | ||
- docker-v1-{{ .Branch }}-{{ .Revision }} | ||
- run: | ||
name: Load Docker image layer cache | ||
no_output_timeout: 30m | ||
command: | | ||
docker info | ||
set +o pipefail | ||
if [ -f /tmp/cache/docker.tar.gz ]; then | ||
sudo apt update && sudo apt -y install pigz | ||
pigz -d --stdout /tmp/cache/docker.tar.gz | docker load | ||
docker images | ||
fi | ||
- run: | ||
name: Deploy to Docker Hub | ||
no_output_timeout: 40m | ||
command: | | ||
if [[ -n "$DOCKER_PASS" ]]; then | ||
docker login -u $DOCKER_USER -p $DOCKER_PASS | ||
docker tag pennlinc/BOnD pennlinc/BOnD:unstable | ||
docker push pennlinc/BOnD:unstable | ||
if [[ -n "$CIRCLE_TAG" ]]; then | ||
docker push pennlinc/BOnD:latest | ||
docker tag pennlinc/BOnD pennlinc/BOnD:$CIRCLE_TAG | ||
docker push pennlinc/BOnD:$CIRCLE_TAG | ||
fi | ||
fi | ||
test_deploy_pypi: | ||
docker: | ||
- image: circleci/python:3.7.4 | ||
working_directory: /tmp/src/BOnD | ||
steps: | ||
- checkout | ||
- run: | ||
name: Build BOnD | ||
command: | | ||
pip install --user twine # For use in checking distributions | ||
THISVERSION=$( python3 get_version.py ) | ||
THISVERSION=${THISVERSION%.dirty*} | ||
THISVERSION=${CIRCLE_TAG:-$THISVERSION} | ||
virtualenv --python=python build | ||
source build/bin/activate | ||
pip install --upgrade "pip>=19.1" numpy | ||
echo "${CIRCLE_TAG:-$THISVERSION}" > BOnD/VERSION | ||
python setup.py sdist | ||
pip wheel --no-deps -w dist/ . | ||
- store_artifacts: | ||
path: /tmp/src/BOnD/dist | ||
- run: | ||
name: Check sdist distribution | ||
command: | | ||
THISVERSION=$( python get_version.py ) | ||
THISVERSION=${THISVERSION%.dirty*} | ||
THISVERSION=${CIRCLE_TAG:-$THISVERSION} | ||
twine check dist/BOnD*.tar.gz | ||
virtualenv --python=python sdist | ||
source sdist/bin/activate | ||
pip install --progress-bar off --upgrade "pip>=19.1" numpy | ||
pip install dist/BOnD*.tar.gz | ||
which BOnD | grep sdist\\/bin | ||
INSTALLED_VERSION=$(BOnD --version) | ||
INSTALLED_VERSION=${INSTALLED_VERSION%$'\r'} | ||
INSTALLED_VERSION=${INSTALLED_VERSION#*"BOnD v"} | ||
echo "VERSION: \"$THISVERSION\"" | ||
echo "INSTALLED: \"$INSTALLED_VERSION\"" | ||
test "$INSTALLED_VERSION" = "$THISVERSION" | ||
- run: | ||
name: Check wheel distribution | ||
command: | | ||
THISVERSION=$( python get_version.py ) | ||
THISVERSION=${THISVERSION%.dirty*} | ||
THISVERSION=${CIRCLE_TAG:-$THISVERSION} | ||
twine check dist/BOnD*.whl | ||
virtualenv --python=python wheel | ||
source wheel/bin/activate | ||
pip install dist/BOnD*.whl | ||
which BOnD | grep wheel\\/bin | ||
INSTALLED_VERSION=$(BOnD --version) | ||
INSTALLED_VERSION=${INSTALLED_VERSION%$'\r'} | ||
INSTALLED_VERSION=${INSTALLED_VERSION#*"BOnD v"} | ||
echo "VERSION: \"$THISVERSION\"" | ||
echo "INSTALLED: \"$INSTALLED_VERSION\"" | ||
test "$INSTALLED_VERSION" = "$THISVERSION" | ||
- run: | ||
name: Build BOnD-container | ||
command: | | ||
THISVERSION=$( python get_version.py ) | ||
THISVERSION=${THISVERSION%.dirty*} | ||
cd wrapper | ||
virtualenv --python=python build | ||
source build/bin/activate | ||
pip install --upgrade "pip>=19.1" | ||
sed -i -E "s/(__version__ = )'[A-Za-z0-9.-]+'/\1'${CIRCLE_TAG:-$THISVERSION}'/" qsiprep_docker.py | ||
python setup.py sdist | ||
pip wheel --no-deps -w dist/ . | ||
- store_artifacts: | ||
path: /tmp/src/BOnD/wrapper/dist | ||
|
||
deploy_pypi: | ||
docker: | ||
- image: circleci/python:3.7.4 | ||
working_directory: /tmp/src/BOnD | ||
steps: | ||
- checkout | ||
- run: | ||
name: Build BOnD | ||
command: | | ||
THISVERSION=$( python get_version.py ) | ||
virtualenv --python=python build | ||
source build/bin/activate | ||
pip install --upgrade "pip>=19.1" numpy | ||
echo "${CIRCLE_TAG:-$THISVERSION}" > BOnD/VERSION | ||
python setup.py sdist | ||
pip wheel --no-deps -w dist/ . | ||
- run: | ||
name: Build BOnD-container | ||
command: | | ||
THISVERSION=$( python get_version.py ) | ||
cd wrapper | ||
virtualenv --python=python build | ||
source build/bin/activate | ||
pip install --upgrade "pip>=19.1" | ||
sed -i -E "s/(__version__ = )'[A-Za-z0-9.-]+'/\1'${CIRCLE_TAG:-$THISVERSION}'/" qsiprep_docker.py | ||
python setup.py sdist | ||
pip wheel --no-deps -w dist/ . | ||
- run: | ||
name: Upload packages to PyPI | ||
command: | | ||
pip install --user twine | ||
pip install --user --upgrade importlib-metadata | ||
twine upload dist/BOnD*gz wrapper/dist/BOnD* | ||
deployable: | ||
docker: | ||
- image: busybox:latest | ||
steps: | ||
- run: echo Deploying! | ||
|
||
|
||
workflows: | ||
version: 2 | ||
build_test_deploy: | ||
jobs: | ||
- build: | ||
filters: | ||
tags: | ||
only: /.*/ | ||
|
||
- setup_conda: | ||
filters: | ||
branches: | ||
ignore: | ||
- /tests?\/.*/ | ||
- /docker\/.*/ | ||
tags: | ||
only: /.*/ | ||
|
||
- install_and_test: | ||
requires: | ||
- build | ||
- setup_conda | ||
filters: | ||
branches: | ||
ignore: | ||
- /tests?\/.*/ | ||
- /docker\/.*/ | ||
tags: | ||
only: /.*/ | ||
|
||
- build_docs: | ||
filters: | ||
branches: | ||
ignore: | ||
- /tests?\/.*/ | ||
- /docker\/.*/ | ||
tags: | ||
only: /.*/ | ||
|
||
- deployable: | ||
requires: | ||
- build_docs | ||
- install_and_test | ||
filters: | ||
branches: | ||
only: master | ||
tags: | ||
only: /.*/ | ||
|
||
- deploy_docker: | ||
requires: | ||
- deployable | ||
filters: | ||
branches: | ||
only: master | ||
tags: | ||
only: /.*/ | ||
|
||
- deploy_pypi: | ||
requires: | ||
- deployable | ||
filters: | ||
branches: | ||
ignore: /.*/ | ||
tags: | ||
only: /.*/ |
Oops, something went wrong.