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 theci preset. It can create, use and delete sandboxes. Then store it as a repository secret:
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:ci-base: a save with the same name replaces it. See Named snapshots.
3. The workflow
.github/workflows/boat-tests.yml
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:
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_limitedand the window (minute,hourorday). 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-fasttoboat new. Retry the job later.
Cost
Boat bills each second that the sandbox runs. Asmall 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:
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.