Replay & verify

Regression tests in CI

A capsule you've verified as FIXED becomes a regression test: the exact recorded session, replayed against every new commit. regress run reads only local files, so CI needs no credentials.

Add tests

bugcapsule regress add <id> --name "coupon over subtotal"   # downloads the capsule
bugcapsule regress list
git add bugcapsule/ && git commit -m "Add coupon regression capsule"

This writes bugcapsule/regressions.json and bugcapsule/regressions/<capsuleId>.bugcapsule under the project root (-p). Commit both. Capsules are redacted on device, but read one with bugcapsule inspect --json before committing it to a shared repository.

Run them

bugcapsule regress run -n 2          # every active test, 2 attempts each; exit 1 on any failure
Verify verdictRecorded asFails CI?
FIXEDpassNo
STILL FAILINGfailYes
INCONCLUSIVE, NOT REPRODUCED, REPRODUCEDinconclusiveYes
FLAKYtest status → quarantinedNo; skipped next time unless --include-quarantined
INCOMPATIBLEtest status → staleNo; the state schema changed, re-capture it

regress run updates each test's lastRun in regressions.json. In CI, either discard that change or upload the file as an artifact to review quarantined and stale tests.

!

Because replay is strict, a regression test breaks when a deliberate change makes the app send new requests in that flow (network.unrecorded → inconclusive). Re-capture the capsule on the new behaviour and replace the test; don't switch to --lenient-network in CI, which would send requests to real services.

CI recipes

name: bugcapsule regressions
on: [pull_request]
jobs:
  regress-web:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with: { node-version: 22 }
      - run: npm ci
      - run: npx playwright-core install --with-deps chromium
      - run: npm install -g @bugcapsule/cli@0.4.1
      - run: bugcapsule regress run -n 2        # builds and serves via bugcapsule.json, replays in Chromium
jobs:
  regress-android:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-java@v4
        with: { distribution: temurin, java-version: 17 }
      - uses: actions/setup-node@v4
        with: { node-version: 22 }
      - run: npm install -g @bugcapsule/cli@0.4.1
      - name: Enable KVM
        run: |
          echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm.rules
          sudo udevadm control --reload-rules && sudo udevadm trigger --name-match=kvm
      - uses: reactivecircus/android-emulator-runner@v2
        with:
          api-level: 35
          arch: x86_64
          script: bugcapsule regress run -n 2   # device must be unlocked; no screen-lock PIN
jobs:
  regress-ios:
    runs-on: macos-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with: { node-version: 22 }
      - run: npm install -g @bugcapsule/cli@0.4.1
      # bugcapsule.json names the scheme, replayTest and simulator; Debug must define DEBUG
      - run: bugcapsule regress run -n 2 -d "iPhone 16"
jobs:
  regress-flutter:
    runs-on: macos-latest
    steps:
      - uses: actions/checkout@v4
      - uses: subosito/flutter-action@v2
        with: { channel: stable }
      - run: flutter pub get
      - name: Boot a simulator
        run: xcrun simctl boot "iPhone 16" || true
      - run: dart run bug_capsule:bugcapsule regress run -n 2 -d "iPhone 16"

These are starting points, not tested workflows: runner images and simulator names change. Keep the per-attempt timeout generous on shared runners (--attempt-timeout or timeouts.attemptSeconds).

Recording replay and verify results from CI

run and verify on a capsule from your project record their result automatically, so it shows in the dashboard (use --report-to <id> when you replay a local file). In CI, give them credentials through the environment rather than bugcapsule login:

      - run: bugcapsule verify ${{ inputs.capsule_id }} -n 5
        env:
          BUGCAPSULE_URL: https://api.bugcapsule.com
          BUGCAPSULE_SECRET_KEY: ${{ secrets.BUGCAPSULE_SECRET_KEY }}   # a CI secret, never in the repo

Release gate

bugcapsule gate blocks a release that brings a fixed bug back. It asks BugCapsule which capsules the release must not reproduce: those of issues resolved in this release or earlier that it claims to fix, and those already verified fixed. It builds the app once, verifies each capsule, records the runs and a gate result on the release, prints a table and can write JUnit XML. Unlike regress run, it needs no capsule files in the repository: the list comes from your project, so every issue you resolve is checked from the next release on.

bugcapsule gate --release com.shop.app@1.5.0+60 --platform android \
  --attempts 3 --junit build/bugcapsule-gate.xml
      - run: bugcapsule gate --release "$APP_RELEASE" --platform android --junit build/bugcapsule-gate.xml
        env:
          APP_RELEASE: com.shop.app@1.5.0+60                   # the release string the build reports
          BUGCAPSULE_TOKEN: ${{ secrets.BUGCAPSULE_TOKEN }}   # service token: capsules.read, replay.submit

Run it on the same runner setup as the recipes above (an emulator, a simulator or Chromium). Use the release string your app reports, so the gate's runs count toward that release on the issues they verify.

Provision the candidate before these examples

Install the pinned CLI from npm and restore SDK dependencies from their registries before building. Keep dependency lockfiles committed and store authorized CLI credentials in CI secrets.

For local regression files, backend credentials are unnecessary unless the job reports results or uploads debug files. Never expose project secrets to untrusted pull-request jobs. The web runner requires Chromium installed on the same runner and a replay-enabled app build.

Capture stdout/stderr and the exit status as CI artifacts. Do not append || true to replay or regression commands: errors and inconclusive attempts must fail the check. Review redacted fixtures before committing them; do not commit CLI credentials or downloaded production capsules.