From 691536f46bedc510ac669771ca6eb63d2bc67c8d Mon Sep 17 00:00:00 2001 From: appleboy Date: Fri, 11 Apr 2025 23:35:39 +0800 Subject: [PATCH] ci: revise golangci-lint configuration and update versioning - Update golangci-lint-action used version from `v6` to `v7` - Set specific golangci-lint version to `v2.0` instead of latest - Remove `run` section with timeout setting in `.golangci.yaml` - Eliminate multiple linters (`errcheck`, `gci`, `gofmt`, `goimports`) from `.golangci.yaml` - Change `linters-settings` to `settings` in `.golangci.yaml` - Add `int-conversion: true` to `perfsprint` settings - Add new exclusion settings for generated code, preset rules, and specific paths under `exclusions` in `.golangci.yaml` - Incorporate formatter settings with enabled formatters and exclusions for certain paths in `.golangci.yaml` Signed-off-by: appleboy --- .github/workflows/testing.yml | 4 +-- .golangci.yaml | 67 +++++++++++++++++++++-------------- 2 files changed, 42 insertions(+), 29 deletions(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 90d7206..3dacfc5 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -15,9 +15,9 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 - name: Setup golangci-lint - uses: golangci/golangci-lint-action@v6 + uses: golangci/golangci-lint-action@v7 with: - version: latest + version: v2.0 args: --verbose - uses: hadolint/hadolint-action@v3.1.0 diff --git a/.golangci.yaml b/.golangci.yaml index 2ee171b..c01d3c7 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -1,14 +1,9 @@ -run: - timeout: 5m +version: "2" linters: enable: - asciicheck - durationcheck - - errcheck - errorlint - - gci - - gofmt - - goimports - gosec - misspell - nakedret @@ -18,24 +13,42 @@ linters: - revive - usestdlibvars - wastedassign - -linters-settings: - gosec: - # To select a subset of rules to run. - # Available rules: https://github.com/securego/gosec#available-rules - # Default: [] - means include all rules - includes: - - G102 - - G106 - - G108 - - G109 - - G111 - - G112 - - G201 - - G203 - perfsprint: - err-error: true - errorf: true - int-conversion: true - sprintf1: true - strconcat: true + settings: + gosec: + includes: + - G102 + - G106 + - G108 + - G109 + - G111 + - G112 + - G201 + - G203 + perfsprint: + int-conversion: true + err-error: true + errorf: true + sprintf1: true + strconcat: true + exclusions: + generated: lax + presets: + - comments + - common-false-positives + - legacy + - std-error-handling + paths: + - third_party$ + - builtin$ + - examples$ +formatters: + enable: + - gci + - gofmt + - goimports + exclusions: + generated: lax + paths: + - third_party$ + - builtin$ + - examples$