Skip to main content
Version: 5.9.x

Building

By default, the test task will also build all build-able targets, so a typical configuration file does not use the build task.

There are a few cases where a build task can be useful:

  1. When the --build_tests_only flag is passed to Bazel, then the test task will not build targets which aren't a dependency of any tests.
  2. Some test targets may be known to be broken. A build task can be used to only build the tests, but not run them.

A simple configuration looks like:

.aspect/workflows/config.yaml
tasks:
- build:

Building specific targets

By default, Workflows builds all targets in the workspace, by running bazel build //.... Specific targets may be selected with the targets attribute:

.aspect/workflows/config.yaml
tasks:
- build:
targets:
# All targets in project A
- //projectA/...
# But excluding this subpackage
- -//projectA/excluded:all

Specifying flags

We recommend that flags typically be checked into a .bazelrc file. Workflows looks for a .aspect/workflows/bazelrc file, and if it exists then Workflows will pass --bazelrc=.aspect/workflows/bazelrc to every invocation of Bazel.

Flags can also be placed in the configuration file. They may go at the top-level and also under a task:

.aspect/workflows/config.yaml
bazel:
flags:
# Allow any actions to see the value of $HOME
- --action_env=HOME
tasks:
- test:
bazel:
flags:
# Allow tests to fetch private container images from Docker Hub
- --test_env=DOCKER_USERNAME
- --test_env=DOCKER_PASSWORD

API Doc

The exhaustive list of attributes for the build task are found at build.