forked from nanshe-org/nanshe
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.travis.yml
135 lines (133 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
language: generic
os: linux
dist: precise
addons:
hosts:
- travis
hostname: travis
env:
- PYTHON_VERSION="2.7" USE_GPL=false DEPLOY_DOCS=true
- PYTHON_VERSION="2.7" USE_GPL=true
- PYTHON_VERSION="3.6" USE_GPL=false
- PYTHON_VERSION="3.6" USE_GPL=true
- PYTHON_VERSION="3.7" USE_GPL=false
- PYTHON_VERSION="3.7" USE_GPL=true
before_install:
# If `$DEPLOY_DOCS` is unset, make it `false` by default.
- if [ -z $DEPLOY_DOCS ]; then DEPLOY_DOCS=false; fi
# Get the tag if it wasn't provided. Travis doesn't provide this if it isn't a tagged build.
- if [ -z $TRAVIS_TAG ]; then TRAVIS_TAG=`git tag --contains` ; fi
- echo $TRAVIS_TAG
# Move out of git directory to build root.
- cd ../..
- pwd
install:
# Download and configure conda.
- wget http://repo.continuum.io/miniconda/Miniconda`echo ${PYTHON_VERSION:0:1}`-latest-Linux-x86_64.sh -O miniconda.sh
- bash miniconda.sh -b -p $HOME/miniconda
- export PATH="$HOME/miniconda/bin:$PATH"
- conda config --set always_yes yes
- conda config --set show_channel_urls True
- conda config --add channels conda-forge
- conda config --add channels nanshe
- source activate root
- conda update --all
# Fix root environment to have the correct Python version.
- touch $HOME/miniconda/conda-meta/pinned
- echo "python ${PYTHON_VERSION}.*" >> $HOME/miniconda/conda-meta/pinned
- conda install python=$PYTHON_VERSION
# Install basic conda dependencies.
- conda install conda-build
# Build the conda package for nanshe.
- cd $TRAVIS_REPO_SLUG
- VERSION=`python setup.py --version`
- echo $VERSION
- python setup.py bdist_conda
# Setup environment for nanshe and install it with all dependencies.
- conda create --use-local -n testenv python=$PYTHON_VERSION nanshe==$VERSION
- touch $HOME/miniconda/envs/testenv/conda-meta/pinned
- conda update --use-local -n testenv --all
- conda install --use-local -n testenv nanshe==$VERSION
- source activate testenv
# Optionally install GPL dependencies.
- if [[ $USE_GPL == true ]]; then conda install --use-local -n testenv pyfftw python-spams; fi
# Install DRMAA with Python support.
- .travis_scripts/install_sge.sh
- export SGE_ROOT=/var/lib/gridengine
- export SGE_CELL=default
- export DRMAA_LIBRARY_PATH=/usr/lib/libdrmaa.so.1.0
- conda install drmaa
# Install sphinx and friends to build documentation.
- conda install sphinx
- conda install cloud_sptheme
# Install coverage and coveralls to generate and submit test coverage results for coveralls.io.
# Also, install docstring-coverage to get information about documentation coverage.
- conda install nose-timer
- conda install coverage
- if [[ $DEPLOY_DOCS == true ]]; then conda install docstring-coverage; fi
# Clean up downloads as there are quite a few and they waste space/memory.
- sudo apt-get clean
- conda clean -tipsy
- rm -rfv $HOME/.cache/pip
script:
# Run tests. Skip 3D tests as they take too long (~1hr).
- python setup.py nosetests --with-timer
# Build documentation.
- python setup.py build_sphinx
# Get info on docstring coverage.
- (hash docstring-coverage && docstring-coverage nanshe | tee .docstring-coverage) || true
after_success:
# Create deploy environment (workaround coverage Python 3.6 bug).
- conda create -n dplenv python=3.5
- source activate dplenv
# Install packages for submitting coverage results when they are needed.
- conda install python-coveralls
# Submit results to coveralls.io.
- coveralls
# Check to see if this is the right branch to build documentation from.
- if [ $TRAVIS_PULL_REQUEST != "false" ] || [ $TRAVIS_REPO_SLUG != "nanshe-org/nanshe" ] || [ $TRAVIS_BRANCH != "master" ]; then exit 0 ; fi
# Save documentation and documentation coverage statistics.
- mv build/sphinx/html ../nanshe-git-docs
- mv .docstring-coverage ../nanshe-git-docs || true
# Update credentials
- git config --global user.name "Travis CI"
- git config --global user.email "[email protected]"
# Get current pages. Unfortunately, `git fetch` does not work here.
- git remote set-url origin "https://${GH_TOKEN}@github.com/${TRAVIS_REPO_SLUG}"
- git checkout --orphan gh-pages
- git pull origin gh-pages
- git branch -v
# Save important git files.
- mv .git ../nanshe-git-docs/
- mv .nojekyll ../nanshe-git-docs/
# Replace old documentation with new documentation.
- rm -rf * .*
- mv ../nanshe-git-docs/.nojekyll .
- mv ../nanshe-git-docs/.git .
- mv ../nanshe-git-docs/.docstring-coverage . || true
- mv ../nanshe-git-docs/* .
- rm -rf ../nanshe-git-docs
# Commit changes and push. Reference commit used and tag if relevant.
- git add -A
- if [ -z $TRAVIS_TAG ]; then git commit -m "Rebuilt documentation for commit (${TRAVIS_COMMIT})." --allow-empty ; else git commit -m "Rebuilt documentation for commit (${TRAVIS_COMMIT}) and tag (${TRAVIS_TAG})." --allow-empty ; fi
- $DEPLOY_DOCS && (git push -q origin gh-pages > /dev/null 2>&1; echo $?)
# Check to see if this is a release. If so, create and upload binaries.
- if [ -z $TRAVIS_TAG ]; then exit 0 ; fi
- git checkout $TRAVIS_TAG
- source activate root
- conda install anaconda-client
- cd $HOME/miniconda/conda-bld/
- conda convert -p osx-64 linux-64/nanshe*
- conda server -t ${AS_TOKEN} upload linux-64/nanshe*
- conda server -t ${AS_TOKEN} upload osx-64/nanshe*
- "curl -H \"Content-Type: application/json\" --data '{\"docker_tag_name\": \"latest\"}' -X POST \"https://registry.hub.docker.com/u/nanshe/nanshe/trigger/${DH_TOKEN}/\""
notifications:
email:
- $TO_EMAIL
webhooks:
on_success: always
on_failure: always
urls:
- https://webhooks.gitter.im/e/70e67f941cc62174c9b2
# Use container format for TravisCI to avoid termination due to insufficient resources.
#sudo: false