Skip to content

Commit 0d1084d

Browse files
authored
Revert "[ENH] Move codecov to the end of each test"
1 parent 15f520d commit 0d1084d

File tree

6 files changed

+51
-44
lines changed

6 files changed

+51
-44
lines changed

.circle/codecov.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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+
# Send coverage data to codecov.io
13+
curl -so codecov.io https://codecov.io/bash
14+
chmod 755 codecov.io
15+
16+
find "${WORKDIR}/tests/" -name 'coverage*.xml' -maxdepth 1 -print0 | \
17+
xargs -0 -I file ./codecov.io -f file -t "${CODECOV_TOKEN}" -F unittests
18+
find "${WORKDIR}/tests/" -name 'smoketest*.xml' -maxdepth 1 -print0 | \
19+
xargs -0 -I file ./codecov.io -f file -t "${CODECOV_TOKEN}" -F smoketests
20+

.circle/tests.sh

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,27 @@ if [ "${CIRCLE_NODE_TOTAL:-}" != "4" ]; then
1313
exit 1
1414
fi
1515

16-
# These tests are manually balanced based on previous build timings.
16+
# These tests are manually balanced based on previous build timings.
1717
# They may need to be rebalanced in the future.
1818
case ${CIRCLE_NODE_INDEX} in
1919
0)
20-
docker run --rm=false -it -e CODECOV_TOKEN=${CODECOV_TOKEN} -e FSL_COURSE_DATA="/data/examples/nipype-fsl_course_data" -v $HOME/examples:/data/examples:ro -v $WORKDIR:/work -w /work nipype/nipype:py35 /usr/bin/run_pytests.sh && \
21-
docker run --rm=false -it -e CODECOV_TOKEN=${CODECOV_TOKEN} -e FSL_COURSE_DATA="/data/examples/nipype-fsl_course_data" -v $HOME/examples:/data/examples:ro -v $WORKDIR:/work -w /work nipype/nipype:py27 /usr/bin/run_pytests.sh && \
22-
docker run --rm=false -it -e CODECOV_TOKEN=${CODECOV_TOKEN} -v $WORKDIR:/work -w /src/nipype/doc nipype/nipype:py35 /usr/bin/run_builddocs.sh && \
23-
docker run --rm=false -it -e CODECOV_TOKEN=${CODECOV_TOKEN} -v $HOME/examples:/data/examples:ro -v $WORKDIR:/work -w /work nipype/nipype:py35 /usr/bin/run_examples.sh test_spm Linear /data/examples/ workflow3d && \
24-
docker run --rm=false -it -e CODECOV_TOKEN=${CODECOV_TOKEN} -v $HOME/examples:/data/examples:ro -v $WORKDIR:/work -w /work nipype/nipype:py35 /usr/bin/run_examples.sh test_spm Linear /data/examples/ workflow4d
20+
docker run --rm=false -it -e FSL_COURSE_DATA="/data/examples/nipype-fsl_course_data" -v $HOME/examples:/data/examples:ro -v $WORKDIR:/work -w /work nipype/nipype:py35 /usr/bin/run_pytests.sh && \
21+
docker run --rm=false -it -e FSL_COURSE_DATA="/data/examples/nipype-fsl_course_data" -v $HOME/examples:/data/examples:ro -v $WORKDIR:/work -w /work nipype/nipype:py27 /usr/bin/run_pytests.sh && \
22+
docker run --rm=false -it -v $WORKDIR:/work -w /src/nipype/doc nipype/nipype:py35 /usr/bin/run_builddocs.sh && \
23+
docker run --rm=false -it -v $HOME/examples:/data/examples:ro -v $WORKDIR:/work -w /work nipype/nipype:py35 /usr/bin/run_examples.sh test_spm Linear /data/examples/ workflow3d && \
24+
docker run --rm=false -it -v $HOME/examples:/data/examples:ro -v $WORKDIR:/work -w /work nipype/nipype:py35 /usr/bin/run_examples.sh test_spm Linear /data/examples/ workflow4d
2525
;;
2626
1)
27-
docker run --rm=false -it -e CODECOV_TOKEN=${CODECOV_TOKEN} -v $HOME/examples:/data/examples:ro -v $WORKDIR:/work -w /work nipype/nipype:py35 /usr/bin/run_examples.sh fmri_spm_dartel Linear /data/examples/ level1 && \
28-
docker run --rm=false -it -e CODECOV_TOKEN=${CODECOV_TOKEN} -v $HOME/examples:/data/examples:ro -v $WORKDIR:/work -w /work nipype/nipype:py35 /usr/bin/run_examples.sh fmri_spm_dartel Linear /data/examples/ l2pipeline
27+
docker run --rm=false -it -v $HOME/examples:/data/examples:ro -v $WORKDIR:/work -w /work nipype/nipype:py35 /usr/bin/run_examples.sh fmri_spm_dartel Linear /data/examples/ level1 && \
28+
docker run --rm=false -it -v $HOME/examples:/data/examples:ro -v $WORKDIR:/work -w /work nipype/nipype:py35 /usr/bin/run_examples.sh fmri_spm_dartel Linear /data/examples/ l2pipeline
2929
;;
3030
2)
31-
docker run --rm=false -it -e CODECOV_TOKEN=${CODECOV_TOKEN} -e NIPYPE_NUMBER_OF_CPUS=4 -v $HOME/examples:/data/examples:ro -v $WORKDIR:/work -w /work nipype/nipype:py27 /usr/bin/run_examples.sh fmri_spm_nested MultiProc /data/examples/ level1 && \
32-
docker run --rm=false -it -e CODECOV_TOKEN=${CODECOV_TOKEN} -e NIPYPE_NUMBER_OF_CPUS=4 -v $HOME/examples:/data/examples:ro -v $WORKDIR:/work -w /work nipype/nipype:py35 /usr/bin/run_examples.sh fmri_spm_nested MultiProc /data/examples/ l2pipeline
31+
docker run --rm=false -it -e NIPYPE_NUMBER_OF_CPUS=4 -v $HOME/examples:/data/examples:ro -v $WORKDIR:/work -w /work nipype/nipype:py27 /usr/bin/run_examples.sh fmri_spm_nested MultiProc /data/examples/ level1 && \
32+
docker run --rm=false -it -e NIPYPE_NUMBER_OF_CPUS=4 -v $HOME/examples:/data/examples:ro -v $WORKDIR:/work -w /work nipype/nipype:py35 /usr/bin/run_examples.sh fmri_spm_nested MultiProc /data/examples/ l2pipeline
3333
;;
3434
3)
35-
docker run --rm=false -it -e CODECOV_TOKEN=${CODECOV_TOKEN} -e NIPYPE_NUMBER_OF_CPUS=4 -v $HOME/examples:/data/examples:ro -v $WORKDIR:/work -w /work nipype/nipype:py35 /usr/bin/run_examples.sh fmri_spm_nested MultiProc /data/examples/ level1 && \
36-
docker run --rm=false -it -e CODECOV_TOKEN=${CODECOV_TOKEN} -v $HOME/examples:/data/examples:ro -v $WORKDIR:/work -w /work nipype/nipype:py35 /usr/bin/run_examples.sh fmri_fsl_feeds Linear /data/examples/ l1pipeline && \
37-
docker run --rm=false -it -e CODECOV_TOKEN=${CODECOV_TOKEN} -v $HOME/examples:/data/examples:ro -v $WORKDIR:/work -w /work nipype/nipype:py35 /usr/bin/run_examples.sh fmri_fsl_reuse Linear /data/examples/ level1_workflow
35+
docker run --rm=false -it -e NIPYPE_NUMBER_OF_CPUS=4 -v $HOME/examples:/data/examples:ro -v $WORKDIR:/work -w /work nipype/nipype:py35 /usr/bin/run_examples.sh fmri_spm_nested MultiProc /data/examples/ level1 && \
36+
docker run --rm=false -it -v $HOME/examples:/data/examples:ro -v $WORKDIR:/work -w /work nipype/nipype:py35 /usr/bin/run_examples.sh fmri_fsl_feeds Linear /data/examples/ l1pipeline && \
37+
docker run --rm=false -it -v $HOME/examples:/data/examples:ro -v $WORKDIR:/work -w /work nipype/nipype:py35 /usr/bin/run_examples.sh fmri_fsl_reuse Linear /data/examples/ level1_workflow
3838
;;
3939
esac

Dockerfile

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -71,20 +71,6 @@ RUN conda config --add channels conda-forge; sync && \
7171
RUN sed -i 's/\(backend *: \).*$/\1Agg/g' /usr/local/miniconda/lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages/matplotlib/mpl-data/matplotlibrc && \
7272
python -c "from matplotlib import font_manager"
7373

74-
# Install codecov inside container
75-
RUN curl -so /usr/bin/codecov.io https://codecov.io/bash && \
76-
chmod 755 /usr/bin/codecov.io
77-
78-
# Install CI scripts
79-
COPY docker/files/run_* /usr/bin/
80-
RUN chmod +x /usr/bin/run_*
81-
82-
# Replace imglob with a Python3 compatible version
83-
COPY nipype/external/fsl_imglob.py /usr/bin/fsl_imglob.py
84-
RUN rm -rf ${FSLDIR}/bin/imglob && \
85-
chmod +x /usr/bin/fsl_imglob.py && \
86-
ln -s /usr/bin/fsl_imglob.py ${FSLDIR}/bin/imglob
87-
8874
# Installing dev requirements (packages that are not in pypi)
8975
WORKDIR /src/
9076
COPY requirements.txt requirements.txt
@@ -97,6 +83,16 @@ RUN cd /src/nipype && \
9783
pip install -e .[all] && \
9884
rm -rf ~/.cache/pip
9985

86+
# Install CI scripts
87+
COPY docker/files/run_* /usr/bin/
88+
RUN chmod +x /usr/bin/run_*
89+
90+
# Replace imglob with a Python3 compatible version
91+
COPY nipype/external/fsl_imglob.py /usr/bin/fsl_imglob.py
92+
RUN rm -rf ${FSLDIR}/bin/imglob && \
93+
chmod +x /usr/bin/fsl_imglob.py && \
94+
ln -s /usr/bin/fsl_imglob.py ${FSLDIR}/bin/imglob
95+
10096
WORKDIR /work/
10197

10298
ARG BUILD_DATE

circle.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ dependencies:
2424
- sudo apt-get -y update && sudo apt-get install -y wget bzip2
2525
# Create work folder and force group permissions
2626
- mkdir -p $WORKDIR && sudo setfacl -d -m group:ubuntu:rwx $WORKDIR && sudo setfacl -m group:ubuntu:rwx $WORKDIR
27-
- mkdir -p $HOME/docker $HOME/examples $WORKDIR/tests $WORKDIR/crashfiles $WORKDIR/logs ${CIRCLE_TEST_REPORTS}/tests/
27+
- mkdir -p $HOME/docker $HOME/examples $WORKDIR/pytest $WORKDIR/logs
2828
override:
2929
- if [[ -e $HOME/docker/cache.tar ]]; then docker load --input $HOME/docker/cache.tar; fi :
3030
timeout: 6000
@@ -50,7 +50,9 @@ test:
5050
parallel: true
5151
post:
5252
# Place reports in the appropriate folder
53-
- cp ${WORKDIR}/tests/*.xml ${CIRCLE_TEST_REPORTS}/tests/
53+
- mkdir -p ${CIRCLE_TEST_REPORTS}/tests/ && cp ${WORKDIR}/tests/*.xml ${CIRCLE_TEST_REPORTS}/tests/
54+
# Send coverage data to codecov.io
55+
- bash .circle/codecov.sh
5456

5557
general:
5658
artifacts:

docker/files/run_examples.sh

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,8 @@ fi
2525
coverage run /src/nipype/tools/run_examples.py $@
2626
exit_code=$?
2727

28-
# Generate coverage report and submit if token is defined
28+
# Collect crashfiles and generate xml report
2929
coverage xml -o ${WORKDIR}/tests/smoketest_${example_id}.xml
30-
if [ "${CODECOV_TOKEN}" != "" ]; then
31-
codecov.io -f ${WORKDIR}/tests/smoketest_${example_id}.xml -t "${CODECOV_TOKEN}" -F smoketests
32-
fi
33-
34-
# Collect crashfiles
3530
find /work -name "crash-*" -maxdepth 1 -exec mv {} ${WORKDIR}/crashfiles/ \;
3631
exit $exit_code
3732

docker/files/run_pytests.sh

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,17 @@ export COVERAGE_FILE=${WORKDIR}/tests/.coverage.py${PYTHON_VERSION}
2828
py.test -v --junitxml=${WORKDIR}/tests/pytests_py${PYTHON_VERSION}.xml --cov nipype --cov-config /src/nipype/.coveragerc --cov-report xml:${WORKDIR}/tests/coverage_py${PYTHON_VERSION}.xml ${TESTPATH}
2929
exit_code=$?
3030

31-
if [ "${CODECOV_TOKEN}" != "" ]; then
32-
codecov.io -f ${WORKDIR}/tests/coverage_py${PYTHON_VERSION}.xml -t "${CODECOV_TOKEN}" -F unittests
33-
fi
34-
3531
# Workaround: run here the profiler tests in python 3
3632
if [[ "${PYTHON_VERSION}" -ge "30" ]]; then
3733
echo '[execution]' >> ${HOME}/.nipype/nipype.cfg
3834
echo 'profile_runtime = true' >> ${HOME}/.nipype/nipype.cfg
3935
export COVERAGE_FILE=${WORKDIR}/tests/.coverage.py${PYTHON_VERSION}_extra
4036
py.test -v --junitxml=${WORKDIR}/tests/pytests_py${PYTHON_VERSION}_extra.xml --cov nipype --cov-report xml:${WORKDIR}/tests/coverage_py${PYTHON_VERSION}_extra.xml /src/nipype/nipype/interfaces/tests/test_runtime_profiler.py /src/nipype/nipype/pipeline/plugins/tests/test_multiproc*.py
4137
exit_code=$(( $exit_code + $? ))
42-
43-
if [ "${CODECOV_TOKEN}" != "" ]; then
44-
codecov.io -f ${WORKDIR}/tests/coverage_py${PYTHON_VERSION}_extra.xml -t "${CODECOV_TOKEN}" -F unittests
45-
fi
4638
fi
4739

48-
# Collect crashfiles
4940
find /work -name "crash-*" -maxdepth 1 -exec mv {} ${WORKDIR}/crashfiles/ \;
41+
42+
# Just in case output xml files are misplaced,
43+
# then circle would not tell the tests failed otherwise
5044
exit ${exit_code}

0 commit comments

Comments
 (0)