-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
62 lines (46 loc) · 1.33 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
LOCALBIN := $(ROOT_DIR)/bin
OUT_DIR := $(ROOT_DIR)/out
GO ?= go
GOLANG_CI ?= $(GO) run -modfile $(ROOT_DIR)/hack/tools/golang-ci/go.mod github.com/golangci/golangci-lint/cmd/golangci-lint
IMG ?= namespace-lister:latest
IMAGE_BUILDER ?= docker
## Local Folders
$(LOCALBIN):
mkdir $(LOCALBIN)
$(OUT_DIR):
@mkdir $(OUT_DIR)
.PHONY: clean
clean: ## Delete local folders.
@-rm -r $(LOCALBIN)
@-rm -r $(OUT_DIR)
.PHONY: lint
lint: lint-go lint-yaml ## Run all linters.
.PHONY: lint-go
lint-go: ## Run golangci-lint to lint go code.
@$(GOLANG_CI) run ./...
.PHONY: lint-yaml
lint-yaml: ## Lint yaml manifests.
@yamllint .
.PHONY: vet
vet: ## Run go vet against code.
$(GO) vet ./...
.PHONY: tidy
tidy: ## Run go tidy against code.
$(GO) mod tidy
.PHONY: fmt
fmt: ## Run go fmt against code.
$(GO) fmt ./...
.PHONY: test
test: ## Run go test against code.
$(GO) test ./...
.PHONY: image-build
image-build:
$(IMAGE_BUILDER) build -t "$(IMG)" .
.PHONY: generate-code
generate-code: mockgen ## Run go generate on the project.
@echo $(GO) generate ./...
@PATH=$(LOCALBIN):${PATH} $(GO) generate ./...
.PHONY: mockgen
mockgen: $(LOCALBIN) ## Install mockgen locally.
$(GO) build -modfile $(ROOT_DIR)/hack/tools/mockgen/go.mod -o $(LOCALBIN)/mockgen go.uber.org/mock/mockgen