From 431f6e607dd8e8f3dc550120dfdc8bb55f7fae6d Mon Sep 17 00:00:00 2001 From: Fran Leustek Date: Thu, 8 Jan 2026 21:11:49 +0100 Subject: [PATCH 1/5] add golangci-lint to pipeline --- .github/CONTRIBUTING.md | 36 +++++++++++++++++++++++++++++++ .github/workflows/golang-lint.yml | 36 +++++++++++++++++++++++++++++++ .golangci.yml | 1 - 3 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/golang-lint.yml diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 5c9f0bf1..f6e9e1ab 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -14,6 +14,7 @@ By participating in this project, you agree to abide by our [Code of Conduct](.g - [Pull Request Guidelines](#pull-request-guidelines) - [Commit Message Guidelines](#commit-message-guidelines) - [Testing](#testing) +- [Linting](#linting) - [Documentation](#documentation) - [Component-Specific Guidelines](#component-specific-guidelines) - [Backporting Changes](#backporting-changes) @@ -70,6 +71,41 @@ We recommend running tests locally to catch issues before opening a PR. --- +## Linting + +We use [golangci-lint](https://golangci-lint.run/) to enforce code quality standards. The linter runs automatically on all pull requests and will block merging if issues are found. + +### Running the Linter Locally + +```bash +# Run linting (will fail on errors) +make lint + +# Run linting with auto-fix for fixable issues +make lint-fix +``` + +### Configuration + +Linting rules are configured in `.golangci.yml` at the repository root. The configuration enables these linters: + +- **errcheck** - Check for unchecked errors +- **govet** - Report suspicious constructs +- **staticcheck** - Advanced static analysis +- **gofmt/goimports** - Code formatting +- **misspell** - Spelling errors in comments +- **revive** - Extensible linter with many rules +- **unused** - Find unused code +- And more (see `.golangci.yml` for the full list) + +### Best Practices + +- Run `make lint` before committing to catch issues early +- Use `make lint-fix` to automatically fix formatting issues +- If a lint rule seems incorrect for your use case, discuss it in the PR rather than disabling it + +--- + ## Documentation Contributions to documentation are highly valued. If you find any documentation gaps or errors: diff --git a/.github/workflows/golang-lint.yml b/.github/workflows/golang-lint.yml new file mode 100644 index 00000000..5d29992e --- /dev/null +++ b/.github/workflows/golang-lint.yml @@ -0,0 +1,36 @@ +name: golangci-lint + +on: + push: + branches: + - main + pull_request: + merge_group: + workflow_dispatch: + +permissions: + contents: read + pull-requests: read + +jobs: + golangci-lint: + name: golangci-lint + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: '1.22' + cache: true + + - name: Run golangci-lint + uses: golangci/golangci-lint-action@v6 + with: + version: v1.59.1 + args: --timeout=5m + # Use the existing .golangci.yml configuration + # Show only new issues for PRs + only-new-issues: true diff --git a/.golangci.yml b/.golangci.yml index aac8a13f..01945236 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -21,7 +21,6 @@ linters: enable: - dupl - errcheck - - exportloopref - ginkgolinter - goconst - gocyclo From 6f55c770e734b480c4232046260219ada8b10083 Mon Sep 17 00:00:00 2001 From: Fran Leustek Date: Thu, 8 Jan 2026 21:20:58 +0100 Subject: [PATCH 2/5] fix: update golangci-lint workflow for Go 1.24 --- .github/workflows/golang-lint.yml | 10 ++++++++-- Makefile | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/golang-lint.yml b/.github/workflows/golang-lint.yml index 5d29992e..9871dc50 100644 --- a/.github/workflows/golang-lint.yml +++ b/.github/workflows/golang-lint.yml @@ -23,13 +23,19 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: '1.22' + go-version-file: 'go.mod' cache: true + - name: Download dependencies + run: go mod download + + - name: Generate code + run: make generate + - name: Run golangci-lint uses: golangci/golangci-lint-action@v6 with: - version: v1.59.1 + version: v1.62.2 args: --timeout=5m # Use the existing .golangci.yml configuration # Show only new issues for PRs diff --git a/Makefile b/Makefile index bde821da..a78ef5a8 100644 --- a/Makefile +++ b/Makefile @@ -516,7 +516,7 @@ HELMIFY ?= helmify KUSTOMIZE_VERSION ?= v5.4.3 CONTROLLER_TOOLS_VERSION ?= v0.16.5 ENVTEST_VERSION ?= release-0.19 -GOLANGCI_LINT_VERSION ?= v1.59.1 +GOLANGCI_LINT_VERSION ?= v1.62.2 HELM_VERSION ?= v3.14.2 YQ_VERSION ?= v4.40.5 From a1ac000904ced21108962c98ed70a46f4d0df2ca Mon Sep 17 00:00:00 2001 From: Fran Leustek Date: Thu, 8 Jan 2026 21:24:33 +0100 Subject: [PATCH 3/5] fix: install golangci-lint from source for Go 1.24 compat --- .github/workflows/golang-lint.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/golang-lint.yml b/.github/workflows/golang-lint.yml index 9871dc50..eb223a84 100644 --- a/.github/workflows/golang-lint.yml +++ b/.github/workflows/golang-lint.yml @@ -35,8 +35,9 @@ jobs: - name: Run golangci-lint uses: golangci/golangci-lint-action@v6 with: + # Install from source to match Go 1.24 + install-mode: goinstall version: v1.62.2 args: --timeout=5m - # Use the existing .golangci.yml configuration # Show only new issues for PRs only-new-issues: true From 2c666a2caab8e681cc0fee94b4088086b3f41b0f Mon Sep 17 00:00:00 2001 From: Fran Leustek Date: Thu, 8 Jan 2026 21:36:34 +0100 Subject: [PATCH 4/5] rename golang-lint to golangci-lint --- .github/workflows/{golang-lint.yml => golangci-lint.yml} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename .github/workflows/{golang-lint.yml => golangci-lint.yml} (91%) diff --git a/.github/workflows/golang-lint.yml b/.github/workflows/golangci-lint.yml similarity index 91% rename from .github/workflows/golang-lint.yml rename to .github/workflows/golangci-lint.yml index eb223a84..e7e9a644 100644 --- a/.github/workflows/golang-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -18,12 +18,12 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout code - uses: actions/checkout@v4 + uses: actions/checkout@v4e - name: Set up Go uses: actions/setup-go@v5 with: - go-version-file: 'go.mod' + go-version-file: "go.mod" cache: true - name: Download dependencies From 8cff9354983ba58e90116b6da36b57c8fd3a8f8f Mon Sep 17 00:00:00 2001 From: Fran Leustek Date: Thu, 8 Jan 2026 21:37:37 +0100 Subject: [PATCH 5/5] fix typo --- .github/workflows/golangci-lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index e7e9a644..8a934e94 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -18,7 +18,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout code - uses: actions/checkout@v4e + uses: actions/checkout@v4 - name: Set up Go uses: actions/setup-go@v5