Skip to content

Commit

Permalink
Cache homebrew
Browse files Browse the repository at this point in the history
Downloaded files are stored in $HOME/Library/Caches/Homebrew, however
the size of this directory is too large to cache on Travis-CI.
Cache only newly downloaded files.
  • Loading branch information
k-takata committed Jul 11, 2017
1 parent 4d765fd commit e67066d
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,16 @@ cache:
directories:
- $HOME/opt

env:
global:
- OPT=$HOME/opt
- CACHE=$OPT/cache
- BREWCACHE=$HOME/Library/Caches/Homebrew

matrix:
include:
- os: linux
env: VIM=vim OPT=$HOME/opt VIMPROG=$OPT/bin/$VIM
env: VIM=vim VIMPROG=$OPT/bin/$VIM
- os: linux
env: VIM=nvim VIMPROG=$VIM
- os: osx
Expand Down Expand Up @@ -40,9 +46,21 @@ install: |
eval "$(curl -Ss https://raw.githubusercontent.com/neovim/bot-ci/master/scripts/travis-setup.sh) nightly-x64"
fi
elif [ "$TRAVIS_OS_NAME" = "osx" ]; then
if [ -d $CACHE ]; then
if [ "$(echo $CACHE/*)" != "$CACHE/*" ]; then
cp $CACHE/* $BREWCACHE
fi
else
mkdir $CACHE -p
fi
(cd $BREWCACHE; ls > $HOME/list1.txt)
brew update
brew upgrade
#brew upgrade
brew install $PACKAGE
brew cleanup -s
(cd $BREWCACHE; ls > $HOME/list2.txt)
comm -1 -3 $HOME/list1.txt $HOME/list2.txt | (cd $BREWCACHE; xargs -I{} cp {} $CACHE)
comm -2 -3 $HOME/list1.txt $HOME/list2.txt | (cd $CACHE; xargs rm -rf)
$VIM --version
fi
Expand Down

0 comments on commit e67066d

Please sign in to comment.