Skip to main content
Each CI job creates one sandbox, runs the tests in it, and deletes it. boat exec exits with the exit code of the tests, so the job fails when the tests fail.

1. Create a CI key and a secret

Create a key with the ci preset. It can create, use and delete sandboxes. Then store it as a repository secret:
The key expires after 90 days. Rotate it with boat api-key rotate <id>. See API keys.

2. Prepare a named snapshot (one time)

Install your toolchain and dependencies once. Save the result as a named snapshot. Each CI sandbox then starts with them in place:
A named snapshot keeps only the Docker images that a container uses. A plain docker pull is lost. Create a container from each image that you need, as above: docker create --name keep-<x> <image>. The container does not need to run. Boat pulls registry images again at each start, so a large image adds start time. See What a snapshot saves.
10 named snapshots are free. Run the same steps again to update ci-base: a save with the same name replaces it. See Named snapshots.

3. The workflow

.github/workflows/boat-tests.yml
What each part does: Use the sandbox ID in every command. The current alias does not work in CI: each step runs in a new shell.

Tests that run longer than 10 minutes

A command that waits for its result stops after 600 seconds. Run a longer suite detached, then follow it. --attach exits with the exit code of the command:
See Background commands.

Many jobs at once: start limits

Each job starts one sandbox. Create, fork and resume each count as a start.
  • A start above the limit fails with rate_limited and the window (minute, hour or day). It does not count as a start.
  • A matrix of 30 jobs on the $20 plan needs about 3 minutes to start all sandboxes. Cap it with strategy.max-parallel: 12.
  • To fail at once when no machine is free, add --fail-fast to boat new. Retry the job later.
All limits and how to raise them: Limits.

Cost

Boat bills each second that the sandbox runs. A small sandbox costs $0.018 an hour. A 6-minute run costs about $0.002. A deleted sandbox costs nothing more. See Pricing.

Private repositories and secrets

The workflow copies the checked-out code, so the sandbox needs no GitHub access. To give the tests secrets, set them on an environment and start with --environment <name>, or pass one value with -e KEY=VALUE. Check that a value arrived:
An environment that is safe for third parties withholds all your secrets. See Secrets.

Other CI systems

The steps are the same in GitLab CI, CircleCI or Buildkite: download the binary, sign in with --key-stdin, boat new --json, boat exec, and boat delete --yes in a step that always runs. In code, use the Python or TypeScript SDK instead.