Skip to content

Commit

Permalink
chore: integrate golangci-lint into makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
powerfooI committed Sep 21, 2023
1 parent 10644dc commit 9a4793d
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ ENVTEST_K8S_VERSION = 1.26.1
YQ_DOWNLOAD_URL = https://github.com/mikefarah/yq/releases/download/v4.35.1/yq_linux_amd64
SEMVER_DOWNLOAD_URL = https://raw.githubusercontent.com/fsaintjacques/semver-tool/master/src/semver

GOLANG_CI_VERSION ?= v1.54.2

# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
GOBIN=$(shell go env GOPATH)/bin
Expand Down Expand Up @@ -188,3 +190,19 @@ $(ENVTEST): $(LOCALBIN)

.PHONY: tools
tools: $(YQ) $(SEMVER)

.PHONY: GOLANGCI_LINT
GOLANGCI_LINT ?= $(LOCALBIN)/golangci-lint
$(GOLANG_LINT):
GOBIN=$(LOCALBIN) go install github.com/golangci/golangci-lint/cmd/golangci-lint@${GOLANG_CI_VERSION}

.PHONY: lint
lint: $(GOLANGCI_LINT) ## Run linting.
$(GOLANGCI_LINT) run -v --timeout=10m

.PHONY: commit-hook
commit-hook: $(GOLANGCI_LINT) ## Install commit hook.
touch .git/hooks/pre-commit
chmod +x .git/hooks/pre-commit
echo "#!/bin/sh" > .git/hooks/pre-commit
echo "make lint" >> .git/hooks/pre-commit

0 comments on commit 9a4793d

Please sign in to comment.