11version : 2.1
22
33commands :
4+ build-images :
5+ parameters :
6+ variant :
7+ type : string
8+ default : " "
9+ steps :
10+ - set-up-variant :
11+ variant : " << parameters.variant >>"
12+ - run :
13+ name : " Building Docker image"
14+ command : |
15+ docker build -t fcpindi/c-pac:${DOCKER_TAG} . ${DOCKERFILE}
16+ docker save fcpindi/c-pac:${DOCKER_TAG} | gzip > ${DOCKER_TARBALL}.tar.gz
17+ no_output_timeout : 5h
18+ - run :
19+ name : " Starting local registry"
20+ command : docker run -d -p 5000:5000 --restart=always --name registry registry:2
21+ - install-singularity-requirements
22+ - when :
23+ condition :
24+ or :
25+ - equal : [ "", "<< parameters.variant >>" ]
26+ - equal : [ "lite", "<< parameters.variant >>" ]
27+ steps :
28+ - run :
29+ name : " Cloning Singularity 2.5.2"
30+ command : git clone -b 2.5.2 https://github.com/sylabs/singularity
31+ - set-up-singularity
32+ - run :
33+ name : " Building Singularity image from Docker image"
34+ command : |
35+ docker load < ${DOCKER_TARBALL}.tar.gz
36+ docker tag fcpindi/c-pac:${CIRCLE_BRANCH//\//_}${VARIANT} localhost:5000/fcpindi/c-pac:${CIRCLE_BRANCH//\//_}${VARIANT}
37+ docker push localhost:5000/fcpindi/c-pac:${CIRCLE_BRANCH//\//_}${VARIANT}
38+ SINGULARITY_NOHTTPS=1 singularity build cpac-singularity-image${VARIANT}.simg docker://localhost:5000/fcpindi/c-pac:${CIRCLE_BRANCH//\//_}${VARIANT}
39+ no_output_timeout : 5h
440 check-for-built-images :
541 steps :
642 - run :
@@ -10,6 +46,25 @@ commands:
1046 then
1147 circleci step halt
1248 fi
49+ configure-git-user :
50+ steps :
51+ - add_ssh_keys :
52+ fingerprints :
53+ - " 12:bc:f2:e4:31:cc:72:54:54:bc:f5:5b:89:e6:d8:ee"
54+ - run :
55+ name : " Configuring git user"
56+ command : |
57+ sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 78BD65473CB3BD13
58+ curl -L https://packagecloud.io/circleci/trusty/gpgkey | sudo apt-key add -
59+ sudo apt-get update
60+ sudo apt-get install git -y
61+ git config --global user.email "${CIRCLE_USERNAME}@users.noreply.github.com"
62+ git config --global user.name "${CIRCLE_USERNAME} @ CircleCI"
63+ get-sample-bids-data :
64+ steps :
65+ - run :
66+ name : Getting Sample BIDS Data
67+ command : git clone https://github.com/bids-standard/bids-examples.git
1368 set-python-version :
1469 steps :
1570 - run :
@@ -24,6 +79,14 @@ commands:
2479 name : " Installing Singularity requirements"
2580 command : |
2681 sudo apt-get update && sudo apt-get install flawfinder squashfs-tools uuid-dev libuuid1 libffi-dev libssl-dev libssl1.1 libarchive-dev libgpgme11-dev libseccomp-dev -y
82+ run-pytest-docker :
83+ steps :
84+ - run :
85+ name : Running pytest on Docker image
86+ command : |
87+ docker load < cpac-docker-image.tar.gz
88+ docker run -dit -P -v /home/circleci/project/test-results:/code/test-results -v /home/circleci/project/htmlcov:/code/htmlcov --entrypoint=/bin/bash --name docker_test fcpindi/c-pac:${DOCKER_TAG}
89+ docker exec docker_test /bin/bash ./code/dev/circleci_data/test_in_image.sh
2790 set-up-singularity :
2891 steps :
2992 - run :
@@ -35,11 +98,10 @@ commands:
3598 make
3699 sudo make install
37100 cd ..
38- build-images :
101+ set-up-variant :
39102 parameters :
40103 variant :
41104 type : string
42- default : " "
43105 steps :
44106 - run :
45107 name : " Setting up variant"
@@ -48,81 +110,50 @@ commands:
48110 if [[ -n "<< parameters.variant >>" ]]
49111 then
50112 DOCKERFILE="variant-<< parameters.variant >>.Dockerfile"
51- sed -i "s|:latest|:${CIRCLE_BRANCH//\//_}|g" ${DOCKERFILE}
113+ if [[ -f ${DOCKERFILE} ]]
114+ then
115+ sed -i "s|:latest|:${CIRCLE_BRANCH//\//_}|g" ${DOCKERFILE}
116+ fi
52117 DOCKER_TARBALL="${DOCKER_TARBALL}-<< parameters.variant >>"
53118 VARIANT="-<< parameters.variant >>"
54119 echo "export DOCKERFILE=\"-f ${DOCKERFILE}\"" >> $BASH_ENV
55120 fi
56121 echo "export DOCKER_TARBALL=${DOCKER_TARBALL}" >> $BASH_ENV
57122 echo "export VARIANT=${VARIANT}" >> $BASH_ENV
58- - run :
59- name : " Building Docker image"
60- command : |
61- docker build -t fcpindi/c-pac:${CIRCLE_BRANCH//\//_}${VARIANT} . ${DOCKERFILE}
62- docker save fcpindi/c-pac:${CIRCLE_BRANCH//\//_}${VARIANT} | gzip > ${DOCKER_TARBALL}.tar.gz
63- no_output_timeout : 5h
64- # Persist the specified paths (workspace/echo-output) into the workspace for use in downstream job.
65- - run :
66- name : " Starting local registry"
67- command : docker run -d -p 5000:5000 --restart=always --name registry registry:2
68- - install-singularity-requirements
69- - when :
70- condition :
71- equal : [ "", "<< parameters.variant >>" ]
72- steps :
73- - run :
74- name : " Cloning Singularity 2.5.2"
75- command : git clone -b 2.5.2 https://github.com/sylabs/singularity
76- - set-up-singularity
77- - run :
78- name : " Building Singularity image from Docker image"
79- command : |
80- docker load < ${DOCKER_TARBALL}.tar.gz
81- docker tag fcpindi/c-pac:${CIRCLE_BRANCH//\//_}${VARIANT} localhost:5000/fcpindi/c-pac:${CIRCLE_BRANCH//\//_}${VARIANT}
82- docker push localhost:5000/fcpindi/c-pac:${CIRCLE_BRANCH//\//_}${VARIANT}
83- SINGULARITY_NOHTTPS=1 singularity build cpac-singularity-image${VARIANT}.simg docker://localhost:5000/fcpindi/c-pac:${CIRCLE_BRANCH//\//_}${VARIANT}
84- no_output_timeout : 5h
85- configure-git-user :
123+ DOCKER_TAG=${CIRCLE_BRANCH//\//_}${VARIANT}
124+ echo "export DOCKER_TAG=${DOCKER_TAG}" >> $BASH_ENV
125+ test-singularity-installation :
86126 steps :
87- - add_ssh_keys :
88- fingerprints :
89- - " 12:bc:f2:e4:31:cc:72:54:54:bc:f5:5b:89:e6:d8:ee"
90127 - run :
91- name : " Configuring git user "
128+ name : Testing Singularity installation
92129 command : |
93- sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 78BD65473CB3BD13
94- curl -L https://packagecloud.io/circleci/trusty/gpgkey | sudo apt-key add -
95- sudo apt-get update
96- sudo apt-get install git -y
97- git config --global user.email "${CIRCLE_USERNAME}@users.noreply.github.com"
98- git config --global user.name "${CIRCLE_USERNAME} @ CircleCI"
130+ pip install -r dev/circleci_data/requirements.txt
131+ coverage run -m pytest --junitxml=test-results/junit.xml --continue-on-collection-errors dev/circleci_data/test_install.py
99132
100133jobs :
101134 pytest-docker :
135+ parameters :
136+ variant :
137+ type : string
138+ default : " "
102139 machine :
103140 image : ubuntu-2004:202010-01
104141 steps :
105142 - attach_workspace :
106- # Must be absolute path or relative path from working_directory
107143 at : /home/circleci/
144+ - set-up-variant :
145+ variant : " << parameters.variant >>"
108146 - check-for-built-images
109147 - set-python-version
110- - run :
111- name : Getting Sample BIDS Data
112- command : git clone https://github.com/bids-standard/bids-examples.git
113- - run :
114- name : Running pytest on Docker image
115- command : |
116- docker load < cpac-docker-image.tar.gz
117- docker run -dit -P -v /home/circleci/project/test-results:/code/test-results -v /home/circleci/project/htmlcov:/code/htmlcov --entrypoint=/bin/bash --name docker_test fcpindi/c-pac:${CIRCLE_BRANCH//\//_}
118- docker exec docker_test /bin/bash ./code/dev/circleci_data/test_in_image.sh
148+ - get-sample-bids-data
149+ - run-pytest-docker
119150 - store_test_results :
120151 path : test-results
121152 - store_artifacts :
122153 path : test-results
123154 - store_artifacts :
124155 path : htmlcov
125- no_output_timeout : 5h
156+
126157 pytest-singularity :
127158 machine :
128159 image : ubuntu-2004:202010-01
@@ -134,11 +165,8 @@ jobs:
134165 - set-python-version
135166 - install-singularity-requirements
136167 - set-up-singularity
137- - run :
138- name : Testing Singularity installation
139- command : |
140- pip install -r dev/circleci_data/requirements.txt
141- coverage run -m pytest --junitxml=test-results/junit.xml --continue-on-collection-errors dev/circleci_data/test_install.py
168+ - test-singularity-installation
169+
142170 build :
143171 machine :
144172 image : ubuntu-2004:202010-01
@@ -196,11 +224,24 @@ workflows:
196224 version : 2
197225 build-and-test :
198226 jobs :
199- - build
200- - build-lite
227+ - build :
228+ name : " Build images"
229+ - build-lite :
230+ name : " Build lite variant images"
231+ - pytest-docker :
232+ name : " Test in Docker"
233+ requires :
234+ - " Build images"
201235 - pytest-docker :
236+ name : " Test lite variant in Docker"
237+ requires :
238+ - " Build lite variant images"
239+ variant : lite
240+ - pytest-singularity :
241+ name : " Test in Singularity"
202242 requires :
203- - build
243+ - " Build images "
204244 - pytest-singularity :
245+ name : " Test lite variant in Singularity"
205246 requires :
206- - build
247+ - " Build lite variant images "
0 commit comments