Using Bazel with Travis-CI

508 views
Skip to first unread message

Uriel Corfa

unread,
Sep 10, 2015, 11:20:03 AM9/10/15
to bazel-...@googlegroups.com
Hi all,

I've been using Bazel with Travis-CI for a while now. With the Beta release, this became finally usable (previously my only option was to compile Bazel during each Travis build, which took a very long time).

Here's a demo of how I make it work: https://github.com/korfuri/bazel-travis

The dummy example takes about 30 to 40s to install all dependencies, install Bazel, start Bazel, compile and run a "int main(){ return 0; }" dummy unittest. Of course since Travis doesn't keep any state between runs, all sources have to be entirely rebuilt from one run to another, so your compile/test time will depend on your entire codebase's size, not just on the changes in the commit being tested.

Feedback and PRs very welcome :)
Cheers,
Uriel

Damien Martin-guillerez

unread,
Sep 10, 2015, 11:28:40 AM9/10/15
to Uriel Corfa, bazel-...@googlegroups.com
Thanks Uriel :)

Note that there is scripts/ci/ci.sh to recompile only the target that depends on a git changeset if you want to reduce the number of target built.

--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/CADGrcx7ofJCcjF0Z_yo_Rnoubbi1%3DjmBQZ%3DDYLoLQzyqt-zEDw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Uriel Corfa

unread,
Sep 10, 2015, 11:30:16 AM9/10/15
to Damien Martin-guillerez, bazel-...@googlegroups.com
Oooh, neat. I'll integrate with that soon.

Jeff Cox

unread,
Sep 10, 2015, 11:53:01 AM9/10/15
to Uriel Corfa, Damien Martin-guillerez, bazel-...@googlegroups.com
Is there no way for Travis to keep the Bazel server alive across runs?

Damien Martin-guillerez

unread,
Sep 10, 2015, 12:00:23 PM9/10/15
to Jeff Cox, Uriel Corfa, bazel-...@googlegroups.com
No, their spawning a new container / vm for each build. You have to use GCE for keeping the server alive.

Damien Martin-guillerez

unread,
Sep 10, 2015, 12:12:21 PM9/10/15
to Jeff Cox, Uriel Corfa, bazel-...@googlegroups.com
*they are spawning* sorry

Thomas Broyer

unread,
Sep 10, 2015, 12:22:53 PM9/10/15
to bazel-discuss


On Thursday, September 10, 2015 at 5:20:03 PM UTC+2, Uriel Corfa wrote:
Of course since Travis doesn't keep any state between runs,

Can't you cache some dirs? http://docs.travis-ci.com/user/caching/

Maybe at least cache the bazel installer and only download it if absent? But possibly also cache the Bazel installation, and bazel build output/state (for incremental builds; see however the other thread re. CircleCI).

Damien Martin-guillerez

unread,
Sep 10, 2015, 1:24:19 PM9/10/15
to Thomas Broyer, bazel-discuss
The output base is configurable but that generally don't work well across containers.

--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discus...@googlegroups.com.

Dino Wernli

unread,
Jun 26, 2016, 7:02:24 AM6/26/16
to bazel-discuss, t.br...@gmail.com
For what it's worth, I've just gone through the exercise of adding Travis support to java-grpc-prometheus, one of my Bazel-powered projects. Here is a .travis.yml that currently works for me.

michal.w....@gmail.com

unread,
Oct 16, 2016, 12:13:39 PM10/16/16
to bazel-discuss, t.br...@gmail.com
FYI I had success getting --output_base to work with Travis CI caching:

https://travis-ci.org/mwitkow/java-flagz/builds/168066991
here's the travis.yml: https://github.com/mwitkow/java-flagz/blob/feature/bazelify/.travis.yml

Reply all
Reply to author
Forward
0 new messages