Skip to content

Commit

Permalink
Add cache of conda installation to Travis
Browse files Browse the repository at this point in the history
  • Loading branch information
abravalheri committed Jun 15, 2018
1 parent ff3bb60 commit 2d855f8
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@ script:
- tox
after_success:
- if [[ "$COVERAGE" == "true" ]]; then coveralls || echo "failed"; fi
after_script:
- travis-cleanup
cache:
apt: true
pip: true
directories:
- $HOME/.cache/pip
- $HOME/miniconda
32 changes: 26 additions & 6 deletions tests/travis_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,25 @@
#
# THIS SCRIPT IS SUPPOSED TO BE AN EXAMPLE. MODIFY IT ACCORDING TO YOUR NEEDS!

set -e
set -e -x # Exit on errors and debug mode

if [[ "$DISTRIB" == "conda" ]]; then
# Deactivate the travis-provided virtual environment and setup a
# conda-based environment instead
deactivate

# Use the miniconda installer for faster download / install of conda
# itself
wget http://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh \
-O miniconda.sh
chmod +x miniconda.sh && ./miniconda.sh -b -p $HOME/miniconda
if [[ -f "$HOME/miniconda/bin" ]]; then
echo "Skip install conda"
else
rm -rf "$HOME/miniconda"
# ^ Caching creates empty dir that conflicts with conda installer

# Use the miniconda installer for faster download / install of conda
# itself
wget http://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh \
-O miniconda.sh
chmod +x miniconda.sh && ./miniconda.sh -b -p $HOME/miniconda
fi
export PATH=$HOME/miniconda/bin:$PATH
conda update --yes conda

Expand All @@ -33,7 +40,20 @@ fi
if [[ "$COVERAGE" == "true" ]]; then
pip install coverage coveralls
fi

# for all
pip install -U pip setuptools
pip install sphinx
pip install tox

travis-cleanup() {
printf "Cleaning up environments ... " # printf avoids new lines
if [[ "$DISTRIB" == "conda" ]]; then
# Force the env to be recreated next time, for build consistency
source deactivate
conda remove -n testenv --all --yes
fi
echo "DONE"
}

set +x

0 comments on commit 2d855f8

Please sign in to comment.