breadboard
docs

11 · Hardware tests in your pipeline

Breadboard CI

Run your circuits as tests on every push: deterministic emulated-hardware runs on hosted workers, GitHub-annotated failures, and replayable flight recordings.

Breadboard CI runs a circuit plus a small test spec on Breadboard's servers (the same engine and emulated boards as the bench, headless) and turns the result into a pass/fail your pipeline can gate on. Deadlines in a spec are simulated time, never wall clock: the engine is deterministic on its 5 ms grid, so assertions follow circuit time. A separate wall budget can stop a run that takes too long. When a spec fails, the run comes back with a flight recording you can replay bit-exactly on your own bench. CI is part of the CI plan (£9.99, $12 or €12 a month, plus tax: everything in Pro, plus the hosted runners).

Hosted CI is not enabled in production yet. These instructions describe an enabled CI deployment; a token or subscription alone does not turn the service on.

Quickstart: GitHub Actions

  1. 1Mint a token: on a CI-enabled account, open the account menu → CI tokens… (or Account → Developer → Manage CI tokens), name it and Create token. The ci_… secret is shown exactly once; copy it into a repository secret named BREADBOARD_CI_TOKEN. Revoke it any time from the same dialog.
  2. 2Commit your circuit: save the bench to a JSON file in the repo (File → Export → Project, e.g. circuit.bb.json).
  3. 3Write a spec: a .bbtest.json file (format below) next to it, e.g. in tests/.
  4. 4Add the workflow:
# .github/workflows/breadboard.yml
name: circuit-tests
on: [push, pull_request]
jobs:
  breadboard:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: Dollis-Hill/breadboard-ci-action@v1
        with:
          token: ${{ secrets.BREADBOARD_CI_TOKEN }}
          doc: circuit.bb.json
          specs: tests/
      - uses: actions/upload-artifact@v4
        if: failure()
        with:
          name: breadboard-ci-recordings
          path: breadboard-ci-recordings/

Failures land as error annotations on the spec file, with the failing step, the sim time it missed its deadline, and a tail of the serial output. The action wraps a small CLI, breadboard-ci: breadboard-ci run --doc circuit.bb.json tests/ submits and polls (token from BREADBOARD_CI_TOKEN), breadboard-ci ping checks a token. Exit codes: 0 every spec passed, 1 a spec failed, 2 setup or service trouble (bad token, missing plan, spent minutes).

The .bbtest.json spec format

{
  "version": 1,
  "name": "thermostat kicks in",
  "boot": { "bootTimeoutSimS": 20, "settleSimS": 5 },
  "wallBudgetMs": 120000,
  "steps": [
    { "type": "expect-serial", "component": "esp1",
      "pattern": "ready", "withinSimS": 10 },
    { "type": "set-param", "component": "tmp1", "params": { "temperatureC": 41 } },
    { "type": "expect-visual", "component": "led1",
      "brightness": { "min": 0.5 }, "withinSimS": 5 }
  ]
}

A spec boots the document (MicroPython banner → REPL on every board → the script in Code injected), runs the steps in order, then settles for settleSimS more simulated seconds. Every run also implicitly asserts that no firmware error or error-level diagnostic ever fires: a crashing program fails even if every explicit step passed. A spec must contain at least one expect-* or observe step, and steps target components by their id (select a part on the bench to see it in the Inspector).

  • expect-serial: a regex must match the board's serial output within withinSimS simulated seconds (output after your script started, and after the latest stimulus step). Add "capture": true to get the matched text and its groups back on the step result (up to 8 groups of 256 characters each; further groups are dropped and the match is marked truncated), e.g. "pattern": "temp=([0-9.]+)\\r?\\n". With capture the pattern sees complete lines only, so a value is never read half-printed. expect-serial-absent is its dual, checked once at the end of the run.
  • interact: press the hardware: buttonDown/buttonUp, switchSet, dialChange, toggleDip, keypadDown/keypadUp, pirTrigger, joystickMove, joystickButtonDown/joystickButtonUp, irKeyDown/irKeyUp (the IR receiver's remote), turn (rotary encoder).
  • set-param: set component parameters directly (sensor values, slider positions): { "params": { "temperatureC": 41 } }.
  • write-serial: type into a board's serial console (omit component to broadcast to every serial-capable board).
  • wait: advance the simulation by simS seconds.
  • expect-visual: poll a component's visible state until every given predicate holds: brightness (0..1 min/max; an LED switching faster than about 50 Hz, such as PWM, reads as its perceived average), textContains (character displays), pixelsLit (LED strips), rpm, toneHz, fault, angle (servo degrees), reading (instruments and sensors), power (watts), rgb (per-channel 0..1 bounds, e.g. { "r": { "min": 0.5 }, "b": { "max": 0.1 } }), pinLevel ({ "pin": "d13", "level": 1 } on a board or IC) and textMatches (a regex over the display rows joined by newlines, { "pattern": "^T=\\d+", "flags": "m" }).
  • expect-signal: frequency and duty cycle on a component pin over a window of simulated time, e.g. { "component": "nano1", "pin": "d13", "windowSimS": 3, "frequencyHz": { "min": 0.9, "max": 1.1 }, "dutyCycle": { "min": 0.4, "max": 0.6 } }. The pin's net voltage is compared with thresholdV (default 1.5 V) once every 5 ms of simulated time, so the supported range is up to 50 Hz, with every high and low phase lasting at least 10 ms. A faster signal fails the step as too fast to measure (a phase under 5 ms can be missed entirely); check PWM with brightness instead. A constant level measures 0 Hz with duty 0 or 1.
  • observe: record a component's state at that instant without asserting it. fields picks from pinLevels, brightness, rgb, text, angle, rpm, toneHz, reading, power, fault, activity, segments (seven-segment), matrix, pixels, joystick and display (the frame display's pixels, up to 32 KiB, colour screens downsampled to fit); voltages lists pins whose net voltage to record. The values appear on the step's result; a field the part does not have is null, and long lists are cut to their cap and named in truncated.
  • expect-voltage: a net voltage at a component pin, e.g. { "component": "esp1", "pin": "g4", "min": 3.0 }.
Firmware scope: MicroPython on the ESP32 family and Pico, analog/digital circuits, and prebuilt firmware blobs referenced by the document. Browser-local idb: firmware cannot be fetched by a hosted worker; use an admitted inline firmware image or an available asset.

Arduino: compile before simulation

To test a fresh Arduino build, pass --code arduino-code.json to the CLI, or code: arduino-code.json to the Action. This separate JSON file uses the hosted API's compile input:

{
  "lang": "arduino",
  "board": "uno",
  "component": "uno1",
  "source": "void setup() { Serial.begin(9600); Serial.println(\"ready\"); }\nvoid loop() {}"
}

Each spec compiles the sketch first, then runs the resulting firmware on the named component. Omit component only when exactly one board in the document matches the compile target. Compiler errors appear as compile_failed with diagnostics. Compile minutes use the account's compile pool, separately from CI simulation minutes. Supported targets depend on the deployment; profiles that require a private relink package currently refuse chaining before charging. Without code, the document's existing firmware is simulated; an Arduino source file in the exported document does not request a build.

Failure recordings

A failing run returns the whole session as a .bbrec.json flight recording: every simulation input at its exact sim time. The action writes recordings to breadboard-ci-recordings/ (keep them with an upload-artifact step, as in the quickstart). To debug one, download the artifact and open breadboard.build/app/?open-recording=1, pick the file and the failure replays on the bench with the full time-travel deck: pause, scrub to the moment it went wrong, single-step, or resume live from any instant and take over.

Allowances and limits

  • The CI plan includes 1500 CI simulation minutes a month (240 a day) and 2 runs in parallel. CI minutes measure worker wall time, rounded up to whole minutes, rather than the circuit's simulated duration. Infrastructure failures refund the CI reservation.
  • One run is one document plus one spec and optional compile input, up to 2 MiB of UTF-8 JSON together; up to 100 steps per spec; results (verdict + recording) are kept for 24 hours.
  • wallBudgetMs (default 120 s, max 600 s) is a real-time safety valve for runaway or slow programs. It is separate from simulated assertion deadlines and the client's --poll-timeout-s / Action poll-timeout-s setting (default 900 s). A client polling timeout does not cancel the hosted run or refund its work. The timeout message includes the run's polling URL.