diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 9eab991..451166e 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -1,5 +1,7 @@ name: lint on: + push: + branches: [ main ] pull_request: branches: [ main ] @@ -8,6 +10,8 @@ jobs: runs-on: [self-hosted, pod] steps: - uses: actions/checkout@v3 + with: + fetch-depth: 0 - uses: andstor/file-existence-action@v2 id: check_files @@ -19,12 +23,17 @@ jobs: docker run --rm -v /usr/local:/sys_usr_local registry.smtx.io/sdn-base/golang:1.20 cp -r /usr/local/go /sys_usr_local/ echo "PATH=${PATH}:/usr/local/go/bin" >> $GITHUB_ENV - - uses: golangci/golangci-lint-action@v3 - if: steps.check_files.outputs.files_exists == 'true' + - name: setup golangci-lint from oci image + run: | + sudo docker run --rm -v /usr/local:/sys_usr_local registry.smtx.io/everoute/golangci-lint:1.62.2 cp -r /golangci-lint /sys_usr_local/bin/ + + - uses: everoute/golangci-lint-action@v5 with: - version: v1.52 - skip-pkg-cache: true - skip-build-cache: true # skip cache because of flaky behaviors + install-mode: none + skip-cache: true + only-new-issues: true + env: + GOPROXY: http://goproxy.smartx.com|https://goproxy.cn|direct generate-check: runs-on: [self-hosted, pod] diff --git a/.golangci.yml b/.golangci.yml index 38926cf..6695633 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -2,7 +2,10 @@ linters-settings: errcheck: # [deprecated] comma-separated list of pairs of the form pkg:regex # the regex is used to ignore names within pkg. (default "fmt:.*"). - ignore: fmt:.*,io/ioutil:^Read.*,io:Close + exclude-functions: + - fmt:.* + - io/ioutil:^Read.* + - io:Close lll: line-length: 170 funlen: @@ -12,7 +15,9 @@ linters-settings: run: timeout: 10m issues-exit-code: 1 - skip-files: + +issues: + exclude-files: - ".*_test.go$" - ".*generate.*.go$" @@ -21,12 +26,11 @@ linters: disable-all: true enable: - bodyclose - - deadcode - depguard - dogsled - dupl - errcheck - - exportloopref + - copyloopvar - funlen - goconst - gocritic @@ -45,10 +49,8 @@ linters: - nolintlint - rowserrcheck - staticcheck - - structcheck - stylecheck - typecheck - unconvert - unused - - varcheck - whitespace