flaker keeps its data in a DuckDB file at the path declared by flaker.toml[storage] path (default .flaker/data). For flaky detection / KPI / quarantine to work, that file must persist between CI runs. GitHub Actions has no first-class runtime storage, so the convention is actions/cache@v6 with a sliding key.
key uses github.run_id so each run writes a new cache entry on save (GH Actions saves at end of job).
restore-keys: flaker-data- matches anything written previously, falling back to the most recent — so the next run sees the latest accumulated state regardless of which earlier run produced it.
if: always() so a failed earlier step still triggers the save (history-on-failure is fine and often more useful than history-only-on-success).
The path MUST equal flaker.toml's [storage] path. Default is .flaker/data (a file, not a directory — pre-creating it as a dir breaks the DuckDB open).
In a pnpm workspace monorepo: prefix the cache path with the package directory, e.g. packages/<pkg>/.flaker/data. flaker does NOT walk up to find flaker.toml — it must live next to where flaker is invoked. Mismatched cache path vs flaker.toml location surfaces as Config file not found (when running from repo root) or "history vanished every run" (when cache and flaker disagree on where storage is).
Triggering writes
actions/cache@v6 saves automatically in its post-step. Callers don't cache save explicitly. The save key is the run-id, so duplicate writes never collide.
fetch-depth for --changed derivation
Any flaker invocation that uses the hybrid / affected strategy (flaker run --gate merge in CI profile, by default) needs --changed <files,...>. Without it: Error: hybrid mode requires resolver and changedFiles.
- uses: actions/checkout@v7
with:
fetch-depth: 0 # need history for `git diff` against the PR base
The cache save at end-of-job picks up the new rows automatically.
if: always() ensures partial-failure runs still record what they saw before the failure.
やってはいけないこと
flaker の実行前に .flaker/data をディレクトリとして事前に作成しないでください。 DuckDB はこれをファイルとして開こうとするため、IO Error: Could not read from file ... Is a directory というエラーが発生します。キャッシュの path: .flaker/data がまだ存在しないファイルを指していても問題ありません。存在する場合は actions/cache が復元し、存在しない場合は flaker が作成します。