chore: Cache custom golangci-lint binaries in GHA workflow#19
chore: Cache custom golangci-lint binaries in GHA workflow#19alexandear wants to merge 1 commit into
Conversation
|
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. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (8)
📝 WalkthroughWalkthroughRead golangci-lint version from Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
This PR speeds up CI linting by caching the golangci-lint and custom-gcl binaries in the GitHub Actions linter workflow, and it centralizes the golangci-lint version by deriving it from .custom-gcl.yml.
Changes:
- Derive
GOLANGCI_LINT_VERSIONinscript/setup-custom-gcl.shfrom.custom-gcl.ymland install binaries into a repo-rootbin/. - Add a GitHub Actions cache step for
bin/golangci-lintandbin/custom-gcl, keyed off.custom-gcl.yml. - Update
.custom-gcl.ymlcomment to clarify the purpose ofversion:.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
script/setup-custom-gcl.sh |
Reads golangci-lint version from .custom-gcl.yml and uses a consistent repo-root bin/ directory. |
.github/workflows/linter.yml |
Adds caching for the golangci-lint and custom-gcl binaries to speed up CI runs. |
.custom-gcl.yml |
Clarifies that version: is the golangci-lint version. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
.github/workflows/linter.yml (1)
21-21: Cache key is sensitive to comment-only edits in.custom-gcl.yml.Line 21 hashes the entire file content, so non-functional comment changes invalidate the cache. Normalized hashing (comments stripped) would preserve cache hits across such edits.
♻️ Optional refactor
+ - id: custom-gcl-cache-key + shell: bash + run: | + normalized="$(sed 's/[[:space:]]*#.*$//' .custom-gcl.yml)" + echo "hash=$(printf '%s' "$normalized" | sha256sum | cut -d' ' -f1)" >> "$GITHUB_OUTPUT" + - uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4 with: path: | bin/golangci-lint bin/custom-gcl - key: ${{ runner.os }}-custom-gcl-${{ hashFiles('.custom-gcl.yml') }} + key: ${{ runner.os }}-custom-gcl-${{ steps.custom-gcl-cache-key.outputs.hash }}🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.github/workflows/linter.yml at line 21, The cache key currently uses hashFiles('.custom-gcl.yml') which is sensitive to comment-only edits; replace it with a normalized hash computed from the file with comments stripped (e.g., add a preceding run step that reads .custom-gcl.yml, removes/comment-lines and blank lines, computes a hash and exposes it as an output or env like NORMALIZED_GCL_HASH) and then change the key to use that normalized value instead of hashFiles('.custom-gcl.yml') so comment changes no longer invalidate the cache.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@script/setup-custom-gcl.sh`:
- Around line 9-11: The GOLANGCI_LINT_VERSION parsed from the .custom-gcl.yml
may be empty or malformed causing silent CI failures; after the existing
assignment to GOLANGCI_LINT_VERSION validate that it is non-empty and then
enforce a semantic format like ^v[0-9]+\.[0-9]+\.[0-9]+$ (or your chosen
pattern), and if either check fails, print a clear error and exit non‑zero so
the reinstall logic runs; ensure this validation happens before any use of
GOLANGCI_LINT_VERSION (e.g., before the grep check that currently uses it) so an
empty pattern cannot short-circuit the install branch.
---
Nitpick comments:
In @.github/workflows/linter.yml:
- Line 21: The cache key currently uses hashFiles('.custom-gcl.yml') which is
sensitive to comment-only edits; replace it with a normalized hash computed from
the file with comments stripped (e.g., add a preceding run step that reads
.custom-gcl.yml, removes/comment-lines and blank lines, computes a hash and
exposes it as an output or env like NORMALIZED_GCL_HASH) and then change the key
to use that normalized value instead of hashFiles('.custom-gcl.yml') so comment
changes no longer invalidate the cache.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 2459fba4-fac0-4384-b0e3-2966184a8ac8
📒 Files selected for processing (3)
.custom-gcl.yml.github/workflows/linter.ymlscript/setup-custom-gcl.sh
There was a problem hiding this comment.
Pull request overview
This PR updates CI and tooling around the repository’s custom golangci-lint setup by caching the installed binaries in GitHub Actions and by deriving the golangci-lint version used by setup-custom-gcl.sh from .custom-gcl.yml.
Changes:
- Added GitHub Actions caching for
bin/golangci-lintandbin/custom-gcl, keyed off.custom-gcl.yml(and selected plugin sources). - Updated
script/setup-custom-gcl.shto locate the repo root and extract thegolangci-lintversion from.custom-gcl.yml. - Added the
tools/extraneousnewcustom linter module (implementation + analysistest coverage) and fixed its plugin path in.custom-gcl.yml.
Reviewed changes
Copilot reviewed 3 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
.github/workflows/linter.yml |
Adds GHA cache steps for golangci-lint and custom-gcl. |
script/setup-custom-gcl.sh |
Computes repo root and parses .custom-gcl.yml for the golangci-lint version. |
.custom-gcl.yml |
Fixes extraneousnew plugin path and clarifies version comment. |
.golangci.yml |
Disables fmtpercentv in the enabled-linters list. |
tools/extraneousnew/extraneousnew.go |
Implements the extraneousnew analyzer plugin. |
tools/extraneousnew/extraneousnew_test.go |
Adds analysistest-based coverage for the analyzer. |
tools/extraneousnew/testdata/... |
Adds positive/negative test fixtures for analyzer diagnostics. |
tools/extraneousnew/go.mod / tools/extraneousnew/go.sum |
Adds a standalone module definition for the new plugin. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
This PR improves CI/dev lint tooling by caching the downloaded golangci-lint/custom-gcl binaries in GitHub Actions and making the custom-gcl setup script derive the golangci-lint version directly from .custom-gcl.yml. It also adds/updates the extraneousnew custom analyzer module referenced by the custom-gcl configuration.
Changes:
- Cache
bin/golangci-lintandbin/custom-gclin the linter GitHub Actions workflow, keyed off.custom-gcl.ymland tool sources. - Update
script/setup-custom-gcl.shto be repo-root-relative and to parse thegolangci-lintversion from.custom-gcl.yml. - Add the
tools/extraneousnewcustom analyzer module with analysistest-based coverage and testdata fixtures.
Reviewed changes
Copilot reviewed 3 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
.github/workflows/linter.yml |
Adds GHA caching for lint binaries to speed up repeated runs. |
script/setup-custom-gcl.sh |
Derives golangci-lint version from .custom-gcl.yml and uses repo-root ./bin. |
.custom-gcl.yml |
Updates plugin path for extraneousnew and clarifies version comment. |
tools/extraneousnew/extraneousnew.go |
Implements the extraneousnew analyzer logic. |
tools/extraneousnew/extraneousnew_test.go |
Adds analysistest harness for the analyzer. |
tools/extraneousnew/testdata/src/has-warnings/main.go |
Provides positive test cases for diagnostics. |
tools/extraneousnew/testdata/src/no-warnings/main.go |
Provides negative test cases ensuring no false reports. |
tools/extraneousnew/go.mod |
Declares the extraneousnew tool module and dependencies. |
tools/extraneousnew/go.sum |
Adds dependency checksums for the new tool module. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
8d290a7 to
8ac904a
Compare
Cache golangci-lint and custom-gcl in GitHub Actions. Derive the golangci-lint version in setup-custom-gcl.sh from .custom-gcl.yml. Key the cache from .custom-gcl.yml so version changes invalidate it.
Summary by CodeRabbit
Chores
Documentation