diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 5a3c788de5b..f3222929c35 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -46,8 +46,7 @@ jobs: - uses: ./.github/actions/install-system-dependencies - uses: ./.github/actions/install-go - uses: ./.github/actions/make-deps - - run: go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.59.0 - - run: golangci-lint run -v --timeout 10m --concurrency 4 + - run: make lint check-fmt: name: Check (gofmt) runs-on: ubuntu-latest diff --git a/Makefile b/Makefile index 6fabbb2b3e3..3d01eb8e3c1 100644 --- a/Makefile +++ b/Makefile @@ -16,6 +16,8 @@ $(warning Your Golang version is go$(shell expr $(GOVERSION) / 1000000).$(shell $(error Update Golang to version to at least $(shell cat GO_VERSION_MIN)) endif +GOLANGCI_LINT_VERSION=v1.59.0 + # git modules that need to be loaded MODULES:= @@ -283,6 +285,20 @@ unittests: ## Run unit tests @$(GOCC) test $(shell go list ./... | grep -v /lotus/itests) .PHONY: unittests +install-linter: + @if ! command -v golangci-lint >/dev/null 2>&1; then \ + echo "Installing golangci-lint $(GOLANGCI_LINT_VERSION)" && \ + go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION); \ + elif ! golangci-lint --version | grep -q "$(GOLANGCI_LINT_VERSION) "; then \ + echo "Updating golangci-lint to $(GOLANGCI_LINT_VERSION)" && \ + go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION); \ + fi +.PHONY: install-linter + +lint: install-linter + golangci-lint run --timeout 10m --concurrency 4 +.PHONY: lint + clean: ## Clean build artifacts rm -rf $(CLEAN) $(BINS) -$(MAKE) -C $(FFI_PATH) clean