-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
93 lines (68 loc) · 2.55 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
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
GOLANGCI_VERSION = 1.62.0
HELM_DOCS_VERSION = 1.14.2
LICENCES_IGNORE_LIST = $(shell cat licenses/licenses-ignore-list.txt)
VERSION ?= 0.0.1
IMAGE_TAG_BASE ?= stackitcloud/stackit-cert-manager-webhook
IMG ?= $(IMAGE_TAG_BASE):$(VERSION)
BUILD_VERSION ?= $(shell git branch --show-current)
BUILD_COMMIT ?= $(shell git rev-parse --short HEAD)
BUILD_TIMESTAMP ?= $(shell date -u '+%Y-%m-%d %H:%M:%S')
PWD = $(shell pwd)
export PATH := $(PWD)/bin:$(PATH)
download:
go mod download
.PHONY: build
build:
CGO_ENABLED=0 go build -ldflags "-s -w" -o ./bin/stackit-cert-manager-webhook -v cmd/webhook/main.go
.PHONY: docker-build
docker-build:
docker build -t $(IMG) -f Dockerfile .
test:
go test -race ./...
mocks:
go generate ./...
GOLANGCI_LINT = bin/golangci-lint-$(GOLANGCI_VERSION)
$(GOLANGCI_LINT):
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | bash -s -- -b bin v$(GOLANGCI_VERSION)
@mv bin/golangci-lint "$(@)"
lint: $(GOLANGCI_LINT) download
$(GOLANGCI_LINT) run -v
HELM_DOCS = bin/helm-docs
$(HELM_DOCS):
GOBIN=$(PWD)/bin go install github.com/norwoodj/helm-docs/cmd/helm-docs@v$(HELM_DOCS_VERSION)
helm-docs: $(HELM_DOCS)
$(HELM_DOCS)
out:
@mkdir -pv "$(@)"
reports:
@mkdir -pv "$(@)/licenses"
coverage: out
go test -race ./... -coverprofile=out/cover.out
html-coverage: out/report.json
go tool cover -html=out/cover.out
.PHONY: out/report.json
out/report.json:
go test -race ./... -coverprofile=out/cover.out --json | tee "$(@)"
test-e2e:
@STACKIT_TOKEN=$(STACKIT_TOKEN) TEST_ZONE_NAME=$(TEST_ZONE_NAME) go test -race -tags=e2e ./... -coverprofile out/cover.out
run:
go run cmd/webhook/main.go
.PHONY: clean
clean:
rm -rf ./bin
rm -rf ./out
GO_RELEASER = bin/goreleaser
$(GO_RELEASER):
GOBIN=$(PWD)/bin go install github.com/goreleaser/goreleaser@latest
.PHONY: release-check
release-check: $(GO_RELEASER) ## Check if the release will work
GITHUB_SERVER_URL=github.com GITHUB_REPOSITORY=stackitcloud/stackit-cert-manager-webhook REGISTRY=$(REGISTRY) IMAGE_NAME=$(IMAGE_NAME) $(GO_RELEASER) release --snapshot --clean --skip-publish
GO_LICENSES = bin/go-licenses
$(GO_LICENSES):
GOBIN=$(PWD)/bin go install github.com/google/go-licenses
.PHONY: license-check
license-check: $(GO_LICENSES) reports ## Check licenses against code.
$(GO_LICENSES) check --include_tests --ignore $(LICENCES_IGNORE_LIST) ./...
.PHONY: license-report
license-report: $(GO_LICENSES) reports ## Create licenses report against code.
$(GO_LICENSES) report --include_tests --ignore $(LICENCES_IGNORE_LIST) ./... > ./reports/licenses/licenses-list.csv