Skip to content

Commit

Permalink
Update circleci to 2.1 api and fix dockerfile (#53)
Browse files Browse the repository at this point in the history
* update Dockerfile so it will build

* update circleci to 2.1 api

* fix config

* fix circle

* no_output_timeout instead of timeout

* remove double commas from substitution

* change to machine images

* fix license file

* fix license

* fix load docker image

* update cache

* split test_data cache from docker cache

* fix remove colons?

* move data loading to test

* add checkout to test

* save test_data cache

* fix save cache

* FIX use tmpfs instead of mounting tmp

* add filter entries for build and test

* FIX deploy

* FIX restore_cache key
  • Loading branch information
Shotgunosine authored May 28, 2020
1 parent 753bd76 commit 3a65466
Show file tree
Hide file tree
Showing 3 changed files with 124 additions and 52 deletions.
121 changes: 121 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
version: 2.1
jobs:
build:
machine:
image: circleci/classic:latest
steps:
- checkout
- restore_cache:
keys:
- v_0-image_cache-{{ checksum "Dockerfile" }}
- run:
name: load and build
command: |
if [[ -e ~/docker/image.tar ]]; then docker load -i ~/docker/image.tar; fi
git describe --tags > version
docker build -t bids/${CIRCLE_PROJECT_REPONAME} .
mkdir -p ~/docker; docker save "bids/${CIRCLE_PROJECT_REPONAME}" > ~/docker/image.tar
mkdir -p ~/license; echo "cHJpbnRmICJEeWxhbi5OaWVsc29uQGdtYWlsLmNvbVxuMzcwNjNcbiAqQ1lrZWhQYUNvRDlNXG4gRlM2N1BTWmRFV2lqb1xuIiA+IH4vbGljZW5zZS9saWNlbnNlLnR4dA==" | base64 -d | sh
no_output_timeout: 6h
- save_cache:
key: v_0-image_cache-{{ checksum "Dockerfile" }}-{{ .Revision }}-{{ epoch }}
paths:
- ~/docker
- ~/license
test:
machine:
image: circleci/classic:latest
steps:
- checkout
- restore_cache:
key: v_0-image_cache-{{ checksum "Dockerfile" }}-{{ .Revision }}
- restore_cache:
key: v_0-test_data
- run:
name: get data
command: |
if [[ ! -d ~/data/ds114_test1 ]]; then wget -c -O ${HOME}/ds114_test1.tar "https://files.osf.io/v1/resources/9q7dv/providers/osfstorage/57e54a326c613b01d7d3ed90" && mkdir -p ${HOME}/data && tar xf ${HOME}/ds114_test1.tar -C ${HOME}/data; fi
if [[ ! -d ~/data/ds114_test2 ]]; then wget -c -O ${HOME}/ds114_test2.tar "https://files.osf.io/v1/resources/9q7dv/providers/osfstorage/57e549f9b83f6901d457d162" && mkdir -p ${HOME}/data && tar xf ${HOME}/ds114_test2.tar -C ${HOME}/data; fi
if [[ ! -d ~/data/ds114_test1_freesurfer_precomp_v6.0.0 ]]; then wget -c --no-check-certificate -O ${HOME}/ds114_test1_freesurfer_precomp_v6.0.0.tar "https://osf.io/j6zk2/?action=download&version=1" && mkdir -p ${HOME}/data && tar xf ${HOME}/ds114_test1_freesurfer_precomp_v6.0.0.tar -C ${HOME}/data; fi
if [[ ! -d ~/data/ds114_test2_freesurfer_precomp_v6.0.0 ]]; then wget -c --no-check-certificate -O ${HOME}/ds114_test2_freesurfer_precomp_v6.0.0.tar "https://osf.io/yhzzj/?action=download&version=1" && mkdir -p ${HOME}/data && tar xf ${HOME}/ds114_test2_freesurfer_precomp_v6.0.0.tar -C ${HOME}/data; fi
- save_cache:
key: v_0-test_data
paths:
- ~/data
- run:
name: load image
command: docker load -i ~/docker/image.tar
- run:
name: print version
command: |
docker run -ti --rm --read-only -v ~/license/license.txt:/license.txt --tmpfs /tmp --tmpfs /var/tmp -v $PWD/ds114_test1:/bids_dataset bids/${CIRCLE_PROJECT_REPONAME} --version
docker run -ti --rm --read-only -v ~/license/license.txt:/license.txt --tmpfs /tmp --tmpfs /var/tmp -v ${HOME}/data/ds114_test1:/bids_dataset bids/${CIRCLE_PROJECT_REPONAME} -h
- run:
name: test 1
command: |
docker run -ti --rm --read-only -v ~/license/license.txt:/license.txt --tmpfs /tmp --tmpfs /var/tmp -v ${HOME}/data/ds114_test1:/bids_dataset -v ${HOME}/outputs1:/outputs bids/${CIRCLE_PROJECT_REPONAME} /bids_dataset /outputs participant --participant_label 01 --license_file=/license.txt --stages autorecon1 && cat ${HOME}/outputs1/sub-01/scripts/recon-all.done
no_output_timeout: 6h
- run:
name: test 2
command: |
docker run -ti --rm --read-only -v ~/license/license.txt:/license.txt --tmpfs /tmp --tmpfs /var/tmp -v ${HOME}/data/ds114_test2:/bids_dataset -v ${HOME}/outputs2:/outputs bids/${CIRCLE_PROJECT_REPONAME} /bids_dataset /outputs participant --participant_label 01 --steps cross-sectional --session_label test --license_file=/license.txt --stages autorecon1 && cat ${HOME}/outputs2/sub-01_ses-test/scripts/recon-all.done
no_output_timeout: 6h
- run:
name: group2 test 1
command: |
docker run -ti --rm --read-only -v ~/license/license.txt:/license.txt --tmpfs /tmp --tmpfs /var/tmp -v ${HOME}/data/ds114_test1:/bids_dataset -v ${HOME}/data/ds114_test1_freesurfer_precomp_v6.0.0:/outputs bids/${CIRCLE_PROJECT_REPONAME} /bids_dataset /outputs group2 --license_file=/license.txt && mkdir -p ${HOME}/outputs1/ && sudo mv ${HOME}/data/ds114_test1_freesurfer_precomp_v6.0.0/00_group* ${HOME}/outputs1/ && cat ${HOME}/outputs1/00_group2_stats_tables/lh.aparc.thickness.tsv && cat ${HOME}/outputs1/00_group2_stats_tables/euler.tsv
no_output_timeout: 6h
- run:
name: group2 test 2
command: |
docker run -ti --rm --read-only -v ~/license/license.txt:/license.txt --tmpfs /tmp --tmpfs /var/tmp -v ${HOME}/data/ds114_test2:/bids_dataset -v ${HOME}/data/ds114_test2_freesurfer_precomp_v6.0.0:/outputs bids/${CIRCLE_PROJECT_REPONAME} /bids_dataset /outputs group2 --license_file=/license.txt && mkdir -p ${HOME}/outputs2/ && sudo mv ${HOME}/data/ds114_test2_freesurfer_precomp_v6.0.0/00_group* ${HOME}/outputs2/ && cat ${HOME}/outputs2/00_group2_stats_tables/lh.aparc.thickness.tsv && cat ${HOME}/outputs2/00_group2_stats_tables/euler.tsv
no_output_timeout: 6h
- store_artifacts:
path: ~/outputs1
- store_artifacts:
path: ~/outputs2


deploy:
machine:
image: circleci/classic:latest
steps:
- checkout
- restore_cache:
key: v_0-image_cache-{{ checksum "Dockerfile" }}-{{ .Revision }}
- run:
name: load image
command: docker load -i ~/docker/image.tar
- deploy:
command: |
if [[ -n "$DOCKER_PASS" ]]; then docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p $DOCKER_PASS && docker push bids/${CIRCLE_PROJECT_REPONAME}:latest; fi
if [[ -n "$DOCKER_PASS" ]]; then docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p $DOCKER_PASS && docker tag bids/${CIRCLE_PROJECT_REPONAME} bids/${CIRCLE_PROJECT_REPONAME}:$CIRCLE_TAG && docker push bids/${CIRCLE_PROJECT_REPONAME}:$CIRCLE_TAG; fi
no_output_timeout: 6h

workflows:
version: 2.1
build_test_deploy:
jobs:
- build:
filters:
tags:
only: /.*/
branches:
only: /.*/
- test:
requires:
- build
filters:
tags:
only: /.*/
branches:
only: /.*/
- deploy:
requires:
- build
- test
filters:
branches:
ignore: /.*/
tags:
only: /.*/
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:trusty
FROM ubuntu:xenial

RUN apt-get update \
&& apt-get install -y wget
Expand All @@ -19,7 +19,8 @@ RUN wget -qO- https://surfer.nmr.mgh.harvard.edu/pub/dist/freesurfer/6.0.1/frees

RUN apt-get install -y python3
RUN apt-get install -y python3-pip
RUN pip3 install nibabel pandas
RUN apt-get install -y python3-pandas
RUN pip3 install nibabel pandas==0.21.0
RUN apt-get install -y python2.7
RUN apt-get install -y python-pip

Expand Down
50 changes: 0 additions & 50 deletions circle.yml

This file was deleted.

0 comments on commit 3a65466

Please sign in to comment.