From bda149ecacd21b6c75440c6c2d04a3c0539a01c7 Mon Sep 17 00:00:00 2001 From: clarkchenc <651044554@qq.com> Date: Mon, 16 Jan 2023 18:12:53 +0800 Subject: [PATCH] linter: add linter for ci --- .github/workflows/ci.yml | 2 +- .github/workflows/lint.yml | 18 ++++++++++++++++++ .golangci.yaml | 28 ++++++++++++++++++++++++++++ Makefile | 2 +- 4 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/lint.yml create mode 100644 .golangci.yaml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7cd49f97..12ee6323 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,7 +9,7 @@ jobs: - name: Install Go uses: actions/setup-go@v1 with: - go-version: 1.16 + go-version: 1.17 - name: "Build binaries" run: make build - name: "Run tests" diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 00000000..506a2cf6 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,18 @@ +name: Lint Check + +on: [pull_request] +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Install Go + uses: actions/setup-go@v1 + with: + go-version: 1.17 + - name: "Run lint" + uses: golangci/golangci-lint-action@v3 + with: + version: v1.41 + args: --timeout=10m + only-new-issues: true \ No newline at end of file diff --git a/.golangci.yaml b/.golangci.yaml new file mode 100644 index 00000000..3230b6e0 --- /dev/null +++ b/.golangci.yaml @@ -0,0 +1,28 @@ +linters: + enable-all: true + disable: + - golint + - scopelint + - interfacer + - maligned + +service: + golangci-lint-version: 1.41 + +run: + skip-dirs: + - gov/simulation + - gov/client + - simulation + + skip-files: + - _test.go + - "test_.*" + +issues: + new: true + +linters-settings: + errcheck: + check-type-assertions: true + check-blank: false \ No newline at end of file diff --git a/Makefile b/Makefile index 35555901..7ee234dd 100644 --- a/Makefile +++ b/Makefile @@ -102,7 +102,7 @@ start-all: LINT_COMMAND := $(shell command -v golangci-lint 2> /dev/null) lint: ifndef LINT_COMMAND - curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOPATH)/bin v1.23.8 + go get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.41.1 endif golangci-lint run