forked from quantopian/zipline
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.travis.yml
118 lines (108 loc) · 5.84 KB
/
.travis.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
language: python
sudo: false
fast_finish: true
python:
- 2.7
- 3.5
env:
global:
# 1. Generated a token for travis at https://anaconda.org/quantopian/settings/access with scope api:write.
# Can also be done via anaconda CLI with
# $ TOKEN=$(anaconda auth --create --name my_travis_token)
# 2. Generated secure env var below with travis gem via
# $ travis encrypt ANACONDA_TOKEN=$TOKEN
# See https://github.com/travis-ci/travis.rb#installation.
# If authenticating travis gem with github, a github token with the following scopes
# is sufficient: ["read:org", "user:email", "repo_deployment", "repo:status", "write:repo_hook"]
# See https://docs.travis-ci.com/api#external-apis.
- secure: "iiVzfsBuKqGf4zEc7Xjf+bWBGxj6atkx0mf31JfqnqqxBesJbQVGWBcmgK82g2XJpiHKfdhNr+KxkKCtHIN9ziOHY//0xNHzCIKsXnlKG4o4fuDkrb3WpK0dU/A0hdB7oDKlyD3/sYvYrOwpAPnag0rkFG7Ck96/jIUtcH0XW2w="
- CONDA_ROOT_PYTHON_VERSION: "2.7"
matrix:
- OLD_PANDAS=1
- NEW_PANDAS=1
matrix:
exclude:
- python: 2.7
env: NEW_PANDAS=1
# include:
# # Workaround Travis OSX not natively supporting Python.
# - os: osx
# language: generic
# env: TRAVIS_PYTHON_VERSION=2.7 OLD_PANDAS=1
# - os: osx
# language: generic
# env: TRAVIS_PYTHON_VERSION=3.5 OLD_PANDAS=1
# - os: osx
# language: generic
# env: TRAVIS_PYTHON_VERSION=3.5 NEW_PANDAS=1
cache:
directories:
- $HOME/.cache/.pip/
before_install:
- source ./ci/travis/install_miniconda.sh
- |
if [ "$OLD_PANDAS" ]; then
NUMPY_VERSION=1.11.3 PANDAS_VERSION=0.18.1 SCIPY_VERSION=0.17.1
else
NUMPY_VERSION=1.14.1 PANDAS_VERSION=0.22.0 SCIPY_VERSION=1.0.0 PANDAS_DATAREADER_VERSION=0.4.0 DASK_VERSION=0.17.1
fi
- source ./ci/travis/overwrite_requirements.sh
- cat etc/requirements.txt
install:
- conda info -a
- conda install conda=4.3.30 conda-build=3.0.28 anaconda-client=1.6.3 --yes -q
- conda list
- TALIB_VERSION=$(cat ./etc/requirements_talib.txt | sed "s/TA-Lib==\(.*\)/\1/")
- CERTIFI_VERSION=$(cat ./etc/requirements.txt | grep "certifi" | sed "s/certifi==\(.*\)/\1/")
- IFS='.' read -r -a NPY_VERSION_ARR <<< "$NUMPY_VERSION"
- CONDA_NPY=${NPY_VERSION_ARR[0]}${NPY_VERSION_ARR[1]}
- CONDA_PY=$TRAVIS_PYTHON_VERSION
- if [[ "$TRAVIS_SECURE_ENV_VARS" = "true" && "$TRAVIS_BRANCH" = "master" && "$TRAVIS_PULL_REQUEST" = "false" ]]; then DO_UPLOAD="true"; else DO_UPLOAD="false"; fi
- |
for recipe in $(ls -d conda/*/ | xargs -I {} basename {}); do
if [[ "$recipe" = "zipline" ]]; then continue; fi
conda build conda/$recipe --python=$CONDA_PY --numpy=$CONDA_NPY --skip-existing --old-build-string -c quantopian -c quantopian/label/ci
RECIPE_OUTPUT=$(conda build conda/$recipe --python=$CONDA_PY --numpy=$CONDA_NPY --old-build-string --output)
if [[ -f "$RECIPE_OUTPUT" && "$DO_UPLOAD" = "true" ]]; then anaconda -t $ANACONDA_TOKEN upload "$RECIPE_OUTPUT" -u quantopian --label ci; fi
done
# Make sure stdout is in blocking mode. If we don't, then conda create will barf during downloads.
# See https://github.com/travis-ci/travis-ci/issues/4704#issuecomment-348435959 for details.
- python -c 'import os,sys,fcntl; flags = fcntl.fcntl(sys.stdout, fcntl.F_GETFL); fcntl.fcntl(sys.stdout, fcntl.F_SETFL, flags&~os.O_NONBLOCK);'
# We conda install certifi at the pinned exact version because it is a transitive dependency of zipline via requests and uses distutils for packaging.
# Since conda installs latest certifi by default, we would fail to uninstall that new version when trying to install the pinned version using pip later in the build:
# "Cannot uninstall 'certifi'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall."
- conda create -n testenv --use-local --yes -c quantopian -c quantopian/label/ci pip python=$TRAVIS_PYTHON_VERSION numpy=$NUMPY_VERSION pandas=$PANDAS_VERSION scipy=$SCIPY_VERSION ta-lib=$TALIB_VERSION libgfortran=3.0 certifi=$CERTIFI_VERSION
- source activate testenv
- CACHE_DIR="$HOME/.cache/.pip/pip_np""$CONDA_NPY"
- python -m pip install --upgrade pip==18.1 coveralls --cache-dir=$CACHE_DIR
# With this env var and CI both set, pip installing bcolz tries to compile it with coverage on py2, which fails to link against gcov on OSX.
# https://github.com/Blosc/bcolz/blob/8234a7505da5188dbaf415b7e36d4609d2c8c2f1/setup.py#L134-L136
- unset TRAVIS
- python -m pip install -r etc/requirements.txt --cache-dir=$CACHE_DIR
- TRAVIS=true # restore value
- python -m pip install -r etc/requirements_dev.txt --cache-dir=$CACHE_DIR
- python -m pip install -r etc/requirements_blaze.txt --cache-dir=$CACHE_DIR # this uses git requirements right now
- python -m pip install -r etc/requirements_talib.txt --cache-dir=$CACHE_DIR
- python -m pip install -e .[all] --cache-dir=$CACHE_DIR
before_script:
- pip freeze | sort
script:
- flake8 zipline tests
- nosetests --with-coverage
# deactive env to get access to anaconda command
- source deactivate
# unshallow the clone so the conda build can clone it.
- git fetch --unshallow --tags
- exec 3>&1; ZP_OUT=$(conda build conda/zipline --python=$CONDA_PY --numpy=$CONDA_NPY -c quantopian -c quantopian/label/ci | tee >(cat - >&3))
- ZP_OUTPUT=$(echo "$ZP_OUT" | grep "anaconda upload " | awk '{print $NF}')
- if [ -z "$ZP_OUTPUT" ]; then exit 1; fi
# test that we can conda install zipline in a new env
- conda create -n installenv --yes -q --use-local python=$TRAVIS_PYTHON_VERSION numpy=$NUMPY_VERSION zipline -c quantopian -c https://conda.anaconda.org/quantopian/label/ci
- if [[ "$DO_UPLOAD" = "true" ]]; then anaconda -t $ANACONDA_TOKEN upload $ZP_OUTPUT -u quantopian --label ci; fi
# reactivate env (necessary for coveralls)
- source activate testenv
after_success:
- coveralls
branches:
only:
- master