Skip to content

Commit

Permalink
Unify golangci-lint-version
Browse files Browse the repository at this point in the history
  • Loading branch information
nhatthm committed Aug 24, 2022
1 parent 855342f commit 66b465a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ on:
pull_request:

env:
GO111MODULE: "on"
GO_VERSION: "1.19.x"

jobs:
Expand All @@ -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
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
14 changes: 9 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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
Expand All @@ -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)

0 comments on commit 66b465a

Please sign in to comment.