chore: Use official golangci-lint-action#20
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 (3)
📝 WalkthroughWalkthroughThis pull request modernizes the CI/CD linter workflow by replacing direct script-based linting with the official 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)
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 |
ec8db62 to
b6ec9c1
Compare
There was a problem hiding this comment.
Pull request overview
This PR updates the repository’s Go workspace/module setup and revises CI linting to use the official golangci/golangci-lint-action, aiming to lint multiple modules in a matrix.
Changes:
- Add a Go workspace (
go.work,go.work.sum) enumerating the repo’s multiple modules. - Update the linter GitHub Actions workflow to detect modules and run golangci-lint per module via a matrix.
- Adjust
examplemodule Go version directive and dependency set (notablysigstore-goversion).
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
go.work |
Introduces a workspace spanning root, examples, and tool modules. |
go.work.sum |
Adds workspace dependency checksums. |
example/go.mod |
Aligns Go directive and updates dependencies (incl. sigstore-go). |
example/go.sum |
Reflects example module dependency graph changes. |
.github/workflows/linter.yml |
Replaces script/lint.sh with module-detection + matrix linting using the official golangci-lint action. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| go-version: stable | ||
| cache-dependency-path: "**/go.sum" | ||
| - id: set-modules | ||
| run: echo "modules=$(go list -m -json | jq -s '.' | jq -c '[.[].Dir]')" >> $GITHUB_OUTPUT |
There was a problem hiding this comment.
The module detection command is likely not producing the intended list. go list -m -json (without args) typically outputs only the main module, and extracting .[].Dir yields absolute paths that are brittle to pass across jobs. Consider deriving module directories via go work edit -json (workspace use entries) or git ls-files '*go.mod' | xargs dirname, and emit repo-relative paths for the matrix.
| run: echo "modules=$(go list -m -json | jq -s '.' | jq -c '[.[].Dir]')" >> $GITHUB_OUTPUT | |
| run: | | |
| modules=$(git ls-files '*go.mod' | xargs -n1 dirname | sort -u | jq -R -s -c 'split("\n")[:-1]') | |
| echo "modules=$modules" >> "$GITHUB_OUTPUT" |
| - name: Setup golangci-lint ${{ matrix.modules }} | ||
| uses: golangci/golangci-lint-action@1e7e51e771db61008b38414a730f564565cf7c20 # v9.2.0 | ||
| with: | ||
| version: v2.10.1 # sync with version in .custom-gcl.yml | ||
| working-directory: ${{ matrix.modules }} |
There was a problem hiding this comment.
This step runs golangci-lint custom ..., but there is no prior step that installs a golangci-lint binary on the runner. Unless it happens implicitly elsewhere, this will fail before the action runs. Reuse script/setup-custom-gcl.sh (which downloads golangci-lint and builds custom-gcl) or add an explicit install/download of the pinned golangci-lint version before invoking golangci-lint custom, and cache the resulting binaries accordingly.
| if [ ! -f bin/custom-gcl ]; then | ||
| golangci-lint custom --name custom-gcl --destination bin | ||
| fi | ||
| bin/custom-gcl run |
There was a problem hiding this comment.
The workflow builds bin/custom-gcl, but then runs golangci/golangci-lint-action, which executes the standard golangci-lint binary. This repo’s .golangci.yml enables custom linters (e.g., extraneousnew, fmtpercentv, sliceofpointers, structfield) that depend on the custom build, so the action run will either skip those checks or error on unknown linters. To keep parity with current linting, run bin/custom-gcl run for each module (or configure the action to use the custom binary if it supports that).
| bin/custom-gcl run | |
| cd "${{ matrix.modules }}" | |
| ../bin/custom-gcl run |
| @@ -0,0 +1,14 @@ | |||
| go 1.25.5 | |||
There was a problem hiding this comment.
go.work uses go 1.25.5 while all the workspace modules’ go.mod files use go 1.25.0. Keeping these aligned avoids go work sync / go tooling rewriting the file and reduces confusion about the intended minimum Go version.
| go 1.25.5 | |
| go 1.25.0 |
| args: --help # hack to install golangci-lint without running it, since we will run the custom one instead | ||
| - name: Setup and run custom golangci-lint | ||
| run: | | ||
| if [ ! -f bin/custom-gcl ]; then | ||
| golangci-lint custom --name custom-gcl --destination bin |
There was a problem hiding this comment.
Previously this workflow ran script/lint.sh, which validates generated files (script/generate.sh --check) and (when CHECK_GITHUB_OPENAPI=1) validates openapi_operations.yaml. Switching to the golangci-lint action removes those checks from CI. If they’re still required, add equivalent steps/jobs alongside the linter action.
eefac55 to
141aac8
Compare
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
141aac8 to
dcf7130
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.github/workflows/linter.yml:
- Line 16: The step name currently uses an undefined matrix variable ("Setup
golangci-lint ${{ matrix.modules }}") which yields an empty string; either
remove the matrix interpolation from the step name (rename to a static "Setup
golangci-lint") or define a strategy.matrix (e.g., add a strategy.matrix.modules
list at the job level) so the interpolation is valid; locate the step with the
name "Setup golangci-lint ${{ matrix.modules }}" and apply one of these fixes to
ensure the step name is correct and the job either supports a matrix or uses a
fixed name.
- Around line 17-20: The workflow now uses golangci-lint-action but no longer
builds or runs the custom golangci-lint binary that provides plugins listed in
.custom-gcl.yml (extraneousnew, fmtpercentv, sliceofpointers, structfield), nor
runs OpenAPI validation; either (A) restore building and using the custom binary
by adding a step to run script/setup-custom-gcl.sh (or the previous
script/lint.sh) before golangci-lint-action and re-enable the metadata
validation step (script/metadata.sh update-openapi --validate) gated by the
CHECK_GITHUB_OPENAPI env var, or (B) if dropping is intentional, remove
.custom-gcl.yml and the plugin references from .golangci.yml and delete any
related comments about syncing versions so the workflow and configs are
consistent.
🪄 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: 981e0170-bbf8-41d2-909e-3021d1f02769
⛔ Files ignored due to path filters (1)
example/newreposecretwithlibsodium/go.sumis excluded by!**/*.sum
📒 Files selected for processing (4)
.github/workflows/linter.ymlexample/newreposecret/main.goexample/newreposecretwithlibsodium/go.modexample/newreposecretwithlibsodium/main.go
💤 Files with no reviewable changes (2)
- example/newreposecretwithlibsodium/main.go
- example/newreposecretwithlibsodium/go.mod
| uses: golangci/golangci-lint-action@1e7e51e771db61008b38414a730f564565cf7c20 # v9.2.0 | ||
| with: | ||
| version: v2.10.1 # sync with version in .custom-gcl.yml | ||
| experimental: "automatic-module-directories" |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Check if custom linter plugins are still referenced elsewhere
echo "=== Custom linter plugins in .custom-gcl.yml ==="
cat .custom-gcl.yml 2>/dev/null || echo "File not found"
echo ""
echo "=== OpenAPI validation in lint.sh ==="
rg -n "CHECK_GITHUB_OPENAPI|metadata.sh" script/lint.sh 2>/dev/null || echo "File not found"
echo ""
echo "=== .golangci.yml custom plugin references ==="
rg -n "extraneousnew|fmtpercentv|sliceofpointers|structfield" .golangci.yml 2>/dev/null || echo "No references found"Repository: alexandear-org/go-github
Length of output: 1347
🏁 Script executed:
cat -n .github/workflows/linter.ymlRepository: alexandear-org/go-github
Length of output: 864
Custom linter plugins and OpenAPI validation are silently dropped.
The previous workflow ran script/lint.sh, which built and executed a custom golangci-lint binary (custom-gcl) containing four custom plugins defined in .custom-gcl.yml:
extraneousnewfmtpercentvsliceofpointersstructfield
It also ran OpenAPI validation via script/metadata.sh update-openapi --validate when CHECK_GITHUB_OPENAPI was set.
The new workflow uses only golangci-lint-action with no step to build or initialize custom plugins. Although .golangci.yml references these plugins, they require compilation to function—which no longer happens. Additionally, there is no OpenAPI validation step.
The comment on line 19 ("sync with version in .custom-gcl.yml") is misleading, as the custom golangci-lint binary is never built or used.
If dropping these checks is intentional, please confirm and remove the .custom-gcl.yml file and plugin references from .golangci.yml. Otherwise, add a step to build custom plugins (e.g., using script/setup-custom-gcl.sh) and restore OpenAPI validation.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In @.github/workflows/linter.yml around lines 17 - 20, The workflow now uses
golangci-lint-action but no longer builds or runs the custom golangci-lint
binary that provides plugins listed in .custom-gcl.yml (extraneousnew,
fmtpercentv, sliceofpointers, structfield), nor runs OpenAPI validation; either
(A) restore building and using the custom binary by adding a step to run
script/setup-custom-gcl.sh (or the previous script/lint.sh) before
golangci-lint-action and re-enable the metadata validation step
(script/metadata.sh update-openapi --validate) gated by the CHECK_GITHUB_OPENAPI
env var, or (B) if dropping is intentional, remove .custom-gcl.yml and the
plugin references from .golangci.yml and delete any related comments about
syncing versions so the workflow and configs are consistent.
9912528 to
8f25dc5
Compare
8f25dc5 to
9fabd9d
Compare
Summary by CodeRabbit
Documentation
Chores
golangci-lint-actionwith pinned version and experimental features enabled.