diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index d9e783b..24bad65 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -7,7 +7,6 @@ on: pull_request: env: - GO111MODULE: "on" GO_VERSION: "1.19.x" jobs: @@ -22,11 +21,15 @@ jobs: with: go-version: ${{ env.GO_VERSION }} - - name: golangci-lint + - id: get-lint-version + run: | + make golangci-lint-version + + - name: lint uses: golangci/golangci-lint-action@v3 with: # Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version. - version: v1.48.0 + version: ${{ steps.get-lint-version.outputs.GOLANGCI_LINT_VERSION }} # Optional: working directory, useful for monorepos # working-directory: somedir diff --git a/.gitignore b/.gitignore index cb00a7e..04bd755 100644 --- a/.gitignore +++ b/.gitignore @@ -11,7 +11,6 @@ # Output of the go coverage tool, specifically when used with LiteIDE *.out -bin # Dependency directories (remove the comment below to include it) /vendor diff --git a/Makefile b/Makefile index 2abf7f6..2042a13 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ VENDOR_DIR = vendor GOLANGCI_LINT_VERSION ?= v1.48.0 GO ?= go -GOLANGCI_LINT ?= golangci-lint-$(GOLANGCI_LINT_VERSION) +GOLANGCI_LINT ?= $(shell go env GOPATH)/bin/golangci-lint-$(GOLANGCI_LINT_VERSION) .PHONY: $(VENDOR_DIR) $(VENDOR_DIR): @@ -13,8 +13,8 @@ $(VENDOR_DIR): @$(GO) mod tidy .PHONY: lint -lint: bin/$(GOLANGCI_LINT) $(VENDOR_DIR) - @bin/$(GOLANGCI_LINT) run -c .golangci.yaml +lint: $(GOLANGCI_LINT) $(VENDOR_DIR) + @$(GOLANGCI_LINT) run -c .golangci.yaml .PHONY: test test: test-unit @@ -35,7 +35,11 @@ gen: @rm -rf test/grpctest @protoc --go_out=. --go-grpc_out=. resources/protobuf/service.proto -bin/$(GOLANGCI_LINT): +.PHONY: golangci-lint-version +golangci-lint-version: + @echo "::set-output name=GOLANGCI_LINT_VERSION::$(GOLANGCI_LINT_VERSION)" + +$(GOLANGCI_LINT): @echo "$(OK_COLOR)==> Installing golangci-lint $(GOLANGCI_LINT_VERSION)$(NO_COLOR)"; \ curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b ./bin "$(GOLANGCI_LINT_VERSION)" - @mv ./bin/golangci-lint bin/$(GOLANGCI_LINT) + @mv ./bin/golangci-lint $(GOLANGCI_LINT)