Skip to content
This repository has been archived by the owner on Mar 20, 2024. It is now read-only.

Continuous Integration

Alex Eagle edited this page Dec 15, 2017 · 1 revision

Continuous Integration is the only way to know whether your code works. We highly encourage you to set this up with the first commit on your project.

Setting up Bazel on CI

We recommend you run your build within the https://hub.docker.com/r/angular/ngcontainer/ Docker image. This gives you a pre-built environment with all the things you might need, and avoids having to wait for the CI to install toolchains before the build can start. It also make the build reproducible elsewhere, like on your local machine.

This is especially convenient on CircleCI, which lets you choose a docker image as the environment for your build. See the CircleCI configuration for this repository for a working example and explanation.

We recommend adding settings to your bazel.rc file that are specifically for CI, by using the build:ci or test:ci prefix on a line. See the example in this repo. Then when running bazel commands in your CI setup, add the --config=ci argument to enable these options.

Build and Test all the things!

The simplest method for executing on the CI is:

  1. Install the npm dependencies (eg. bazel run @yarn//:yarn)
  2. Build everything (eg. bazel build --config=ci //...)
  3. Run all the tests (eg. bazel test --config=ci //...)

This is fine, but it misses some parallelization opportunities, as the first unit test can't start executing until you've built all your slowest artifacts, like the docker image for your backend.

A fancier approach is bazel query //... | xargs bazel test though this can run into command line argv limits in your OS. See https://github.com/bazelbuild/bazel/issues/4257 for more discussion.