anomalyco / anomalyco/opencode

ci: setup-bun cache key differs between restore and save, exact cache hits never happen

Open
#47,617 1 comment 0 reactions 1 assignee View on GitHub

@nexxeln is already working on this.

Since Sep 6, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Summary

The setup-bun composite action (.github/actions/setup-bun/action.yml) never gets an exact cache hit on dev. Restore and save both use hashFiles('**/bun.lock'), but they run at different times: restore before bun install, save after. Once node_modules exists, the glob also matches lockfiles shipped inside dependencies, so the two keys differ. The key that gets saved is never the key that gets looked up.

Evidence

Last three test.yml runs on dev (34011772829, 34011717028, 33998805878), unit (linux) job:

Cache hit for restore-key: Linux-bun-bdcce106…      <- fallback prefix match, not the primary key
Failed to save: Unable to reserve cache with key Linux-bun-b26debf2…

Reproducing hashFiles locally on a fresh clone of dev (sha256 of each file's sha256, sorted by path):

moment files matched hash
restore (before install) 5 (bun.lock + 4 in-repo) 845de84c…
save (after install) 7 (+2 under node_modules/.bun/ghostty-web…) b26debf2…

The save hash matches the CI log exactly. The restore hash is never saved by anyone.

Effect

Dependencies are always restored from whatever Linux-bun-* entry is newest, regardless of lockfile, and then re-saved under an unreachable key on every push. It still works thanks to restore-keys, so the failure is silent, but exact hits never happen and the cache is not invalidated by lockfile changes.

Fix

Compute the key once, before bun install, and pass it to both actions/cache/restore and actions/cache/save. PR incoming.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.