Builders

Building Plans

A builder is a component that takes a plan source code, and optionally the SDK's source code, and compiles it into a build artifact, ready to be used by compatible Runners to schedule test workloads on Testground.

The build process is different depending on the language of the plan, and the kind of build artifact being targeted. Here's a simple diagram to understand how builders and runners relate to one another.


-------------    -----------    ------------------    ----------    ---------------
| plan code | -> | builder | -> | build artifact | -> | runner | -> | test output |
-------------    -----------    ------------------    ----------    ---------------

Supported builders

Builder names follow the format: <build artifact type>:<language>

Builder configuration options

The builders accept options on the command-line which can customize their behaviour. Each builder has a different set of configurable options. This section lists the configuration options supported by each.

Builder configuration options can be provided by various means, in the following order of precedence (highest precedence to lowest precedence):

  1. CLI --build-cfg flags for single commands, and in the composition file for composition commands.

  2. .env.toml: [builders] section.

  3. Test plan manifest.

  4. Builder defaults (applied by the runner).

exec:go builder

The exec:go builder uses the machine's own Go installation to compile and build a binary. Below are the options this builder supports. None of these are required and need only be edited if the defaults do not work well in your environment.‌

docker:go builder

The docker:go builder uses the user's local Docker daemon to construct a Docker image. By default, the docker:go builder will leverage a goproxy container to speed up fetching of Go modules. Additionally, all builds are performed on an isolated Docker network.‌

None of these options are required and need only be edited if the defaults do not work well in your environment.‌

Examples

Single build for a single test for the example/output plan using the exec:go builder. This command will produce a binary which you can find in ~/testground/ on Linux and macOS systems.

$ testground build single --plan=example --builder=exec:go

Same, using the docker:go builder. This command will produce a Docker image.

$ testground build single --plan=example --builder=docker:go

Use the docker:go builder to build an image and then push the image to DockerHub (configure credentials in env.toml file).

$ testground build single --plan=example --builder=docker:go \
                                         --build-cfg push_registry=true \
                                         --build-cfg registry_type=dockerhub

Build a composition defined in barrier-local.toml. Note that the composition file will contain the builder and runner so specifying the builder on the command-line is not used in this example.

$ testground build composition --file=compositions/barrier-local.toml \
                               --write-artifacts

Last updated