-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathCustom.mk
More file actions
112 lines (84 loc) · 2.83 KB
/
Custom.mk
File metadata and controls
112 lines (84 loc) · 2.83 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
SOURCE := $(wildcard api/*/*.go controller/*.go ozctl/*.go ozctl/*/*.go)
ifeq (true,$(PUBLISH))
GORELEASER_FLAGS := --clean
else
GORELEASER_FLAGS := --snapshot --clean
endif
## Tool Binaries
REVIVE_VER ?= v1.3.1
REVIVE ?= $(LOCALBIN)/revive
GOLANGCI_VER ?= v1.63.4
GOLANGCI ?= $(LOCALBIN)/golangci-lint
GOFUMPT_VER ?= v0.5.0
GOFUMPT ?= $(LOCALBIN)/gofumpt
GOLINES_VER ?= v0.11.0
GOLINES ?= $(LOCALBIN)/golines
GORELEASER_VER ?= v2.12.5
GORELEASER ?= $(LOCALBIN)/goreleaser
GEN_CRD_API_DOCS_VER ?= v0.3.1-0.20220223025230-af7c5e0048a3
GEN_CRD_API_DOCS ?= $(LOCALBIN)/go-crd-api-reference-docs
goreleaser:
.PHONY: cover
cover:
go tool cover -func cover.out
.PHONY: coverhtml
coverhtml:
go tool cover -html cover.out
.PHONY: lint
lint: revive golangci-lint
$(REVIVE) -config revive.toml -formatter stylish ./...
$(GOLANGCI) run
.PHONY: test-e2e # you will need to have a Kind cluster up and running to run this target
test-e2e: cert-manager
go test ./internal/testing/e2e/ -v -ginkgo.v
.PHONY: cert-manager
cert-manager:
kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.10.1/cert-manager.yaml
.PHONY: goreleaser
goreleaser: $(GORELEASER)
$(GORELEASER):
GOBIN=$(LOCALBIN) go install github.com/goreleaser/goreleaser/v2@$(GORELEASER_VER)
.PHONY: gofumpt
gofumpt: $(GOFUMPT)
$(GOFUMPT):
GOBIN=$(LOCALBIN) go install mvdan.cc/gofumpt@$(GOFUMPT_VER)
.PHONY: golines
golines: $(GOLINES)
$(GOLINES):
GOBIN=$(LOCALBIN) go install github.com/segmentio/golines@$(GOLINES_VER)
.PHONY: fmt
fmt: $(GOFUMPT) $(GOLINES) ## Run go fmt against code.
$(GOFUMPT) -l -w .
$(GOLINES) -w .
.PHONY: revive
revive: $(REVIVE) ## Download revive locally if necessary.
$(REVIVE): $(LOCALBIN) Custom.mk
GOBIN=$(LOCALBIN) go install github.com/mgechev/revive@$(REVIVE_VER)
.PHONY: golangci-lint
golangci-lint: $(GOLANGCI)
$(GOLANGCI): $(LOCALBIN) Custom.mk
GOBIN=$(LOCALBIN) go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_VER)
.PHONY: release
release: $(GORELEASER)
IMG=$(IMG) $(GORELEASER) release $(GORELEASER_FLAGS)
.PHONY: build
build: $(GORELEASER)
PUBLISH=false $(MAKE) release dist/docker.tar
.PHONY: docker-load
docker-load: dist/docker.tar
docker load --input dist/docker.tar && kind load docker-image $(IMG)
dist/docker.tar:
docker save -o dist/docker.tar $(IMG)
.PHONY: docker-save
docker-save: dist/docker.tar
gen-crd-api-reference-docs: $(GEN_CRD_API_DOCS)
$(GEN_CRD_API_DOCS):
GOBIN=$(LOCALBIN) go install github.com/ahmetb/gen-crd-api-reference-docs@$(GEN_CRD_API_DOCS_VER)
.PHONY: godocs
godocs: $(GEN_CRD_API_DOCS)
bin/gen-crd-api-reference-docs \
-config ./gen-crd-api-reference-docs.json \
-api-dir ./internal/api/v1alpha1 \
-template-dir $$(go env GOMODCACHE)/github.com/ahmetb/gen-crd-api-reference-docs@$(GEN_CRD_API_DOCS_VER)/template \
-out-file API.md \
-v 5