Skip to content

chore: Use official golangci-lint-action#20

Closed
alexandear wants to merge 1 commit into
masterfrom
chore/use-golangci-lint-action
Closed

chore: Use official golangci-lint-action#20
alexandear wants to merge 1 commit into
masterfrom
chore/use-golangci-lint-action

Conversation

@alexandear
Copy link
Copy Markdown
Member

@alexandear alexandear commented Mar 23, 2026

Summary by CodeRabbit

  • Documentation

    • Updated example documentation to clarify encryption library references and type names.
  • Chores

    • Removed libsodium-based example module and implementation.
    • Updated GitHub Actions linter workflow to use golangci-lint-action with pinned version and experimental features enabled.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 23, 2026

Warning

Rate limit exceeded

@alexandear has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 10 minutes and 29 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: efd6e588-a8d2-47c9-b93b-893524b95ea7

📥 Commits

Reviewing files that changed from the base of the PR and between dcf7130 and 9fabd9d.

⛔ Files ignored due to path filters (1)
  • example/newreposecretwithlibsodium/go.sum is excluded by !**/*.sum
📒 Files selected for processing (3)
  • .github/workflows/linter.yml
  • example/newreposecretwithlibsodium/go.mod
  • example/newreposecretwithlibsodium/main.go
📝 Walkthrough

Walkthrough

This pull request modernizes the CI/CD linter workflow by replacing direct script-based linting with the official golangci/golangci-lint-action GitHub Action (v2.10.1), updates documentation comments in an example program to reference the correct encryption library, and removes a deprecated example module that relied on libsodium.

Changes

Cohort / File(s) Summary
Linter Workflow Update
.github/workflows/linter.yml
Replaces manual actions/cache and script/lint.sh execution with golangci/golangci-lint-action@v2.10.1, enabling experimental automatic-module-directories feature.
Example Documentation
example/newreposecret/main.go
Updates comments to rename program from newreposecretwithxcrypto to newreposecret and clarifies encryption method as x/crypto/nacl/box sealed-box instead of sodium reference.
Deprecated Example Removal
example/newreposecretwithlibsodium/go.mod, example/newreposecretwithlibsodium/main.go
Removes entire deprecated example module including Go module definition, dependencies (libsodium-go, go-github/v84), and the complete implementation (158 lines) that previously demonstrated libsodium-based secret encryption.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 The linter hops with GitHub's might,
Old sodium fades from sight,
Examples clean, docs gleam so bright,
With nacl/box we encrypt right,
Code springs forth, refreshed and light!

🚥 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 'chore: Use official golangci-lint-action' directly describes the main change across the changeset—replacing the manual linter implementation with the official golangci-lint GitHub Action in the workflow file.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ 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/use-golangci-lint-action

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.

@alexandear alexandear force-pushed the chore/use-golangci-lint-action branch 2 times, most recently from ec8db62 to b6ec9c1 Compare March 23, 2026 11:20
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 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 example module Go version directive and dependency set (notably sigstore-go version).

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.

Comment thread .github/workflows/linter.yml Outdated
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
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
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"

Copilot uses AI. Check for mistakes.
Comment thread .github/workflows/linter.yml Outdated
Comment on lines +37 to +41
- 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 }}
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Comment thread .github/workflows/linter.yml Outdated
if [ ! -f bin/custom-gcl ]; then
golangci-lint custom --name custom-gcl --destination bin
fi
bin/custom-gcl run
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

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

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).

Suggested change
bin/custom-gcl run
cd "${{ matrix.modules }}"
../bin/custom-gcl run

Copilot uses AI. Check for mistakes.
Comment thread go.work Outdated
@@ -0,0 +1,14 @@
go 1.25.5
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
go 1.25.5
go 1.25.0

Copilot uses AI. Check for mistakes.
Comment thread .github/workflows/linter.yml Outdated
Comment on lines +42 to +46
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
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
@alexandear alexandear force-pushed the chore/use-golangci-lint-action branch 2 times, most recently from eefac55 to 141aac8 Compare March 23, 2026 11:42
@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!

@alexandear alexandear force-pushed the chore/use-golangci-lint-action branch from 141aac8 to dcf7130 Compare March 23, 2026 11:52
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: 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

📥 Commits

Reviewing files that changed from the base of the PR and between a12b8d7 and dcf7130.

⛔ Files ignored due to path filters (1)
  • example/newreposecretwithlibsodium/go.sum is excluded by !**/*.sum
📒 Files selected for processing (4)
  • .github/workflows/linter.yml
  • example/newreposecret/main.go
  • example/newreposecretwithlibsodium/go.mod
  • example/newreposecretwithlibsodium/main.go
💤 Files with no reviewable changes (2)
  • example/newreposecretwithlibsodium/main.go
  • example/newreposecretwithlibsodium/go.mod

Comment thread .github/workflows/linter.yml Outdated
Comment thread .github/workflows/linter.yml Outdated
Comment on lines +17 to +20
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"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 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.yml

Repository: 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:

  • extraneousnew
  • fmtpercentv
  • sliceofpointers
  • structfield

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.

@alexandear alexandear force-pushed the chore/use-golangci-lint-action branch 2 times, most recently from 9912528 to 8f25dc5 Compare March 23, 2026 12:01
@alexandear alexandear force-pushed the chore/use-golangci-lint-action branch from 8f25dc5 to 9fabd9d Compare March 23, 2026 12:07
@alexandear alexandear closed this Mar 23, 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