Getting Started with Buck build on Travis
817 reads

Getting Started with Buck build on Travis CI

Read on Terminal Reader

Too Long; Didn't Read

Companies Mentioned

Mention Thumbnail
Mention Thumbnail
featured image - Getting Started with Buck build on Travis CI
Buckaroo - C/C++ Package Manager HackerNoon profile picture

Buckaroo - C/C++ Package Manager
react to story with heart

Travis CI is a service that offers free build servers for open-source projects (thanks, VCs!). It has tight integration with GitHub, allowing you to automatically build and test code in a pull request before merging. This is great for projects with multiple contributors, because you can run tests without checking-out the code yourself.

But how do you integrate a Buck based project with Travis CI?

To follow this guide you will need the following:


Grab the relevant files from the example repo on GitHub.

Create a .travis.yml File

At the heart of a Travis project is the .travis.yml file. This is a YAML file that defines the build steps and build environment for your project. The most important property is script, which is the list of Bash commands.

For example:


Run on Ubuntu “Trusty”

Install Build Dependencies

Buck is not packaged with any of the Travis system images, so we will need to add an installation step to the Travis file. Installation steps live under the before_install element.

The easiest way to get Buck running on Linux is via Linuxbrew, the Linux port of Homebrew. Like Homebrew, Linuxbrew allows us to easily install packages in userland, and it is mostly package-compatibile.


This snippet runs before the project is built. First, it installs Linuxbrew, then it uses Linuxbrew to install Buck.

You might have noticed that we did not use the provided Linuxbrew install script. This is because it is best to keep everything in the home folder, which ensures that the Travis user has read and write access.

Once we have Buck installed, the script portion of .travis.yml can call Buck:


Pulling everything together, we have the following:


Add this file to the root of your project, and be sure to change the buck build command to point to the correct Buck target!

Connect Travis CI to GitHub

Once the Travis file is in place, you need to connect Travis CI to your GitHub project. Create an account on Travis CI, then flick the switch on the project you want to integrate.


Travis will now be integrated with your project, and it will start building master. You will also notice useful notifications appear in your pull requests!

Accelerating the Build

The build will take a while because it has to install all of the dependencies each time! We can improve this massively by taking advantage of Travis CI’s cache feature.

Travis CI allows you to mark a directory as cached, which means it gets re-used between builds. Since we installed Linuxbrew in userland, we can just cache the whole ~/.linuxbrew directory. On subsequent builds, Linuxbrew will detect that our dependencies are already installed and skip the installation step.


We also need to make sure that we do not git clone Linuxbrew twice:


Pulling everything together gives us the finished Travis file:



And that’s it! The full Travis file should be enough to get started, or you can grab the relevant files from the example repo on GitHub.


. . . comments & more!
Hackernoon hq - po box 2206, edwards, colorado 81632, usa