Skip to content

fix: use deterministic temp dir for history cache storage#29

Merged
maximn merged 2 commits into
mainfrom
fix/deterministic-cache-path
Apr 5, 2026
Merged

fix: use deterministic temp dir for history cache storage#29
maximn merged 2 commits into
mainfrom
fix/deterministic-cache-path

Conversation

@maximn
Copy link
Copy Markdown
Contributor

@maximn maximn commented Apr 5, 2026

Summary

History cache was never restored between runs because mkdtempSync generates a random
directory name on every run. @actions/cache archives files at their absolute path and
restores them to that same path — so a cache saved from /tmp/testglance-abc123/ can
never be found when the next run looks at /tmp/testglance-xyz789/. Every run was a
guaranteed cache miss, causing "First run on this branch" forever.

Changes

  • Replace mkdtempSync with a deterministic directory path derived from branch + reportPathHash
  • Update node:fs mocks in both test files (mkdtempSyncmkdirSync)
  • Update cache key format assertion to verify the deterministic path

Test plan

  • All 553 unit tests pass
  • E2E run on main: second push should restore history and show deltas/trends instead of "First run on this branch"
  • Stale caches (saved with old random paths) can be purged from repo settings

maximn added 2 commits April 5, 2026 17:44
mkdtempSync creates a unique dir per run, so @actions/cache restores
the archive to the old random path while the code checks a different
new random path — always a miss, always "First run on this branch".

Replace with a fixed path derived from branch + report-path hash so
save and restore always use the same location across runs.
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 5, 2026

@maximn maximn merged commit db9fa6a into main Apr 5, 2026
7 checks passed
@maximn maximn deleted the fix/deterministic-cache-path branch April 5, 2026 17:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant