From a33d7467ef152aedeba7661f2aada4838b8bb5ab Mon Sep 17 00:00:00 2001 From: Ramkumar Chinchani Date: Sun, 23 Mar 2025 14:16:30 -0700 Subject: [PATCH] ci: enable golangci-lint Signed-off-by: Ramkumar Chinchani --- .github/workflows/golangci-lint.yaml | 50 +++++++++++++++++++ golangcilint.yaml | 75 ++++++++++++++++++++++++++++ 2 files changed, 125 insertions(+) create mode 100644 .github/workflows/golangci-lint.yaml create mode 100644 golangcilint.yaml diff --git a/.github/workflows/golangci-lint.yaml b/.github/workflows/golangci-lint.yaml new file mode 100644 index 0000000..ae222e5 --- /dev/null +++ b/.github/workflows/golangci-lint.yaml @@ -0,0 +1,50 @@ +name: golangci-lint +on: + push: + tags: + - v* + branches: + - main + pull_request: +permissions: + contents: read + # Optional: allow read access to pull request. Use with `only-new-issues` option. + # pull-requests: read +jobs: + golangci: + name: lint + runs-on: ubuntu-latest + steps: + - uses: actions/setup-go@v5 + with: + cache: false + go-version: '1.23' + - uses: actions/checkout@v4 + - name: Run linter with GH action + uses: golangci/golangci-lint-action@v6 + with: + # Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version + version: v1.64.8 + + # Optional: working directory, useful for monorepos + # working-directory: somedir + + # Optional: golangci-lint command line arguments. + # args: --issues-exit-code=0 + args: --config ./golangcilint.yaml --exclude-files ./pkg/verity/verity.go --enable-all ./cmd/... ./pkg/... + + # Optional: show only new issues if it's a pull request. The default value is `false`. + # only-new-issues: true + + # Optional: if set to true then the action don't cache or restore ~/go/pkg. + # skip-pkg-cache: true + # skip-pkg-cache: false + + # Optional: if set to true then the action don't cache or restore ~/.cache/go-build. + # skip-build-cache: true + - name: Run linter from make target + run: | + make check + - name: Run log linter + run: | + make check-logs diff --git a/golangcilint.yaml b/golangcilint.yaml new file mode 100644 index 0000000..9bfdc39 --- /dev/null +++ b/golangcilint.yaml @@ -0,0 +1,75 @@ +run: + timeout: 60m + +linters: + enable-all: true + disable: + - gomnd + - funlen + - gocognit + - paralleltest + - forbidigo + - ireturn + - wrapcheck + - exhaustive + - maintidx + - exhaustruct + - rowserrcheck + - sqlclosecheck + - revive + - musttag + - depguard + - execinquery + - inamedparam + - intrange + - promlinter + - protogetter + - contextcheck # needs to revisit: https://github.com/project-zot/zot/pull/2556 + - copyloopvar # needs to revisit: https://github.com/project-zot/zot/pull/2556 + - typecheck + - exportloopref + +linters-settings: + dupl: + threshold: 200 + nestif: + min-complexity: 26 + cyclop: + max-complexity: 40 + skip-tests: true + varnamelen: + check-return: true + ignore-type-assert-ok: true + ignore-map-index-ok: true + ignore-chan-recv-ok: true + ignore-names: + - err + - ok + - gc + - wg + ignore-decls: + - n int + - i int + - r *os.File + - w *os.File + - to int64 + gci: + sections: + - standard + - default + wsl: + allow-assign-and-anything: true + force-err-cuddling: true + nolintlint: + allow-unused: true + mnd: + checks: + - argument + - case + - condition + - operation + - return + - assign + ignored-numbers: + - "10" + - "64"