Skip to content

Commit addda24

Browse files
authored
Merge pull request #1889 from oesteban/circle/Codecov
[ENH] Move codecov to the end of each test
2 parents 22ca05c + 96a37eb commit addda24

File tree

6 files changed

+44
-51
lines changed

6 files changed

+44
-51
lines changed

.circle/codecov.sh

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

.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 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
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
2525
;;
2626
1)
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
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
2929
;;
3030
2)
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
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
3333
;;
3434
3)
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
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
3838
;;
3939
esac

Dockerfile

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,20 @@ 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+
7488
# Installing dev requirements (packages that are not in pypi)
7589
WORKDIR /src/
7690
COPY requirements.txt requirements.txt
@@ -83,16 +97,6 @@ RUN cd /src/nipype && \
8397
pip install -e .[all] && \
8498
rm -rf ~/.cache/pip
8599

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-
96100
WORKDIR /work/
97101

98102
ARG BUILD_DATE

circle.yml

Lines changed: 2 additions & 4 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/pytest $WORKDIR/logs
27+
- mkdir -p $HOME/docker $HOME/examples $WORKDIR/tests $WORKDIR/crashfiles $WORKDIR/logs ${CIRCLE_TEST_REPORTS}/tests/
2828
override:
2929
- if [[ -e $HOME/docker/cache.tar ]]; then docker load --input $HOME/docker/cache.tar; fi :
3030
timeout: 6000
@@ -50,9 +50,7 @@ test:
5050
parallel: true
5151
post:
5252
# Place reports in the appropriate folder
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
53+
- cp ${WORKDIR}/tests/*.xml ${CIRCLE_TEST_REPORTS}/tests/
5654

5755
general:
5856
artifacts:

docker/files/run_examples.sh

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

28-
# Collect crashfiles and generate xml report
28+
# Generate coverage report and submit if token is defined
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
3035
find /work -name "crash-*" -maxdepth 1 -exec mv {} ${WORKDIR}/crashfiles/ \;
3136
exit $exit_code
3237

docker/files/run_pytests.sh

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,23 @@ 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+
3135
# Workaround: run here the profiler tests in python 3
3236
if [[ "${PYTHON_VERSION}" -ge "30" ]]; then
3337
echo '[execution]' >> ${HOME}/.nipype/nipype.cfg
3438
echo 'profile_runtime = true' >> ${HOME}/.nipype/nipype.cfg
3539
export COVERAGE_FILE=${WORKDIR}/tests/.coverage.py${PYTHON_VERSION}_extra
3640
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
3741
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
3846
fi
3947

48+
# Collect crashfiles
4049
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
4450
exit ${exit_code}

0 commit comments

Comments
 (0)