From 6dc1fd00e01d2a94eee51290ae91f69b9513d9ba Mon Sep 17 00:00:00 2001 From: Robert Zaremba Date: Mon, 8 Nov 2021 10:24:22 +0000 Subject: [PATCH] chore: golangci-linter github action setup (#10475) ## Description Closes: #10474 --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [ ] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable) --- .github/workflows/lint.yml | 10 +++++++--- Makefile | 4 ++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index a205981912b2..09daa1b4d91a 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -14,7 +14,7 @@ jobs: steps: - uses: actions/setup-go@v2.1.4 with: - go-version: 1.16 + go-version: 1.17 - uses: technote-space/get-diff-action@v5 id: git_diff with: @@ -22,6 +22,10 @@ jobs: **/**.go go.mod go.sum - - name: run go linters - run: make lint-go + - name: golangci-lint + uses: golangci/golangci-lint-action@v2 + with: + version: latest + args: --out-format=tab + skip-go-installation: true if: env.GIT_DIFF diff --git a/Makefile b/Makefile index dadbf36df299..f19650b347a9 100644 --- a/Makefile +++ b/Makefile @@ -344,7 +344,7 @@ markdownLintImage=tmknom/markdownlint containerMarkdownLint=$(PROJECT_NAME)-markdownlint containerMarkdownLintFix=$(PROJECT_NAME)-markdownlint-fix -golangci_lint_cmd=go run github.com/golangci/golangci-lint/cmd/golangci-lint +golangci_lint_cmd=golangci-lint lint: lint-go @if docker ps -a --format '{{.Names}}' | grep -Eq "^${containerMarkdownLint}$$"; then docker start -a $(containerMarkdownLint); else docker run --name $(containerMarkdownLint) -i -v "$(CURDIR):/work" $(markdownLintImage); fi @@ -354,7 +354,7 @@ lint-fix: @if docker ps -a --format '{{.Names}}' | grep -Eq "^${containerMarkdownLintFix}$$"; then docker start -a $(containerMarkdownLintFix); else docker run --name $(containerMarkdownLintFix) -i -v "$(CURDIR):/work" $(markdownLintImage) . --fix; fi lint-go: - echo $(GIT_DIFF) + @@test -n "$$golangci-lint version | awk '$4 >= 1.42')" $(golangci_lint_cmd) run --out-format=tab $(GIT_DIFF) .PHONY: lint lint-fix