Skip to content

perf(ci): cache node_modules, agent .venv, and Jest transforms in build workflow#202

Draft
scottschreckengaust wants to merge 3 commits into
mainfrom
fix/201-ci-caching
Draft

perf(ci): cache node_modules, agent .venv, and Jest transforms in build workflow#202
scottschreckengaust wants to merge 3 commits into
mainfrom
fix/201-ci-caching

Conversation

@scottschreckengaust
Copy link
Copy Markdown
Contributor

@scottschreckengaust scottschreckengaust commented May 27, 2026

Summary

  • Adds actions/cache@v4 for node_modules (keyed on yarn.lock), agent/.venv (keyed on uv.lock), and Jest transform cache (keyed on yarn.lock + commit SHA with cross-branch restore-keys)
  • Sets Jest cacheDirectory to <rootDir>/.jest-cache — moves cache off tmpfs (fixes /tmp filling), enables persistence locally and in CI
  • Adds .jest-cache to .gitignore
  • Includes timing instrumentation (SECONDS + ::notice) to measure cache-hit vs cold performance

How to measure the improvement

The workflow logs cache status and timing in GHA annotations:

::notice::Install completed in 5s (node_modules=true, venv=true, jest=true)   ← all cached
::notice::Install completed in 75s (node_modules=miss, venv=miss, jest=miss)  ← cold
::notice::Build completed in 580s                                             ← with jest cache
::notice::Build completed in 725s                                             ← without jest cache

To compare:

  1. First run: all caches MISS (cold baseline)
  2. Second run (re-run or push): caches HIT — install drops to ~5s, build drops ~30-50s
  3. Compare via ::notice annotations in workflow summary

To drop the instrumentation after validation: Remove the SECONDS=0 / echo "::notice::" lines. The caching is the permanent change.

Cache strategy

Cache Key Restore-keys Invalidates when
node_modules node-modules-{os}-{hash(yarn.lock)} None Lockfile changes
agent/.venv agent-venv-{os}-{hash(agent/uv.lock)} None Python deps change
Jest transforms jest-{os}-{hash(yarn.lock)}-{sha} jest-{os}-{hash(yarn.lock)}- Always unique per commit; falls back to same-lockfile prior run

Jest cache uses restore-keys because partial cache (most files unchanged) is still beneficial. The others don't, because stale node_modules/.venv with wrong versions would break the build.

Expected impact

Metric Before (cold) After (cache hit)
Install step ~75s ~5-10s
Jest test step ~90s ~40-50s
Total wall time saved ~110-120s

Also fixes: Jest transform cache no longer fills /tmp tmpfs (was causing ENOSPC failures locally).

Test plan

  • First PR run: verify all caches MISS, timings match baseline
  • Second run: verify caches HIT, install ~5s, build faster
  • Verify mise run build still passes
  • Verify mutation detection still works
  • Verify .jest-cache/ does not appear in git status

Refs #201

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com

scottschreckengaust and others added 2 commits May 27, 2026 05:18
Adds actions/cache for node_modules (keyed on yarn.lock) and
agent/.venv (keyed on uv.lock). Includes timing instrumentation
via SECONDS and ::notice annotations to measure cache-hit vs cold
install performance across runs.

Expected: Install step drops from ~75s (cold) to ~5s (cache hit).

Refs #201

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sets cacheDirectory to <rootDir>/.jest-cache (off tmpfs, persists
locally) and caches it in CI via actions/cache keyed on yarn.lock +
commit SHA with restore-keys fallback for cross-branch reuse.

Expected: test step drops from ~90s to ~40-50s on cache hit since
ts-jest skips re-transpiling unchanged source files.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@scottschreckengaust scottschreckengaust changed the title perf(ci): cache node_modules and agent .venv in build workflow perf(ci): cache node_modules, agent .venv, and Jest transforms in build workflow May 27, 2026
No-op commit to trigger a second CI run where caches are warm.
Compare Install/Build timing annotations with the prior cold run.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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