Skip to content

Commit d5ce2e7

Browse files
committed
CI: Refactor Travis to separate steps more cleanly, use extras to for dependencies
1 parent 7239a36 commit d5ce2e7

File tree

1 file changed

+43
-49
lines changed

1 file changed

+43
-49
lines changed

.travis.yml

Lines changed: 43 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -13,32 +13,36 @@ cache:
1313
- $HOME/.cache/pip
1414
env:
1515
global:
16-
- DEPENDS="six numpy scipy matplotlib h5py pillow pydicom indexed_gzip"
16+
- SETUP_REQUIRES="pip setuptools>=30.3.0 wheel"
17+
- DEPENDS="numpy scipy matplotlib h5py pillow pydicom indexed_gzip"
1718
- INSTALL_TYPE="setup"
1819
- CHECK_TYPE="test"
1920
- EXTRA_WHEELS="https://5cf40426d9f06eb7461d-6fe47d9331aba7cd62fc36c7196769e4.ssl.cf2.rackcdn.com"
2021
- PRE_WHEELS="https://7933911d6844c6c53a7d-47bd50c35cd79bd838daf386af554a83.ssl.cf2.rackcdn.com"
2122
- EXTRA_PIP_FLAGS="--find-links=$EXTRA_WHEELS"
2223
- PRE_PIP_FLAGS="--pre $EXTRA_PIP_FLAGS --find-links $PRE_WHEELS"
24+
2325
python:
2426
- 3.6
2527
- 3.7
28+
2629
matrix:
2730
include:
28-
# Absolute minimum dependencies
31+
# Basic dependencies only
32+
- python: 3.5
33+
env:
34+
- DEPENDS="-r requirements.txt"
35+
# Clean install
2936
- python: 3.5
3037
env:
31-
- DEPENDS="-r min-requirements.txt setuptools==30.3.0"
38+
- DEPENDS=""
39+
- CHECK_TYPE=skiptests
3240
# Absolute minimum dependencies
3341
- python: 3.5
3442
env:
43+
- SETUP_REQUIRES="setuptools==30.3.0"
3544
- DEPENDS="-r min-requirements.txt"
36-
- CHECK_TYPE="import"
3745
# Absolute minimum dependencies plus oldest MPL
38-
# Check these against:
39-
# nibabel/info.py
40-
# doc/source/installation.rst
41-
# requirements.txt
4246
- python: 3.5
4347
env:
4448
- DEPENDS="-r min-requirements.txt matplotlib==1.3.1"
@@ -60,9 +64,6 @@ matrix:
6064
- python: 3.5
6165
env:
6266
- INSTALL_TYPE=wheel
63-
- python: 3.5
64-
env:
65-
- INSTALL_TYPE=requirements
6667
- python: 3.5
6768
env:
6869
- INSTALL_TYPE=archive
@@ -72,60 +73,55 @@ matrix:
7273
# Documentation doctests
7374
- python: 3.5
7475
env:
75-
- CHECK_TYPE="doc_doctests"
76+
- CHECK_TYPE="doc"
7677

78+
# Set up virtual environment, build package, build from depends
7779
before_install:
78-
- travis_retry python -m pip install --upgrade pip
79-
- travis_retry pip install --upgrade virtualenv
80+
- travis_retry python -m pip install --upgrade pip virtualenv
8081
- virtualenv --python=python venv
8182
- source venv/bin/activate
8283
- python --version # just to check
83-
- travis_retry pip install -U pip setuptools>=27.0 wheel
84-
- travis_retry pip install coverage
85-
- if [ "${CHECK_TYPE}" == "test" ]; then
86-
travis_retry pip install nose mock;
87-
fi
88-
- if [ "${CHECK_TYPE}" == "style" ]; then
89-
travis_retry pip install flake8;
84+
- travis_retry pip install -U $SETUP_REQUIRES
85+
- |
86+
if [ "$INSTALL_TYPE" == "sdist" ]; then
87+
python setup.py egg_info # check egg_info while we're here
88+
python setup.py sdist
89+
export ARCHIVE=$( ls dist/*.tar.gz )
90+
elif [ "$INSTALL_TYPE" == "wheel" ]; then
91+
python setup.py bdist_wheel
92+
export ARCHIVE=$( ls dist/*.whl )
93+
elif [ "$INSTALL_TYPE" == "archive" ]; then
94+
export ARCHIVE="package.tar.gz"
95+
git archive -o $ARCHIVE HEAD
9096
fi
91-
- travis_retry pip install $EXTRA_PIP_FLAGS $DEPENDS
97+
- if [ -n "$DEPENDS" ]; then pip install $EXTRA_PIP_FLAGS $DEPENDS; fi
9298

9399
# command to install dependencies
94100
install:
95101
- |
96102
if [ "$INSTALL_TYPE" == "setup" ]; then
97103
python setup.py install
98-
elif [ "$INSTALL_TYPE" == "sdist" ]; then
99-
python setup_egg.py egg_info # check egg_info while we're here
100-
python setup_egg.py sdist
101-
pip install $EXTRA_PIP_FLAGS dist/*.tar.gz
102-
elif [ "$INSTALL_TYPE" == "wheel" ]; then
103-
python setup_egg.py bdist_wheel
104-
pip install $EXTRA_PIP_FLAGS dist/*.whl
105-
elif [ "$INSTALL_TYPE" == "requirements" ]; then
106-
pip install $EXTRA_PIP_FLAGS -r requirements.txt
107-
python setup.py install
108-
elif [ "$INSTALL_TYPE" == "archive" ]; then
109-
git archive -o package.tar.gz HEAD
110-
pip install $EXTRA_PIP_FLAGS package.tar.gz
104+
else
105+
pip install $EXTRA_PIP_FLAGS $ARCHIVE
111106
fi
107+
# Basic import check
108+
- python -c 'import nibabel; print(nibabel.__version__)'
109+
- if [ "$CHECK_TYPE" == "skiptests" ]; then exit 0; fi
110+
111+
before_script:
112112
# Point to nibabel data directory
113113
- export NIBABEL_DATA_DIR="$PWD/nibabel-data"
114+
# Because nibabel is already installed, will just look up the extra
115+
- pip install $EXTRA_PIP_FLAGS "nibabel[$CHECK_TYPE]"
116+
114117
# command to run tests, e.g. python setup.py test
115118
script:
116119
- |
117120
if [ "${CHECK_TYPE}" == "style" ]; then
118121
# Run styles only on core nibabel code.
119122
flake8 nibabel
120-
elif [ "${CHECK_TYPE}" == "import" ]; then
121-
# Import nibabel without attempting to test
122-
# Allows us to check missing dependencies masked by testing libraries
123-
printf 'import nibabel\nprint(nibabel.__version__)\n' > import_only.py
124-
cat import_only.py
125-
coverage run import_only.py
126-
elif [ "${CHECK_TYPE}" == "doc_doctests" ]; then
123+
elif [ "${CHECK_TYPE}" == "doc" ]; then
127124
cd doc
128-
pip install -r ../doc-requirements.txt
129125
make html;
130126
make doctest;
131127
elif [ "${CHECK_TYPE}" == "test" ]; then
@@ -137,12 +133,10 @@ script:
137133
else
138134
false
139135
fi
140-
after_success:
141-
- |
142-
if [ "${CHECK_TYPE}" == "test" ]; then
143-
travis_retry pip install codecov
144-
codecov
145-
fi
136+
137+
after_script:
138+
- travis_retry pip install codecov
139+
- codecov
146140

147141
notifications:
148142
webhooks: http://nipy.bic.berkeley.edu:54856/travis

0 commit comments

Comments
 (0)