diff --git a/.github/workflows/lint-go.yaml b/.github/workflows/lint-go.yaml index bdea07482..30eb70d7b 100644 --- a/.github/workflows/lint-go.yaml +++ b/.github/workflows/lint-go.yaml @@ -23,7 +23,8 @@ jobs: uses: golangci/golangci-lint-action@v3 with: version: v1.54 - args: --timeout=30m + # use the default if on main branch, otherwise use the pull request config + args: --timeout=30m --config=${{ github.event_name == 'pull_request' && '.golangci.pull-request.yml' || '.golangci.yml' }} only-new-issues: true skip-cache: true skip-pkg-cache: true diff --git a/.golangci.pull-request.yml b/.golangci.pull-request.yml new file mode 100644 index 000000000..4626647a3 --- /dev/null +++ b/.golangci.pull-request.yml @@ -0,0 +1,13 @@ +# Please refer to the official golangci-lint config documentation for more details: +# https://golangci-lint.run/usage/configuration/ +# https://github.com/golangci/golangci-lint/blob/master/.golangci.reference.yml + +linters: + enable-all: true + +run: + timeout: 10m + tests: false + +issues: + max-issues-per-linter: 1000 diff --git a/.golangci.yml b/.golangci.yml index 4626647a3..92c987a7d 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -3,7 +3,9 @@ # https://github.com/golangci/golangci-lint/blob/master/.golangci.reference.yml linters: - enable-all: true + disable: + - unused + - errcheck run: timeout: 10m diff --git a/Makefile b/Makefile index 117eb5d2f..91b76c140 100644 --- a/Makefile +++ b/Makefile @@ -55,10 +55,10 @@ test-coverage:| go_version_check #@ Run the tests with coverage @go tool cover -html=coverage.out lint_command_check: - @command -v golangci-lint || (echo "golangci-lint not found, please install it from https://golangci-lint.run/usage/install/") + @command -v golangci-lint || (echo "golangci-lint not found, please install it from https://golangci-lint.run/usage/install/" && exit 1) lint: | go_version_check lint_command_check #@ Run 'golangci-lint' on new code changes - @golangci-lint run --new + @golangci-lint run --new --config .golangci.pull-request.yml lint-all: | go_version_check lint_command_check #@ Run 'golangci-lint' on the entire codebase - @golangci-lint run + @golangci-lint run --config .golangci.yml