Skip to content

Commit dd4f101

Browse files
authored
Merge pull request #1858 from oesteban/fix/CircleTests
[FIX] CircleCI tests - error codes are not propagated
2 parents 0366859 + 26dfd79 commit dd4f101

File tree

6 files changed

+64
-49
lines changed

6 files changed

+64
-49
lines changed

.circle/codecov.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
#
3+
# This script pull all coverage files into the $CIRCLE_TEST_REPORTS folder
4+
# and sends data to codecov.
5+
#
6+
7+
# Setting # $ help set
8+
set -e # Exit immediately if a command exits with a non-zero status.
9+
set -u # Treat unset variables as an error when substituting.
10+
set -x # Print command traces before executing command.
11+
12+
mkdir -p ${CIRCLE_TEST_REPORTS}/
13+
for report in $( ls ~/scratch/*.xml ); do
14+
rname=$( basename $report )
15+
cp ${report} ${CIRCLE_TEST_REPORTS}/${rname:: -4}_${CIRCLE_NODE_INDEX}.xml
16+
done
17+
18+
# Send coverage data to codecov.io
19+
curl -so codecov.io https://codecov.io/bash
20+
chmod 755 codecov.io
21+
22+
find "${CIRCLE_TEST_REPORTS}/" -name 'coverage*.xml' -print0 | \
23+
xargs -0 -I file ./codecov.io -f file -t "${CODECOV_TOKEN}" -F unittests
24+
find "${CIRCLE_TEST_REPORTS}/" -name 'smoketests*.xml' -print0 | \
25+
xargs -0 -I file ./codecov.io -f file -t "${CODECOV_TOKEN}" -F smoketests
Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
#!/bin/bash
2+
#
3+
# Balance nipype testing workflows across CircleCI build nodes
4+
#
25

3-
set -o nounset
4-
set -o xtrace
5-
6-
export CODECOV_TOKEN=ac172a50-8e66-42e5-8822-5373fcf54686
6+
# Setting # $ help set
7+
set -e # Exit immediately if a command exits with a non-zero status.
8+
set -u # Treat unset variables as an error when substituting.
9+
set -x # Print command traces before executing command.
710

811
if [ "${CIRCLE_NODE_TOTAL:-}" != "4" ]; then
912
echo "These tests were designed to be run at 4x parallelism."
@@ -14,15 +17,15 @@ fi
1417
# They may need to be rebalanced in the future.
1518
case ${CIRCLE_NODE_INDEX} in
1619
0)
17-
docker run --rm -it -v $HOME/examples:/root/examples:ro -v $SCRATCH:/scratch -w /scratch nipype/nipype_test:py35 /usr/bin/run_examples.sh fmri_spm_dartel Linear /root/examples/ level1 && \
18-
docker run --rm -it -v $HOME/examples:/root/examples:ro -v $SCRATCH:/scratch -w /scratch nipype/nipype_test:py35 /usr/bin/run_examples.sh fmri_spm_dartel Linear /root/examples/ l2pipeline
19-
;;
20-
1)
21-
docker run --rm -it -v $HOME/examples:/root/examples:ro -v $SCRATCH:/scratch -w /scratch nipype/nipype_test:py35 /usr/bin/run_examples.sh test_spm Linear /root/examples/ workflow3d && \
22-
docker run --rm -it -v $HOME/examples:/root/examples:ro -v $SCRATCH:/scratch -w /scratch nipype/nipype_test:py35 /usr/bin/run_examples.sh test_spm Linear /root/examples/ workflow4d && \
2320
docker run --rm -it -e FSL_COURSE_DATA="/root/examples/nipype-fsl_course_data" -v $HOME/examples:/root/examples:ro -v $SCRATCH:/scratch -w /root/src/nipype nipype/nipype_test:py27 /usr/bin/run_pytests.sh py27 && \
2421
docker run --rm -it -e FSL_COURSE_DATA="/root/examples/nipype-fsl_course_data" -v $HOME/examples:/root/examples:ro -v $SCRATCH:/scratch -w /root/src/nipype nipype/nipype_test:py35 /usr/bin/run_pytests.sh py35 && \
25-
docker run --rm -it -v $SCRATCH:/scratch -w /root/src/nipype/doc nipype/nipype_test:py35 /usr/bin/run_builddocs.sh
22+
docker run --rm -it -v $SCRATCH:/scratch -w /root/src/nipype/doc nipype/nipype_test:py35 /usr/bin/run_builddocs.sh && \
23+
docker run --rm -it -v $HOME/examples:/root/examples:ro -v $SCRATCH:/scratch -w /scratch nipype/nipype_test:py35 /usr/bin/run_examples.sh test_spm Linear /root/examples/ workflow3d && \
24+
docker run --rm -it -v $HOME/examples:/root/examples:ro -v $SCRATCH:/scratch -w /scratch nipype/nipype_test:py35 /usr/bin/run_examples.sh test_spm Linear /root/examples/ workflow4d
25+
;;
26+
1)
27+
docker run --rm -it -v $HOME/examples:/root/examples:ro -v $SCRATCH:/scratch -w /scratch nipype/nipype_test:py35 /usr/bin/run_examples.sh fmri_spm_dartel Linear /root/examples/ level1 && \
28+
docker run --rm -it -v $HOME/examples:/root/examples:ro -v $SCRATCH:/scratch -w /scratch nipype/nipype_test:py35 /usr/bin/run_examples.sh fmri_spm_dartel Linear /root/examples/ l2pipeline
2629
;;
2730
2)
2831
docker run --rm -it -e NIPYPE_NUMBER_OF_CPUS=4 -v $HOME/examples:/root/examples:ro -v $SCRATCH:/scratch -w /scratch nipype/nipype_test:py27 /usr/bin/run_examples.sh fmri_spm_nested MultiProc /root/examples/ level1 && \
@@ -34,14 +37,3 @@ case ${CIRCLE_NODE_INDEX} in
3437
docker run --rm -it -v $HOME/examples:/root/examples:ro -v $SCRATCH:/scratch -w /scratch nipype/nipype_test:py35 /usr/bin/run_examples.sh fmri_fsl_reuse Linear /root/examples/ level1_workflow
3538
;;
3639
esac
37-
38-
# Put the artifacts in place
39-
bash docker/files/teardown.sh
40-
41-
# Send coverage data to codecov.io
42-
curl -so codecov.io https://codecov.io/bash
43-
chmod 755 codecov.io
44-
find "${CIRCLE_TEST_REPORTS}/pytest" -name 'coverage*.xml' -print0 | \
45-
xargs -0 -I file ./codecov.io -f file -t "${CODECOV_TOKEN}" -F unittests
46-
find "${CIRCLE_TEST_REPORTS}/pytest" -name 'smoketests*.xml' -print0 | \
47-
xargs -0 -I file ./codecov.io -f file -t "${CODECOV_TOKEN}" -F smoketests

.dockerignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,13 @@ src/
2323
# other
2424
docs/**/*
2525
docs/
26+
.circle/**/*
27+
.circle/
28+
circle.yml
2629
.coverage
2730
.coveragerc
2831
codecov.yml
2932
rtd_requirements.txt
30-
circle.yml
3133
Vagrantfile
3234
.travis.yml
3335
.noserc

circle.yml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ machine:
88
DATA_NIPYPE_FSL_COURSE: "${OSF_NIPYPE_URL}/57f472cf9ad5a101f977ecfe"
99
DATA_NIPYPE_FSL_FEEDS: "${OSF_NIPYPE_URL}/57f473066c613b01f113e7af"
1010
SCRATCH: "$HOME/scratch"
11+
CODECOV_TOKEN: "ac172a50-8e66-42e5-8822-5373fcf54686"
1112
services:
1213
- docker
1314

@@ -32,34 +33,39 @@ dependencies:
3233
- if [[ ! -d ~/examples/feeds ]]; then wget --retry-connrefused --waitretry=5 --read-timeout=20 --timeout=15 -t 0 -q -O fsl-5.0.9-feeds.tar.gz "${DATA_NIPYPE_FSL_FEEDS}" && tar xzf fsl-5.0.9-feeds.tar.gz -C ~/examples/; fi
3334
- docker images
3435
- sed -i -E "s/(__version__ = )'[A-Za-z0-9.-]+'/\1'$CIRCLE_TAG'/" nipype/info.py
35-
- e=1 && for i in {1..5}; do docker build -t nipype/nipype:latest --build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` --build-arg VCS_REF=`git rev-parse --short HEAD` --build-arg VERSION=$CIRCLE_TAG . && e=0 && break || sleep 15; done && [ "$e" -eq "0" ] :
36+
- e=1 && for i in {1..5}; do docker build --rm=false -t nipype/nipype:latest --build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` --build-arg VCS_REF=`git rev-parse --short HEAD` --build-arg VERSION=$CIRCLE_TAG . && e=0 && break || sleep 15; done && [ "$e" -eq "0" ] :
3637
timeout: 21600
37-
- e=1 && for i in {1..5}; do docker build -f docker/Dockerfile_py27 -t nipype/nipype_test:py27 . && e=0 && break || sleep 15; done && [ "$e" -eq "0" ] :
38+
- e=1 && for i in {1..5}; do docker build --rm=false -f docker/Dockerfile_py27 -t nipype/nipype_test:py27 . && e=0 && break || sleep 15; done && [ "$e" -eq "0" ] :
3839
timeout: 1600
39-
- e=1 && for i in {1..5}; do docker build -f docker/Dockerfile_py35 -t nipype/nipype_test:py35 . && e=0 && break || sleep 15; done && [ "$e" -eq "0" ] :
40+
- e=1 && for i in {1..5}; do docker build --rm=false -f docker/Dockerfile_py35 -t nipype/nipype_test:py35 . && e=0 && break || sleep 15; done && [ "$e" -eq "0" ] :
4041
timeout: 1600
4142
- docker save -o $HOME/docker/cache.tar nipype/nipype:latest nipype/nipype_test:py27 nipype/nipype_test:py35 :
4243
timeout: 6000
4344

4445
test:
4546
override:
46-
- bash docker/files/tests.sh :
47+
- bash .circle/tests.sh :
4748
timeout: 7200
4849
parallel: true
50+
post:
51+
# Send coverage data to codecov.io
52+
- bash .circle/codecov.sh
4953

5054
general:
5155
artifacts:
52-
- "~/docs"
53-
- "~/logs"
56+
- "~/scratch/docs"
57+
- "~/scratch/logs"
5458

5559
deployment:
5660
production:
5761
tag: /.*/
5862
commands:
63+
# Deploy to docker hub
5964
- if [[ -n "$DOCKER_PASS" ]]; then docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p $DOCKER_PASS && docker push nipype/nipype:latest; fi :
6065
timeout: 21600
6166
- if [[ -n "$DOCKER_PASS" ]]; then docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p $DOCKER_PASS && docker tag nipype/nipype nipype/nipype:$CIRCLE_TAG && docker push nipype/nipype:$CIRCLE_TAG; fi :
6267
timeout: 21600
68+
6369
# Automatic deployment to Pypi:
6470
# - printf "[distutils]\nindex-servers =\n pypi\n\n[pypi]\nusername:$PYPI_USER\npassword:$PYPI_PASS\n" > ~/.pypirc
6571
# - python setup.py sdist upload -r pypi

docker/files/teardown.sh

Lines changed: 0 additions & 15 deletions
This file was deleted.

nipype/interfaces/freesurfer/tests/test_preprocess.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,18 +98,23 @@ def test_mandatory_outvol(create_files_in_directory):
9898
with pytest.raises(ValueError): mni.cmdline
9999

100100
# test with minimal args
101-
mni.inputs.in_file = filelist[0]
102-
assert mni.cmdline == ('mri_nu_correct.mni --i %s --o %s_output.mgz'
103-
% (filelist[0], filelist[0].replace('.mgz', '')))
101+
mni.inputs.in_file = filelist[0]
102+
base, ext = os.path.splitext(os.path.basename(filelist[0]))
103+
if ext == '.gz':
104+
base, ext2 = os.path.splitext(base)
105+
ext = ext2 + ext
106+
107+
assert mni.cmdline == (
108+
'mri_nu_correct.mni --i %s --o %s_output%s' % (filelist[0], base, ext))
104109

105110
# test with custom outfile
106111
mni.inputs.out_file = 'new_corrected_file.mgz'
107112
assert mni.cmdline == ('mri_nu_correct.mni --i %s --o new_corrected_file.mgz'
108113
% (filelist[0]))
109114

110115
# constructor based tests
111-
mni2 = freesurfer.MNIBiasCorrection(in_file=filelist[0],
116+
mni2 = freesurfer.MNIBiasCorrection(in_file=filelist[0],
112117
out_file='bias_corrected_output',
113118
iterations=4)
114-
assert mni2.cmdline == ('mri_nu_correct.mni --i %s --n 4 --o bias_corrected_output.mgz'
119+
assert mni2.cmdline == ('mri_nu_correct.mni --i %s --n 4 --o bias_corrected_output'
115120
% filelist[0])

0 commit comments

Comments
 (0)