Skip to content

ci: restore turbo cache hits on PR unit job#75

Merged
Astro-Han merged 2 commits into
devfrom
worktree-fix-ci-turbo-cache-path
Apr 20, 2026
Merged

ci: restore turbo cache hits on PR unit job#75
Astro-Han merged 2 commits into
devfrom
worktree-fix-ci-turbo-cache-path

Conversation

@Astro-Han

@Astro-Han Astro-Han commented Apr 20, 2026

Copy link
Copy Markdown
Owner

Summary

Change actions/cache path from node_modules/.cache/turbo (turbo v1 default) to .turbo/cache (turbo v2 default) so the cache dir actually has contents to save, and add a per-job discriminator (-typecheck / -unit) to the cache key so the two concurrent jobs stop racing on the same reservation.

Why

ci / unit spends ~232s on every PR, even YAML-only ones. Root cause is a two-layer cache failure that compounds: the cache path pointed at an empty directory (turbo v1 default, but we run turbo v2), so every post-step logged [warning]Path Validation Error: Path(s) specified in the action for caching do(es) not exist, hence no cache is being saved. — no turbo-Linux-* entry ever landed in the pool (verified: 37 caches, 10.3 GB, zero turbo entries). Even with the path fixed, both jobs shared the exact same cache key, so they would race on reserveCache; per actions/toolkit source, the loser catches ReserveCacheError and logs it at info level without uploading. typecheck (~60s) always finishes before unit (~232s), so unit's cache would never enter the pool and subsequent runs would restore typecheck-flavored tarballs into unit jobs, producing task-hash misses and another full 232s run. Splitting the keys makes each job own its own slice.

Related Issue

Closes #74. The issue lists three levers: turbo cache fix (this PR), --filter=...[origin/dev] (obsoleted by turbo's own content-hash skipping once cache is working), and bun / desktop-electron concurrency (independent micro-optimisation, open a fresh issue if benchmark warrants it). Note: the issue body's passThroughEnv: ["*"] hypothesis is not the root cause — local turbo --dry=json with fake GitHub runner env produces identical task hashes, confirming passThroughEnv is a "pass through but don't hash" allowlist, not the opposite.

How To Verify

Pre-merge (local, already run):

bun turbo run test:ci --filter=opencode --dry=json 2>/dev/null \
  | jq '.tasks[] | {hash, envMode, passThroughEnv}' > /tmp/h1.json
GITHUB_RUN_ID=9999 GITHUB_SHA=deadbeef bun turbo run test:ci --filter=opencode --dry=json 2>/dev/null \
  | jq '.tasks[] | {hash, envMode, passThroughEnv}' > /tmp/h2.json
diff /tmp/h1.json /tmp/h2.json   # empty diff confirms env does not affect hash

Post-merge (CI observation — cannot be reproduced locally because actions/cache save/restore only runs on GitHub runners):

  • On this PR's own ci / unit and ci / typecheck runs: post-step should log Cache saved with key: turbo-Linux-typecheck-... and turbo-Linux-unit-... (no Path Validation Error, no ReserveCacheError).
  • On the next non-docs-only PR after merge: both jobs log Cache restored from key: turbo-Linux-typecheck-... / turbo-Linux-unit-...; bun turbo test:ci output contains >>> FULL TURBO for unchanged tasks.
  • Cache pool check: gh api /repos/Astro-Han/pawwork/actions/caches | jq '.actions_caches[].key' | grep turbo should return turbo-Linux-typecheck-* and turbo-Linux-unit-* entries.

Checklist

  • I ran the relevant verification steps
  • I tested visible changes manually when needed (N/A — CI-only change)
  • I am targeting the dev branch

Summary by CodeRabbit

No user-visible changes

This release contains only internal infrastructure updates to the continuous integration build pipeline. No new features, bug fixes, or user-facing functionality have been modified.

The `actions/cache` step pointed at `node_modules/.cache/turbo`, which
is turbo v1's default. Turbo v2 writes to `.turbo/cache`, so the cache
path bound to an empty directory: the post-action save silently wrote
nothing, no `turbo-Linux-*` key ever landed in the pool, and every run
three-way-missed the restore keys (observed on PR #72 logs).

Net effect: seven tasks marked `cache miss, executing` on every PR
unit job, turning a YAML-only PR into a full 232s cold run.

Refs: #74
typecheck and unit jobs shared the exact same cache key
(turbo-Linux-<hash>-<sha>). With path now pointing at the real
turbo v2 cache dir, they would race on reserveCache: typecheck
finishes first (~60s) and wins the reservation, unit (~232s)
hits ReserveCacheError and skips upload.

Effect: pool accumulates only typecheck-flavored tarballs. Next
run's unit job restores typecheck's cache, finds no matching
test:ci task hash, and re-executes the full 232s suite.

Split the key with a job discriminator (-typecheck / -unit) so
each job saves and restores its own slice.

Refs: #74
@Astro-Han Astro-Han added bug Something isn't working ci Continuous integration / GitHub Actions P1 High priority labels Apr 20, 2026
@gemini-code-assist

Copy link
Copy Markdown

Note

Gemini is unable to generate a review for this pull request due to the file types involved not being currently supported.

@coderabbitai

coderabbitai Bot commented Apr 20, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Updated GitHub Actions cache configuration for Bun's Turborepo build artifacts in the CI workflow. Changed the cached directory from node_modules/.cache/turbo to .turbo/cache and introduced job-specific cache key naming for typecheck and unit jobs. Build commands remain unchanged.

Changes

Cohort / File(s) Summary
Turborepo Cache Configuration
.github/workflows/ci.yml
Updated cache directory path from node_modules/.cache/turbo to .turbo/cache in both typecheck and unit jobs. Adjusted cache key naming to be job-specific: typecheck uses turbo-${{ runner.os }}-typecheck-... while unit uses turbo-${{ runner.os }}-unit-... for better cache isolation.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Possibly related issues

  • [Feature] Speed up ci / unit job #74: Directly related—both changes modify the same CI cache configuration for Turbo in the unit job, including cache directory path and key naming adjustments.

Suggested labels

P2

Poem

🐰 Caches dancing, paths align,
Turborepo now works fine!
Job by job, we cache with care,
Swift builds floating through the air! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title directly describes the main change: fixing turbo cache hits in the PR unit job, which is the core objective of this PR.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description check ✅ Passed The PR description comprehensively covers all required template sections with detailed technical context, root cause analysis, and verification steps.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch worktree-fix-ci-turbo-cache-path

Comment @coderabbitai help to get the list of available commands and usage tips.

@Astro-Han Astro-Han added P2 Medium priority and removed P1 High priority labels Apr 20, 2026
@Astro-Han Astro-Han merged commit 7913254 into dev Apr 20, 2026
16 of 22 checks passed
@coderabbitai coderabbitai Bot mentioned this pull request Apr 22, 2026
7 tasks
@Astro-Han Astro-Han deleted the worktree-fix-ci-turbo-cache-path branch April 26, 2026 07:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working ci Continuous integration / GitHub Actions P2 Medium priority

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Speed up ci / unit job

1 participant