Skip to content

chore: Cache custom golangci-lint binaries in GHA workflow#19

Closed
alexandear wants to merge 1 commit into
masterfrom
chore/cache-custom-gcl
Closed

chore: Cache custom golangci-lint binaries in GHA workflow#19
alexandear wants to merge 1 commit into
masterfrom
chore/cache-custom-gcl

Conversation

@alexandear
Copy link
Copy Markdown
Member

@alexandear alexandear commented Mar 19, 2026

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

    • CI now caches lint tool binaries to speed up repeated workflow runs.
    • Development setup now reads the linter/tool version from repository config, uses repository-relative paths, and fails early if the version cannot be determined.
  • Documentation

    • Clarified linter version wording in repository config and added a brief doc comment describing the go-github library version.

@alexandear alexandear requested a review from Copilot March 19, 2026 11:33
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 19, 2026

Warning

Rate limit exceeded

@alexandear has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 12 minutes and 14 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5f49d441-b475-4029-8d19-577eda34266c

📥 Commits

Reviewing files that changed from the base of the PR and between 8d290a7 and 8ac904a.

⛔ Files ignored due to path filters (1)
  • tools/extraneousnew/go.sum is excluded by !**/*.sum
📒 Files selected for processing (8)
  • .custom-gcl.yml
  • .github/workflows/linter.yml
  • script/setup-custom-gcl.sh
  • tools/extraneousnew/extraneousnew.go
  • tools/extraneousnew/extraneousnew_test.go
  • tools/extraneousnew/go.mod
  • tools/extraneousnew/testdata/src/has-warnings/main.go
  • tools/extraneousnew/testdata/src/no-warnings/main.go
📝 Walkthrough

Walkthrough

Read golangci-lint version from .custom-gcl.yml, adjust a plugin path, change setup script to use repo-root bin and derive version dynamically, and add a GitHub Actions cache for the lint binaries.

Changes

Cohort / File(s) Summary
GolangCI config
\.custom-gcl.yml
Updated version comment to state it's the golangci-lint version; changed plugin path from ./tools/extraneous-new to ./tools/extraneousnew.
Setup script
script/setup-custom-gcl.sh
Compute ROOT_DIR from script location, set BIN="$ROOT_DIR/bin", read GOLANGCI_LINT_VERSION from $ROOT_DIR/.custom-gcl.yml (strip comments/quotes/whitespace), and error if version not found.
CI workflow
.github/workflows/linter.yml
Added actions/cache step to cache bin/golangci-lint and bin/custom-gcl; cache key includes runner OS/arch and a hash of .custom-gcl.yml plus tools/**/go.mod, tools/**/go.sum, and tools/**/*.go.
Docs / Const
github/github.go
Added a documentation comment describing the exported Version constant (value unchanged).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇 I sniffed the YAML and found the version clear,
I hopped to root and set the bin quite near,
Caches stash the carrots for faster tries,
A plugin path un-tangled, neat and wise,
The rabbit nods: linting's ready — cheer!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: caching custom golangci-lint binaries in the GitHub Actions workflow, which is the primary objective of this PR.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/cache-custom-gcl
📝 Coding Plan
  • Generate coding plan for human review comments

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.

❤️ Share

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

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_VERSION in script/setup-custom-gcl.sh from .custom-gcl.yml and install binaries into a repo-root bin/.
  • Add a GitHub Actions cache step for bin/golangci-lint and bin/custom-gcl, keyed off .custom-gcl.yml.
  • Update .custom-gcl.yml comment to clarify the purpose of version:.

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.

Comment thread script/setup-custom-gcl.sh Outdated
Comment thread .github/workflows/linter.yml Outdated
@codecov-commenter
Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 19c1a8a and e70f07c.

📒 Files selected for processing (3)
  • .custom-gcl.yml
  • .github/workflows/linter.yml
  • script/setup-custom-gcl.sh

Comment thread script/setup-custom-gcl.sh Outdated
@alexandear alexandear requested a review from Copilot March 19, 2026 11:52
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-lint and bin/custom-gcl, keyed off .custom-gcl.yml (and selected plugin sources).
  • Updated script/setup-custom-gcl.sh to locate the repo root and extract the golangci-lint version from .custom-gcl.yml.
  • Added the tools/extraneousnew custom 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.

Comment thread .github/workflows/linter.yml Outdated
@alexandear alexandear requested a review from Copilot March 19, 2026 12:12
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-lint and bin/custom-gcl in the linter GitHub Actions workflow, keyed off .custom-gcl.yml and tool sources.
  • Update script/setup-custom-gcl.sh to be repo-root-relative and to parse the golangci-lint version from .custom-gcl.yml.
  • Add the tools/extraneousnew custom 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.

@alexandear alexandear force-pushed the chore/cache-custom-gcl branch from 8d290a7 to 8ac904a Compare March 19, 2026 12:50
@alexandear alexandear closed this Mar 21, 2026
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.

3 participants