Skip to content

Commit 2b1bc54

Browse files
committed
Makefile improvements
1 parent 03cf51f commit 2b1bc54

File tree

2 files changed

+11
-15
lines changed

2 files changed

+11
-15
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
vendor*
22
cover.out
3+
bin/
34

45
# IDE baggage
56
.idea/

Makefile

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
1-
SOURCE_DIRS = handler leader predicate status
21
SOURCES := $(shell find . -name '*.go' -not -path "*/vendor/*" -not -path "*/.git/*")
32
.DEFAULT_GOAL := build
43

5-
# ensure: ## Install or update project dependencies
6-
# @dep ensure
7-
84
build: $(SOURCES) ## Build Test
95
go build -i -ldflags="-s -w" ./...
106

@@ -15,38 +11,37 @@ lint-fix: golangci-lint ## Run golangci lint to automatically perform fixes
1511
@$(GOLANGCI_LINT) run --fix
1612

1713
fmt: ## Run go fmt
18-
@gofmt -d $(SOURCES)
14+
@go fmt ./...
1915

2016
fmtcheck: ## Check go formatting
2117
@gofmt -l $(SOURCES) | grep ".*\.go"; if [ "$$?" = "0" ]; then exit 1; fi
2218

2319
test: ## Run unit tests
24-
@go test -race -covermode atomic -coverprofile cover.out $(addprefix ./, $(addsuffix /... , $(SOURCE_DIRS)))
20+
@go test -race -covermode atomic -coverprofile cover.out ./...
2521

2622
vet: ## Run go vet
27-
@go vet $(addprefix ./, $(SOURCE_DIRS))
23+
@go vet ./...
2824

2925
tidy: ## Tidy go dependencies
3026
@go mod tidy
3127

32-
check-license: $(SOURCES)
28+
check-license: $(SOURCES) ## Check license headers
3329
@./hack/check-license.sh "$(SOURCES)"
3430

3531
check: tidy fmtcheck vet lint build test check-license ## Pre-flight checks before creating PR
3632
@git diff --exit-code
3733

3834
clean: ## Clean up your working environment
39-
@rm -f coverage-all.out coverage.out
35+
@rm -f cover.out
4036

37+
GOLANGCI_LINT=./bin/golangci-lint
38+
GOLANGCI_LINT_VER=1.30.0
4139
golangci-lint:
42-
ifeq (, $(shell which golangci-lint))
40+
ifneq ($(GOLANGCI_LINT_VER), $(shell $(GOLANGCI_LINT) version 2>&1 | cut -d" " -f4))
4341
@{ \
4442
set -e ;\
45-
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell go env GOPATH)/bin v1.29.0 ;\
43+
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b bin v$(GOLANGCI_LINT_VER) ;\
4644
}
47-
GOLANGCI_LINT=$(shell go env GOPATH)/bin/golangci-lint
48-
else
49-
GOLANGCI_LINT=$(shell which golangci-lint)
5045
endif
5146

5247
# generate: ## regenerate mocks
@@ -61,4 +56,4 @@ help: ## Show this help screen
6156
@grep -E '^[ a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | \
6257
awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
6358

64-
.PHONY: ensure build lint fmt fmtcheck test vet check help clean
59+
.PHONY: build lint lint-fix fmt fmtcheck test vet tidy check-license check clean golangci-lint help

0 commit comments

Comments
 (0)