-
Notifications
You must be signed in to change notification settings - Fork 84
Continuous Integration
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.
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.
The simplest method for executing on the CI is:
- Install the npm dependencies (eg.
bazel run @yarn//:yarn
) - Build everything (eg.
bazel build --config=ci //...
) - 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.