Skip to content

Instantly share code, notes, and snippets.

@gfreezy
Created August 25, 2019 07:34
Show Gist options
  • Save gfreezy/52cb2afe807d59b821c82a50cd183f4b to your computer and use it in GitHub Desktop.
Save gfreezy/52cb2afe807d59b821c82a50cd183f4b to your computer and use it in GitHub Desktop.
cache brew cache in travis
cache:
directories:
- $TRAVIS_BUILD_DIR/target
# https://stackoverflow.com/questions/39930171/cache-brew-builds-with-travis-ci
- $HOME/Library/Caches/Homebrew
- /usr/local/Homebrew/
# used in OSX custom build script dealing with local bottle caching
- $HOME/local_bottle_metadata
addons:
homebrew:
update: true
packages:
- libsodium
before_install: |
if [ -n "$IS_OSX" ]; then
TAPS="$(brew --repository)/Library/Taps"
if [ -e "$TAPS/caskroom/homebrew-cask" -a -e "$TAPS/homebrew/homebrew-cask" ]; then
rm -rf "$TAPS/caskroom/homebrew-cask"
fi
find "$TAPS" -type d -name .git -exec \
bash -xec '
cd $(dirname '\''{}'\'') || echo "status: $?"
git clean -fxd || echo "status: $?"
sleep 1 || echo "status: $?"
git status || echo "status: $?"' \; || echo "status: $?"
brew_cache_cleanup
fi
before_cache: |
# Cleanup dirs to be cached
set -e; set -x
if [ -n "$IS_OSX" ]; then
# When Taps is cached, this dir causes "Error: file exists" on `brew update`
if [ -e "$(brew --repository)/Library/Taps/homebrew/homebrew-cask/homebrew-cask" ]; then
rm -rf "$(brew --repository)/Library/Taps/homebrew/homebrew-cask/homebrew-cask"
fi
brew_cache_cleanup
fi
set +x; set +e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment