Skip to content

Commit 50e4949

Browse files
committed
CI: Build images in each job
1 parent 83b9933 commit 50e4949

File tree

1 file changed

+150
-49
lines changed

1 file changed

+150
-49
lines changed

.circleci/config.yml

Lines changed: 150 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
- docker/Dockerfile.base-pruned
3636
- docker/get_base_image.sh
3737

38-
build_images:
38+
test_pytest:
3939
machine:
4040
# Ubuntu 14.04 with Docker 17.10.0-ce
4141
image: circleci/classic:201710-02
@@ -100,35 +100,6 @@ jobs:
100100
--build-arg VERSION="${CIRCLE_TAG}-py27" /home/circleci/nipype \
101101
&& e=0 && break || sleep 15
102102
done && [ "$e" -eq "0" ]
103-
- run:
104-
name: Save Docker images to workspace
105-
no_output_timeout: 60m
106-
command: |
107-
docker save nipype/nipype:base \
108-
nipype/nipype:latest \
109-
nipype/nipype:py27 \
110-
nipype/nipype:py36 | gzip -1 > /tmp/docker/nipype-base-latest-py36-py27.tar.gz \
111-
&& du -h /tmp/docker/nipype-base-latest-py36-py27.tar.gz
112-
- persist_to_workspace:
113-
root: /tmp
114-
paths:
115-
- docker/*
116-
117-
test_pytest:
118-
machine:
119-
# Ubuntu 14.04 with Docker 17.10.0-ce
120-
image: circleci/classic:201710-02
121-
working_directory: /home/circleci/nipype
122-
steps:
123-
- attach_workspace:
124-
at: /tmp
125-
- run:
126-
name: Load saved Docker images.
127-
no_output_timeout: 60m
128-
command: |
129-
docker load < /tmp/docker/nipype-base-latest-py36-py27.tar.gz
130-
- checkout:
131-
path: /home/circleci/nipype
132103
- run:
133104
name: Get codecov
134105
command: |
@@ -166,15 +137,50 @@ jobs:
166137
image: circleci/classic:201710-02
167138
working_directory: /home/circleci/nipype
168139
steps:
140+
- checkout:
141+
path: /home/circleci/nipype
169142
- attach_workspace:
170143
at: /tmp
171144
- run:
172-
name: Load saved Docker images.
145+
name: Generate Dockerfiles
146+
command: |
147+
make gen-dockerfiles
148+
- run:
149+
name: Modify Nipype version if necessary
150+
command: |
151+
if [ "$CIRCLE_TAG" != "" ]; then
152+
sed -i -E "s/(__version__ = )'[A-Za-z0-9.-]+'/\1'$CIRCLE_TAG'/" nipype/info.py
153+
fi
154+
- run:
155+
name: Get base image (pull or build)
173156
no_output_timeout: 60m
174157
command: |
175-
docker load < /tmp/docker/nipype-base-latest-py36-py27.tar.gz
176-
- checkout:
177-
path: /home/circleci/nipype
158+
source /tmp/docker/get_base_image.sh
159+
if [ "$GET_BASE" == "PULL" ]; then
160+
echo "Pulling base image ..."
161+
docker pull nipype/nipype:base
162+
elif [ "$GET_BASE" == "BUILD" ]; then
163+
e=1 && for i in {1..5}; do
164+
docker build -t nipype/nipype:base - < docker/Dockerfile.base && e=0 && break || sleep 15
165+
done && [ "$e" -eq "0" ]
166+
else
167+
echo "Error: method to get base image not understood"
168+
exit 1
169+
fi
170+
- run:
171+
name: Build main image (py36)
172+
no_output_timeout: 60m
173+
command: |
174+
e=1 && for i in {1..5}; do
175+
docker build \
176+
--rm=false \
177+
--tag nipype/nipype:latest \
178+
--tag nipype/nipype:py36 \
179+
--build-arg BUILD_DATE="$(date -u +"%Y-%m-%dT%H:%M:%SZ")" \
180+
--build-arg VCS_REF="$(git rev-parse --short HEAD)" \
181+
--build-arg VERSION="${CIRCLE_TAG}" /home/circleci/nipype \
182+
&& e=0 && break || sleep 15
183+
done && [ "$e" -eq "0" ]
178184
- run:
179185
name: Get codecov
180186
command: |
@@ -215,15 +221,50 @@ jobs:
215221
image: circleci/classic:201710-02
216222
working_directory: /home/circleci/nipype
217223
steps:
224+
- checkout:
225+
path: /home/circleci/nipype
218226
- attach_workspace:
219227
at: /tmp
220228
- run:
221-
name: Load saved Docker images.
229+
name: Generate Dockerfiles
230+
command: |
231+
make gen-dockerfiles
232+
- run:
233+
name: Modify Nipype version if necessary
234+
command: |
235+
if [ "$CIRCLE_TAG" != "" ]; then
236+
sed -i -E "s/(__version__ = )'[A-Za-z0-9.-]+'/\1'$CIRCLE_TAG'/" nipype/info.py
237+
fi
238+
- run:
239+
name: Get base image (pull or build)
222240
no_output_timeout: 60m
223241
command: |
224-
docker load < /tmp/docker/nipype-base-latest-py36-py27.tar.gz
225-
- checkout:
226-
path: /home/circleci/nipype
242+
source /tmp/docker/get_base_image.sh
243+
if [ "$GET_BASE" == "PULL" ]; then
244+
echo "Pulling base image ..."
245+
docker pull nipype/nipype:base
246+
elif [ "$GET_BASE" == "BUILD" ]; then
247+
e=1 && for i in {1..5}; do
248+
docker build -t nipype/nipype:base - < docker/Dockerfile.base && e=0 && break || sleep 15
249+
done && [ "$e" -eq "0" ]
250+
else
251+
echo "Error: method to get base image not understood"
252+
exit 1
253+
fi
254+
- run:
255+
name: Build main image (py36)
256+
no_output_timeout: 60m
257+
command: |
258+
e=1 && for i in {1..5}; do
259+
docker build \
260+
--rm=false \
261+
--tag nipype/nipype:latest \
262+
--tag nipype/nipype:py36 \
263+
--build-arg BUILD_DATE="$(date -u +"%Y-%m-%dT%H:%M:%SZ")" \
264+
--build-arg VCS_REF="$(git rev-parse --short HEAD)" \
265+
--build-arg VERSION="${CIRCLE_TAG}" /home/circleci/nipype \
266+
&& e=0 && break || sleep 15
267+
done && [ "$e" -eq "0" ]
227268
- run:
228269
name: Get codecov
229270
command: |
@@ -262,15 +303,65 @@ jobs:
262303
image: circleci/classic:201710-02
263304
working_directory: /home/circleci/nipype
264305
steps:
306+
- checkout:
307+
path: /home/circleci/nipype
265308
- attach_workspace:
266309
at: /tmp
267310
- run:
268-
name: Load saved Docker images.
311+
name: Generate Dockerfiles
312+
command: |
313+
make gen-dockerfiles
314+
- run:
315+
name: Modify Nipype version if necessary
316+
command: |
317+
if [ "$CIRCLE_TAG" != "" ]; then
318+
sed -i -E "s/(__version__ = )'[A-Za-z0-9.-]+'/\1'$CIRCLE_TAG'/" nipype/info.py
319+
fi
320+
- run:
321+
name: Get base image (pull or build)
269322
no_output_timeout: 60m
270323
command: |
271-
docker load < /tmp/docker/nipype-base-latest-py36-py27.tar.gz
272-
- checkout:
273-
path: /home/circleci/nipype
324+
source /tmp/docker/get_base_image.sh
325+
if [ "$GET_BASE" == "PULL" ]; then
326+
echo "Pulling base image ..."
327+
docker pull nipype/nipype:base
328+
elif [ "$GET_BASE" == "BUILD" ]; then
329+
e=1 && for i in {1..5}; do
330+
docker build -t nipype/nipype:base - < docker/Dockerfile.base && e=0 && break || sleep 15
331+
done && [ "$e" -eq "0" ]
332+
else
333+
echo "Error: method to get base image not understood"
334+
exit 1
335+
fi
336+
- run:
337+
name: Build main image (py36)
338+
no_output_timeout: 60m
339+
command: |
340+
e=1 && for i in {1..5}; do
341+
docker build \
342+
--rm=false \
343+
--tag nipype/nipype:latest \
344+
--tag nipype/nipype:py36 \
345+
--build-arg BUILD_DATE="$(date -u +"%Y-%m-%dT%H:%M:%SZ")" \
346+
--build-arg VCS_REF="$(git rev-parse --short HEAD)" \
347+
--build-arg VERSION="${CIRCLE_TAG}" /home/circleci/nipype \
348+
&& e=0 && break || sleep 15
349+
done && [ "$e" -eq "0" ]
350+
- run:
351+
name: Build main image (py27)
352+
no_output_timeout: 60m
353+
command: |
354+
e=1 && for i in {1..5}; do
355+
docker build \
356+
--rm=false \
357+
--tag nipype/nipype:py27 \
358+
--build-arg PYTHON_VERSION_MAJOR=2 \
359+
--build-arg PYTHON_VERSION_MINOR=7 \
360+
--build-arg BUILD_DATE="$(date -u +"%Y-%m-%dT%H:%M:%SZ")" \
361+
--build-arg VCS_REF="$(git rev-parse --short HEAD)" \
362+
--build-arg VERSION="${CIRCLE_TAG}-py27" /home/circleci/nipype \
363+
&& e=0 && break || sleep 15
364+
done && [ "$e" -eq "0" ]
274365
- run:
275366
name: Get codecov
276367
command: |
@@ -302,6 +393,19 @@ jobs:
302393
bash /home/circleci/nipype/.circleci/test_py2_fmri_spm_nested_multiproc_l2.sh
303394
- store_artifacts:
304395
path: /home/circleci/work/tests
396+
- run:
397+
name: Save Docker images to workspace
398+
no_output_timeout: 60m
399+
command: |
400+
docker save nipype/nipype:base \
401+
nipype/nipype:latest \
402+
nipype/nipype:py27 \
403+
nipype/nipype:py36 | gzip -1 > /tmp/docker/nipype-base-latest-py36-py27.tar.gz \
404+
&& du -h /tmp/docker/nipype-base-latest-py36-py27.tar.gz
405+
- persist_to_workspace:
406+
root: /tmp
407+
paths:
408+
- docker/*
305409

306410
deploy:
307411
docker:
@@ -340,21 +444,18 @@ workflows:
340444
build_test_deploy:
341445
jobs:
342446
- compare_base_dockerfiles
343-
- build_images:
344-
requires:
345-
- compare_base_dockerfiles
346447
- test_pytest:
347448
requires:
348-
- build_images
449+
- compare_base_dockerfiles
349450
- test_py3_fmri_fsl_spm:
350451
requires:
351-
- build_images
452+
- compare_base_dockerfiles
352453
- test_py3_fmri_spm_dartel_linear:
353454
requires:
354-
- build_images
455+
- compare_base_dockerfiles
355456
- test_fmri_spm_nested_multiproc:
356457
requires:
357-
- build_images
458+
- compare_base_dockerfiles
358459
- deploy:
359460
filters:
360461
branches:

0 commit comments

Comments
 (0)