Skip to Content

The four commands

The four rig commands: check, show, install and test.

pitafix rig check <dir> [--project DIR] [--json]

Reads the manifest and says what is wrong with it. Nothing runs. Exit 0 when there is no problem, 1 when there is, 2 on a usage mistake.

$ pitafix rig check pkg/rig/testdata/example
orchard-web: no problem. 2 journeys, 2 states claimed, 2 said unreached.

With problems it lists each field, the problem and a fix:

8 problem(s) in /path/to/pitafix-rig.toml:

  journeys.steps.expekt: a rig has no such key.
    fix: Check its spelling against the guide, or take it out.
  id: "Bad Rig" is not a plain id.
    fix: Use lower-case letters, digits, dots, underscores and hyphens, 64 at most, starting with a letter or digit.
  journeys[0].steps.a.open: "orders" is not a path of the app.
    fix: Begin it with "/", as "/orders/42".
  ...

--json prints { "passed": false, "problems": [{ "field": "...", "message": "...", "fix": "..." }] }.

pitafix rig show <dir> [--json]

Says what the rig does, the lines the install sheet shows. Nothing runs. It exits 1 if the rig has a problem.

$ pitafix rig show pkg/rig/testdata/example
rig         orchard-web
name        Orchard
for         the nextjs core
runs        no command of its own
code        handlers/api.mjs
preloads    scripts/fixed-clock.cjs, from the project
sets        API_URL={{api.url}}
sets        STRIPE_PUBLISHABLE_KEY=
sets        API_URL=https://staging-api.orchard.example
reaches     staging-api.orchard.example, images.orchard.example, staging.orchard.example
asks        Your staging session: sign in on staging.orchard.example and copy its session cookie
asks        The mail address of your staging account
asks        The code staging just mailed you
walks       2 journeys, 11 steps
claims      2 states reached, 2 said unreached

--json prints the whole rig, which is what a core that isn't written in Go reads. Its keys are camel case (signIn, appHost, blockedBy, wayIn, testId), every journey's steps come in order with each use, state and sign_in put in its place, and each step has a kind (open, tap, type, key, back, scroll, idle, upload, menu, sign_in or launch):

{
  "id": "start-refund",
  "kind": "tap",
  "label": "Start a refund",
  "target": { "role": "button", "name": "Ask for a refund", "exact": true },
  "expect": { "url": "^/en/orders/42/refund" }
}

pitafix rig install <dir>

Shows rig show's lines with the folder it comes from, the folder it goes to, the SHA-256 of its files and its size, asks Install this rig? [y/N], then installs. Without an answer, as when nobody is at the terminal, it installs nothing. Use --dry-run to preview. See the CLI guide for scripted installs.

PitaFix rig install

rig         orchard-web
...
from        <the project>/.pitafix/rig
to          <data folder>/rigs/orchard-web
sha256      <the hash of the exact files>
size        <their size>

Install this rig? [y/N] y
Installed orchard-web to <data folder>/rigs/orchard-web.
Install grant recorded for these exact files. Running a project's code with it is asked about separately.

pitafix rig test <dir> --project DIR [--core DIR] [--journey ID]... [--json] [--timeout 2m] [--keep]

Checks the rig the way a capture will use it. First the manifest is read with nothing run. Then the rig's core walks each journey in a throwaway copy of the project, and each run is held to what every run is held to and to the rig's own claims. It runs the core's and the project's code with your rights, and records no trust. --core is the core's folder; without it the test looks for an installed core with the rig's core id. --journey narrows the test to one journey, repeatably. --project is required, and it is only read.

The checks come in order. rig says the manifest passed and how many journeys and claims it has. match says [match] holds for the project. Then each journey is a walk [<id>], followed by the checks every run gets (the trace, its records, its artifacts' hashes and so on), and a claims [<id>] check for a journey that has claims. A journey the rig doesn't have fails by its id. A rig with no journey has its core's own walk run once. Two checks appear only when they fail: core fails when the core's id isn't the rig's core, or when the core doesn't declare rig = true under [capabilities]. After a failure of rig, core, match or an unknown journey, nothing is walked, and walks shows as skipped.

A passing run, abridged, as the paper core in pkg/rig/rigtest walks a two-journey rig:

PitaFix rig test: ./.pitafix/rig
core: <the core's folder>
project: <the project> (read only; the core runs in a throwaway copy)

ok    rig                                   2 journeys, 2 states claimed, 1 said unreached
ok    match                                 paper.json contains "stationery"
ok    manifest                              pitafix-core.toml is valid
ok    doctor                                1 check
...
ok    walk [browse]                         passed, with 6 records
ok    trace-file [browse]                   6 records
...
ok    claims [browse]
ok    walk [order]                          passed, with 5 records
...
ok    claims [order]
ok    process-group                         nothing left the process group, and no job or verb left anything running
ok    core-unchanged                        the core's own folder is as it was, so its grant would still hold

stationery: 35 passed, 0 failed, 0 warned, 2 skipped, in <n> ms
PASS

A failing claim looks like this:

FAIL  claims [order]
      Basket, one item, is claimed by step "basket", and the walk left no record of that step.
      fix: Make the walk reach the step, or say the state is unreached and why.

A claim fails for one of three reasons, each with its fix: the walk left no record of the step, the step ended in another status than passed, or the step left no picture of the screen. --json prints the whole report, schema pitafix.rig-test/1. Exit 0 when every check passes or only warns, 1 when any fails or the run was interrupted, 2 on a usage mistake. A real toolchain needs a longer --timeout, and --keep leaves the throwaway folder.

On this page