The trawler-ci command
trawler-ci starts a Trawler run for a pull request, waits for it, comments the result and sets the job’s exit code. It is a thin client of the Run API: it holds no logic about your product, and everything it asks for is in the run’s report.
It lives in apps/ci of the public repository, under Apache-2.0. It is not published as a package yet: check Trawler out in the job and run it from the checkout. It needs Node.js 24 or later and npm ci at the root of the checkout, and has no build step.
node apps/ci/src/main.ts run --project <uuid> [options]The rest of the documentation calls this command trawler-ci. node apps/ci/src/main.ts --help, or -h or help, prints the usage and exits with 0.
What it does
Section titled “What it does”- Reads the
--accountsfile, if there is one. - Looks for a CI system. On GitHub Actions it reads the pull request from the event that started the job; elsewhere there is none. With a pull request it reads the description of the CI setup, if there is one.
- Starts the run with
POST /api/v1/runs, and prints the run’s number and report address. When Trawler cannot start a run yet, it waits and tries again; see When a run cannot start yet. - With
--runner own, starts the runner that carries the run out inside the job: one, or with--conversationone for each person. Each takes the jobs of this run only. - Asks for the run’s state every 5 seconds until it has ended, or until
--timeout-minutesruns out. - Prints the result’s Markdown and, on GitHub, writes it to the job summary and posts it on the pull request.
- Stops the run if it has not ended, stops the runners and exits with the code below.
Options
Section titled “Options”| Option | Default | |
|---|---|---|
--project <uuid> |
required | The project to test: the UUID in its address in the app. |
--api <url> |
TRAWLER_API |
The address of the app, such as https://app.usetrawler.com. An http address is accepted only for localhost, 127.0.0.1 and [::1], because the token is sent there. |
--plan <uuid> |
the project’s first plan | The plan to run, the UUID after plan= in the plan page’s address. |
--runner hosted|own |
hosted |
Who carries the run out. See Two ways to run. |
--url <address> |
the project’s address | Test this address instead. An http or https address, and only with --runner own; the app refuses it for a hosted run. |
--accounts <file> |
none | A JSON file of accounts for people, only with --runner own. See Accounts from the CI job. |
--allow-origin <address> |
none | Let the people also open this origin, next to the app at --url: a service in the job such as a mail inbox, http://localhost:8025. Up to 5 times; only with --runner own and --url. See The address under test. |
--environment <file> |
.github/trawler/environment.md |
A description of how the app runs in the job and what it does not have, up to 4,000 characters. See Describing the CI setup. Used only when there is a pull request and --plan-mode is not regression. |
--cap <usd> |
$2 | The hard cap, from 0.1 to 50, in plain decimal such as 3 or 2.5. |
--model <id> |
by the workspace’s key | The model for the run. Left out, the first model Trawler suggests for the provider of the key. |
--conversation |
off | Let the people work at the same time and talk. See People who talk during a run. |
--fail-on new-confirmed|any-confirmed|never |
new-confirmed |
When a run fails the job. See Exit codes. |
--plan-mode regression|change|both |
change |
How the run uses the pull request: change plays only the plan Trawler makes for it, regression only the project’s plan, both the two together. See Plans for pull requests. Used only when there is a pull request. |
--replan |
off | Plan the pull request again even if its title, description, changed files and setup description are as when its plan was made. |
--timeout-minutes <n> |
45 |
How long to wait for the run, as a number above 0. When it runs out, the command stops the run. |
--no-comment |
off | Do not comment on the pull request. The job summary is still written. |
Environment variables
Section titled “Environment variables”| Variable | |
|---|---|
TRAWLER_API_TOKEN |
Required. A workspace API token. It is sent only to --api, and shown as *** in the command’s error messages and the runner’s output. |
TRAWLER_API |
The default for --api. One of the two is required. |
GITHUB_TOKEN |
On GitHub Actions, lets the command comment on the pull request and read its changed files. The job needs pull-requests: write to comment. |
On GitHub Actions the command also reads the variables the platform sets: GITHUB_ACTIONS, GITHUB_EVENT_PATH, GITHUB_REPOSITORY, GITHUB_SHA, GITHUB_API_URL — for GitHub Enterprise Server — and GITHUB_STEP_SUMMARY. It sets TRAWLER_ACCOUNTS_FILE, TRAWLER_RUNNER_TOKEN and TRAWLER_RUN_ID for the runner it starts; they are not yours to set.
What it prints
Section titled “What it prints”Progress and warnings go to standard error, and only the result goes to standard output.
Trawler run #17 started (github, pull request #42)Report: https://app.usetrawler.com/runs/0017Run #17: queued, 0/9 goals reached, 0 confirmed defect(s)Run #17: running, 2/9 goals reached, 0 confirmed defect(s)Run #17: succeeded, 8/9 goals reached, 1 confirmed defect(s)A progress line is printed whenever it changes. Lines of the runner carry [runner]. The result’s Markdown, the pull request comment, follows on standard output, then a line on standard error that says what it decided, such as Run #17 confirmed 1 defect(s) (–fail-on new-confirmed). Report: https://app.usetrawler.com/runs/0017
While waiting, a call that fails because of the network, a 408, a 429 or a 5xx is tried again after a growing pause, 10 seconds at first and a minute at most, and the command prints warning: polling failed (…); retrying. After 15 failures in a row it gives up with error: … and exit code 1. Any other answer, such as a revoked token, ends the command at once.
When a run cannot start yet
Section titled “When a run cannot start yet”Some refusals of the Run API pass with time, so trawler-ci waits and starts again instead of failing the job:
- A run is going on the project (
409, Run 0007 is still going on this project. …), for instance one started from the app. - The workspace has 5 runs going in CI jobs (
429, This workspace already has 5 runs going in CI jobs, …), or the token made too many calls in a minute.
The pause starts at 10 seconds and doubles to a minute, and each retry prints Trawler cannot start a run yet (…) Retry 1 in 10s. After 10 minutes of waiting it gives up with Trawler could not start a run within 10 minutes: … and This is not caused by the pull request, so the job does not fail. A newer push to the same pull request does not add to either count: it stops its earlier run, see Newer pushes and other pull requests.
When the workspace’s model key is the problem — Trawler refused it, the key cannot use the model, the provider could not be reached, no key was added, or the first run on Trawler is used — the command does not fail the job either. It prints Trawler did not test this change: and the refusal, then This is not a problem with the pull request, so the job does not fail., writes the same under Trawler did not test this change in the job summary, posts no comment and exits with 0.
Any other refusal fails the job with error: HTTP …, see What it refuses.
Exit codes
Section titled “Exit codes”| Code | When |
|---|---|
0 |
The job passes: the run ended Complete with no confirmed defect; or with --fail-on never; or the run ended some other way, as below; or the wait ran out; or no run could be started, as above. |
1 |
The run ended Complete and confirmed at least one defect; or something went wrong: the app refused the call, the token was refused, the network gave up, or the runner stopped before the run finished. The message starts with error:. |
2 |
A mistake in how the command was called: an option that is missing, unknown or invalid, or an --accounts file that cannot be used. The message is followed by the usage. |
130, 143 |
The job was interrupted by SIGINT or SIGTERM. The run and the runners are stopped first. |
--fail-on new-confirmed and --fail-on any-confirmed both fail the job on any confirmed defect: Trawler keeps no baseline to compare a run with an earlier one yet.
Only a run that ended Complete passes or fails the job. A run that was Stopped at cap, Stopped or Failed leaves the job passing, even if it had confirmed defects before it stopped, and the command prints Run #17 ended as cancelled before it could finish, so it does not pass or fail the job (1 confirmed so far). Report: …, or ended as failed for a failed run.
A run that a newer push stopped prints Run #17 was stopped because a newer push to this pull request started another run, so it does not pass or fail the job. with the report’s address, posts no comment and writes no job summary; the comment is the newer run’s. A run that was skipped because nothing in the change can be tested through the product’s UI prints Run #17 was skipped: nothing in this change can be tested through the product’s UI, so it does not pass or fail the job., posts the comment that says so and exits with 0: see When nothing can be tested.
A run that reached fewer than half of its goals and confirmed nothing is not called clean in the comment, but it passes the job like any run that confirmed nothing: see The variants.
A run that was Stopped at cap is never reported as clean. The command prints Run #17 ran out of its budget before it finished testing, so it does not pass or fail the job and is not a clean result (1 confirmed, 2 reported defect(s) not replayed or judged). Report: …, and the comment says the same, see The variants. The exit code is 0: raise --cap and run again to get an answer.
A run whose lead could not plan for the pull request, or did not answer in time, ran the project’s plan instead and is not a clean result for the change either. While waiting, the command prints warning: and the lead’s note once. When nothing was confirmed it prints Run #17 is not a clean result for this change, so it does not pass or fail the job., the note and the report’s address, and exits 0. Confirmed defects still fail the job, with the note after the message.
Stopping the run
Section titled “Stopping the run”The command stops the run it started, so that a job that gives up does not leave it going. It calls POST /api/v1/runs/<id>/stop of the Run API and prints Run #17 stopped (…). when the run was still going, in three cases:
- The wait ran out. When the run is still going after
--timeout-minutes, the command stops it, prints Run #17 did not finish within 45 minutes, so it was stopped and does not pass or fail the job. Report: … and exits with0. It posts no comment. - The job is interrupted. On
SIGINTorSIGTERMit stops the run and the runners, and exits with130or143. - The command leaves before the run ended, for example because a runner exited or the app could not be reached for good: it stops the run on its way out, best effort.
The stop is a call with a 5-second limit. When it fails, the command prints warning: could not stop run #17: …. Stop it from <the report's address> and goes on; open the run and choose Stop run. What the run found so far stays, and its page says Stopped from CI: the job timed out, was cancelled or was interrupted before the run finished. A job killed so hard that the command never runs again, with SIGKILL or the machine lost, stops nothing itself, but Trawler notices that nobody asks about the run any more and stops it: see If the job ends early.
On GitHub
Section titled “On GitHub”When GITHUB_ACTIONS is true, the command knows it is on GitHub Actions.
- The pull request. From the job’s event it takes the pull request’s number, title, description, base and head branches, address, the commit and the repository. A job started by something other than a pull request, such as a push, still passes the repository and the commit, but has no pull request number: it gets no comment and no plan of its own.
- Its details. Unless
--plan-modeisregression, the command also asks GitHub for the pull request’s changed files, up to 200, and, if the event carried no title, its title and description. It needsGITHUB_TOKENfor that. If it cannot read them it printswarning: could not read the pull request's details, so the run plans without them: …and goes on. The description is cut to 4,000 characters, the title to 300. - The comment. With
GITHUB_TOKENand a pull request number, the command posts the Markdown as a comment on the pull request, or updates the one it posted before. See The pull request comment. It prints Pull request comment created. or …updated.; and, without the token, a number or a pull request, No pull request comment posted (needs GITHUB_TOKEN and a pull request); see the job summary. A comment that GitHub refuses, for lack ofpull-requests: write, say, only printswarning: could not post the pull request comment: …: it never changes the exit code. - The job summary. The Markdown is appended to the file
GITHUB_STEP_SUMMARYnames, so the run’s result shows on the job’s page. It is written whether or not a comment is posted; a failure printswarning: could not write the job summary: ….
A workflow that GitHub starts for a pull request from a fork gets no secrets, so TRAWLER_API_TOKEN is empty and the command stops with exit code 2 and TRAWLER_API_TOKEN is not set. Its GITHUB_TOKEN is read-only. See GitHub Actions.
In other CI systems
Section titled “In other CI systems”Outside GitHub Actions the command has no adapter: it reads nothing about a pull request, so it posts no comment, passes no pull request to Trawler and makes no plan for it, and writes no job summary. It starts the run, waits, prints the Markdown to standard output and sets the exit code. Everything else — the options, the variables, the own runner — works the same, from environment variables.
What it refuses
Section titled “What it refuses”| Message | Why |
|---|---|
no command given / unknown command … |
The first word must be run or help. |
run needs --api <url> or TRAWLER_API |
No address for the app. |
the API token is sent to --api, so it must use https unless it is on this machine |
An http address that is not localhost. |
TRAWLER_API_TOKEN is not set |
The token variable is empty or missing. |
--project is required / --project must be a UUID, got … |
The project is missing or is not a UUID. |
--cap must be a number of dollars between 0.1 and 50, got … |
The cap is out of range or not a plain number. |
--runner must be one of hosted, own, got … |
Likewise --fail-on and --plan-mode. |
--accounts needs --runner own, because a hosted runner cannot read a file in this job |
A file of accounts for a hosted run. |
--accounts … cannot be used: … |
The file is missing, larger than 64,000 bytes, not valid JSON, or not in the format. |
--allow-origin needs --runner own and --url, because it allows an address next to the app in this job / --allow-origin can be given at most 5 times / --allow-origin must be an http(s) address, got … |
An address was allowed for a hosted run or without --url, too many were given, or one is not an http or https address. Exit code 2. |
--environment … cannot be used: … |
The file named with --environment cannot be read. The default file is left out silently when it is not there. |
error: HTTP 422: Maya needs a test account to sign in. |
The app refused to start the run. Every refusal of the Run API that is not waited for or passed, as in When a run cannot start yet, prints this way, after its status. |
warning: a hosted runner cannot reach localhost; use --runner own for a server started in this job |
--url is on this machine and the run is hosted. The command goes on and the app refuses the call with A different target URL can only be tested by a runner in your own network. … |
error: HTTP 412: Start the first run of this project from the app, where you confirm you are authorised to test it. … |
The project has no run yet. Start its first run with Start run, or, for a product on a private network, choose Allow runs from CI on its start page; after that the command can start runs. |
error: HTTP 422: … or error: HTTP 503: … naming the provider |
The workspace’s model key was tested before the run was queued, and the provider refused it (422), the key cannot use the model (422) or the provider could not be reached (503). See What starting a run checks. |
error: HTTP 502: the server answered with something other than a started run; is the CLI older than the server? |
The checkout is of another version than the app’s, and the answer is not the shape the command expects. |
error: the runner exited with code 1 before the run finished; see the [runner] lines above |
The runner started for --runner own ended before the run did, with the code in the message or killed by a signal. The command notices within 5 seconds, stops the run and exits with 1. A runner that Trawler refuses for good, because it does not know the token or the version is not the app’s, ends this way after a line such as claim failed for good, the runner is stopping: the control plane does not know this runner (HTTP 401); …. See What the job needs. |