Skip to content

CI setup

Running flaky-tests in CI gives you a shared failure history across every pull request and push, which makes pattern detection much more reliable than local-only data.

You need a shared store — SQLite is local-only and won’t work for CI. Use Turso, Supabase, or Postgres.

.github/workflows/ci.yml
name: CI
on:
push:
branches: [main]
pull_request:
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- run: bun install
# Capture failures during test run
- run: bun test
env:
FLAKY_TESTS_STORE: turso
FLAKY_TESTS_CONNECTION_STRING: ${{ secrets.TURSO_URL }}
FLAKY_TESTS_AUTH_TOKEN: ${{ secrets.TURSO_AUTH_TOKEN }}
# On main: check for new patterns and open issues if found
- if: github.ref == 'refs/heads/main'
uses: brewpirate/flaky-tests@v1
with:
store: turso
connection-string: ${{ secrets.TURSO_URL }}
auth-token: ${{ secrets.TURSO_AUTH_TOKEN }}
github-token: ${{ secrets.GITHUB_TOKEN }}
create-issues: 'true'
  1. Create a Turso database (or Supabase/Postgres project)
  2. Go to your GitHub repo → SettingsSecrets and variablesActions
  3. Add the required secrets:
    • TURSO_URL — your Turso database URL (libsql://...)
    • TURSO_AUTH_TOKEN — your Turso auth token
EventCaptures failuresChecks for patternsOpens issues
Pull requestYesNoNo
Push to mainYesYes (if create-issues: true)Yes (if new patterns)
Scheduled (weekly)NoYesYes (if new patterns)
  • Writes are drained at process exit. The Bun preload tracks every fire-and-forget write and awaits outstanding ones before the test process shuts down, so transient remote-store latency at the end of a run doesn’t drop failures.
  • Remote stores retry transient failures. Turso, Supabase, and Postgres adapters retry network errors with exponential backoff out of the box — flaky CI networking rarely needs special handling on your side.
  • Migrations run automatically. Plugins and the CLI both call migrate() before the first query, so a fresh database works on the first run with no setup step.

If you want to collect data without running detection yet:

- run: bun test
env:
FLAKY_TESTS_STORE: turso
TURSO_URL: ${{ secrets.TURSO_URL }}
TURSO_AUTH_TOKEN: ${{ secrets.TURSO_AUTH_TOKEN }}
# No detection step — just accumulate data

Run in capture-only mode for a week or two to build up baseline data before enabling detection.