Skip to content

Instantly share code, notes, and snippets.

@jsuereth
Last active December 7, 2015 14:55
Show Gist options
  • Save jsuereth/56bd6f63138f5877f9b8 to your computer and use it in GitHub Desktop.
Save jsuereth/56bd6f63138f5877f9b8 to your computer and use it in GitHub Desktop.
Travis CI caching hackeries
#!/bin/bash
# very simple script to generate a tar of dependencies in ivy cache for extraction in TravisCI.
# usage: ./.create-travis-cache.sh <sbt-command>*
#
# By Default this will run `sbt update` with a clean cache directory and
# generate a .tar.bz2 with all the artifacts. This file can be pushed into
# dropbox and expanded in your TravisCI server later for a slight improvement
# in resolution times.
STAGING_DIR="$(pwd)/sbt-zipped-home-cache"
TAR_NAME=sbt-cache.tar.bz2
# Create ivy cache of artifacts used
makeCache() {
echo "Generating ivy cache..."
sbt -d -Dsbt.boot.directory=${STAGING_DIR}/.sbt/boot -Dsbt.ivy.home=${STAGING_DIR}/.ivy2 -Divy.home=${STAGING_DIR}/.ivy2 update $@
}
# Create a new staging directory to save things.
makeTar() {
pushd $STAGING_DIR
# Now generate the TAR
echo "Generating $TAR_NAME ..."
tar -cjvf $TAR_NAME .ivy2 .sbt >/dev/null 2>&1
#Now pop, we're done.
popd
}
mkdir -p $STAGING_DIR/.ivy2
# Here we pass in optional commands to run.
makeCache "$@"
makeTar
#!/bin/bash
# WORKAROUND lack of caching in public repos:
# http://docs.travis-ci.com/user/caching/
curl -L https://www.dropbox.com/s/7v8qrukd6wmoydz/sbt-cache.tar.bz2 | tar xjf - -C $HOME
# always succeed: the cache is optional
exit 0
language: scala
install:
- bash ./.load-travis-cache.sh
.... TODO - YOUR STUFF HERE ...
@fommil
Copy link

fommil commented Aug 13, 2014

typo in language.

also to be more general, using bash directly might be better incase people forget to chmod 755

@jsuereth
Copy link
Author

@fommil thanks for the review!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment