Skip to content

ci: add golangci-lint GitHub Actions workflow#269

Merged
wu-sheng merged 8 commits intoapache:mainfrom
gofogo:add-lint-github-action
Apr 5, 2026
Merged

ci: add golangci-lint GitHub Actions workflow#269
wu-sheng merged 8 commits intoapache:mainfrom
gofogo:add-lint-github-action

Conversation

@ivankatliarchuk
Copy link
Copy Markdown
Contributor

@ivankatliarchuk ivankatliarchuk commented Apr 5, 2026

What:

  • New .github/workflows/lint.yaml — runs gofmt check and golangci-lint on PRs to main
  • GOLANGCI_LINT_VERSION extracted into a Makefile variable; workflow reads it from there — single source of truth

Why: Automates lint enforcement in CI so formatting/lint issues are caught on every PR without manual runs.

Current status
Screenshot 2026-04-05 at 12 11 21

Screenshot 2026-04-05 at 12 13 52

All three suppressions are legitimate. The //nolint:gosec comments are the correct approach here — the alternative of calling filepath.Clean() would give false safety (it doesn't prevent traversal, it just normalizes separators) and wouldn't address gosec's taint analysis anyway.

@wu-sheng wu-sheng requested review from Copilot and kezhenxu94 April 5, 2026 11:46
@wu-sheng wu-sheng added this to the 0.9.0 milestone Apr 5, 2026
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

Adds CI lint enforcement for Go code in GitHub Actions, and aligns the repository’s golangci-lint versioning so local/CI linting can share a single source of truth.

Changes:

  • Added a new GitHub Actions workflow to run gofmt checks and golangci-lint on PRs targeting main.
  • Centralized GOLANGCI_LINT_VERSION in the Makefile and wired the workflow to read from it.
  • Added targeted //nolint:gosec suppressions for intentional file operations flagged by gosec.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
.github/workflows/lint.yaml New PR-time lint workflow (gofmt + golangci-lint) reading version from Makefile.
Makefile Introduces GOLANGCI_LINT_VERSION and uses it for golangci-lint installation.
pkg/review/header.go Suppresses gosec warning for reading GitHub event payload path from env var.
pkg/header/fix.go Suppresses gosec warning for writing to files discovered by the tool.
pkg/deps/golang_test.go Suppresses gosec warning for temp file writes in tests.
commands/header_check.go Suppresses gosec warning for writing GitHub step summary file.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

exit 1
fi

- name: Read golangci-lint version from Makefile
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What do you think we just reuse the make lint here, so we don't need to all these setup because make lint already installs linter.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Should work as well. Probably even better without github action

Copy link
Copy Markdown
Member

@kezhenxu94 kezhenxu94 left a comment

Choose a reason for hiding this comment

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

Thank you!

@wu-sheng wu-sheng merged commit f8cba27 into apache:main Apr 5, 2026
2 checks passed
@ivankatliarchuk ivankatliarchuk deleted the add-lint-github-action branch April 6, 2026 07:50
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.

4 participants