In 2019, github has made it incredibly easy to run continuous integration (CI) on public repositories, using Github Actions.
Thanks to a simple
.yml configuration file, any open-source project can be enhanced with a very
capable, Github-hosted, CI server.
Lately I have been working a lot with Bazel, to ensure that my projects can obtain fully reproducible binaries across different platforms.
Let’s add some CI testing to one of these project!
Testing this particular project is very simple. We just need to make sure that the command
bazel build //project completes successfully on our CI servers.
bazel has many different versions and some are incompatible with others. We could provision the CI server to be provisioned with the right version, but that would be tedious.
Lucky for us,
bazelisk is exactly what we need. Not only it comes pre-installed on every Github Actions container, but it can also check our project for a
.bazelversion file and use the right version of Bazel automatically!
Say that our project used Bazel version 3.1.0, we would just add the following
Now for the meat of the project. We want to run the following command on our CI servers:
bazelisk build //project
And we want it to work across different operating systems too!
Traditionally we would have had to spin up different virtual machines, and provision them… A project in and of itself.
But wait! Github Actions provides an amazingly simple solution that allow us to run a multi platform command like
bazelisk on different operating systems by using its
Let’s add this
build.yml to our
And we are done! Pretty incredible huh?
Using Github Actions is a simple and intuitive way of adding CI to any open source project. Definitely worth trying when working with Bazel!