Buck on Travis CI
Oct 1, 2017
Special thanks to Markus Spiske for his article which was my starting point for this config.
I’m growing to love Buck. I like the way it encourages you to specify builds as a graph of dependencies. I’d even argue it’ll make you a better programmer as it forces you to be explicit with your dependencies. If you create BUCK files at the package level it forces you to give greater consideration to your design as it doesn’t permit circular dependencies. All that aside I love it because it’s fast! If you want evidence of how fast I’m building an experimental build tool for Clojure. Buck runs a fresh build in under 3s from a clean checkout on my machine and an incremental build in under 400ms. I looked at Bazel (Bucks inspiration from Google) as well but found it much slower at 20s for a fresh build.
Ok I’ll assume you’re convinced to use Buck, that was the hard part… the next bit is getting it to work in CI. For my project I’m using Travis and the final config looks as follows:
dist: trusty language: java before_install: - test -f $HOME/.buck/build/successful-build || sudo apt-get update - test -f $HOME/.buck/build/successful-build || sudo apt-get install -y ant # Install Buck - test -f $HOME/.buck/build/successful-build || git clone --branch v2017.09.04.02 --depth 1 https://github.com/facebook/buck.git $HOME/.buck - ls $HOME/.buck - cd $HOME/.buck; test -f $HOME/.buck/build/successful-build || ant; cd - # build then jump back to project directory - rm -rf $HOME/.buck/.git # don't bother caching the .git folder as it'll bloat the cache - $HOME/.buck/bin/buck --version script: - $HOME/.buck/bin/buck test --all branches: except: - gh-pages cache: directories: - $HOME/.buck/ # this prevents you from having to wait for buck to build every time - buck-out/cache # this speeds tings up a bit by retaining the cache across builds
With that config the build time will vary depending on whether it’s a “clean” build or “incremental”. My last tweak to my .travis.yml resulted in a build that was done in 41s not too shabby!
The basic gist of the above config is as follows:
- Use Trusty and Java language which gives you a 1.8 series JDK.
- Install Apache Ant because that’s how buck is built (they release deb packages too).
- Shallow clone the most recent buck tag.
- Cache the buck build binaries ($HOME/.buck) and the projects buck cache (buck-out/cache) as it’ll speed up subsequent builds.
- If the build gets slow due to the cache download process purge it. The next build will be a little pokey because it needs to build buck again but subsequent builds should be grease lightning.
- Docker for Development
- Recreational GraphQL use
- Clojure Speedup - Class Prefetching
- Illustrated Guide to Clojure Start-up Timings
- Buck on Travis CI
- Joys of Java Logging
- ARC Analysis using Pandas
- » All Articles