fix: cache Go module dir to prevent re-downloads#200
Conversation
Add ~/go/pkg/mod to the tools cache path to persist downloaded Go modules across CI runs, preventing unnecessary re-downloads of tool dependencies on every action run. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📝 WalkthroughWalkthroughUpgrade GitHub Actions versions across workflows and simplify caching: checkout/setup-go bumped (v4→v6, v5→v6), CI cache patterns generalized to "**/*.sum", and a dedicated "Cache Tools Binaries" step removed (placeholder commented); job steps otherwise unchanged. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
Comment |
Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
.github/workflows/ci.yml (1)
33-44:⚠️ Potential issue | 🟠 MajorRemove
~/go/pkg/modfrom the tools cache to avoid conflicts with setup-go's module caching.The
actions/setup-go@v5action at lines 13-19 already caches~/go/pkg/modwithcache-dependency-path: | **/go.sum go.work.sum. Adding the same path to the tools cache creates redundant caching with incompatible cache keys:
- setup-go invalidates on changes to
**/go.sumorgo.work.sum(all modules in workspace)- tools cache invalidates only on changes to
tools/tools.goorgo.sum(root only)The tools cache's narrower key means it won't invalidate when submodule or workspace dependencies change, risking stale modules being restored over the fresher setup-go cache. The
actions/setup-goaction already handles module caching comprehensively; the tools cache should only manage~/go/binand~/.cache/golangci-lint.Recommended fix
- name: Cache Tools Binaries uses: actions/cache@v4 with: path: | ~/go/bin - ~/go/pkg/mod ~/.cache/golangci-lint # Key depends ONLY on tools/tools.go and the root go.sum (where tools versions are pinned) # This prevents tool rebuilds when app dependencies change
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Disable setup-go's built-in cache for the quality job since our custom tools cache uses a more stable key (only tools changes) compared to setup-go's cache (all dependencies). This prevents cache extraction conflicts and ensures tools aren't re-downloaded when only app dependencies change. Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In @.github/workflows/ci.yml:
- Around line 30-41: The cache key currently hashes both 'tools/tools.go' and
'go.sum' (key: ${{ runner.os }}-tools-${{ hashFiles('tools/tools.go', 'go.sum')
}}), which contradicts the "tools-only" claim; either remove 'go.sum' from the
hashFiles so the key is tools-only (e.g., hash only 'tools/tools.go') or update
the surrounding comment to state that app dependency changes (from go.sum) will
invalidate the cache; update the 'key' entry and/or the comment accordingly to
make the behavior and documentation consistent.
Apply the same custom cache strategy to the test job to prevent re-downloading Go modules on every run. The test job cache key is based on all go.sum files (app + examples dependencies) to ensure proper cache invalidation when dependencies change. Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
.github/workflows/ci.yml (1)
42-45:⚠️ Potential issue | 🟡 MinorStale comment references non-existent cache.
The comment "With the cache above, this will be a near-instant no-op if binaries exist" references a cache step that is now commented out. Update or remove this comment to reflect the current state.
📝 Suggested fix
- name: Install tools - # Use make tools to install versions pinned in go.mod/tools.go - # With the cache above, this will be a near-instant no-op if binaries exist + # Use make tools to install versions pinned in go.mod/tools.go run: make tools
Summary
~/go/pkg/modto the CI tools cache pathProblem
The current cache configuration only cached
~/go/bin(tool binaries) but not~/go/pkg/mod(Go module cache). This meant that even when binaries were cached,go installhad to re-download all tool dependencies from scratch on every run because the module cache wasn't persisted.Solution
Include
~/go/pkg/modin the cache path alongside~/go/binand~/.cache/golangci-lint. This ensures that:Test plan
Made with Cursor
Summary by CodeRabbit