-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
64 lines (49 loc) · 1.85 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
ROOT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
COMMIT:=$(shell git rev-list -1 HEAD)
VERSION:=$(COMMIT)
DATE:=$(shell date -uR)
BIN_NAME:=auth0-exporter
GOFLAGS:=-mod=readonly
GO_BUILD:=go build $(GOFLAGS)
KO_DOCKER_REPO:=ghcr.io/tfadeyi/auth0-exporter
export KO_DOCKER_REPO=$KO_DOCKER_REPO
# include files with the `// +build mock` annotation
TEST_TAGS:=-tags mock -coverprofile cover.out
.PHONY: build generate docs test build-all-platforms clean install-tools licenses lint
install-ci-tools:
go install github.com/swaggo/swag/cmd/[email protected]
go install github.com/matryer/[email protected]
go install github.com/google/go-licenses@c781b427440f8ea100841eefdd308e660d26d121
go install github.com/norwoodj/helm-docs/cmd/[email protected]
install-local-tools: install-ci-tools
go install github.com/goreleaser/[email protected]
go install github.com/golangci/golangci-lint/cmd/[email protected]
build:
cd $(ROOT_DIR) && $(GO_BUILD) -o builds/$(BIN_NAME) .
./builds/$(BIN_NAME)-$(GOOS)-$(GOARCH):
cd $(ROOT_DIR) && $(GO_BUILD) -o builds/$(BIN_NAME)-$(GOOS)-$(GOARCH) .
build-all-platforms:
$(MAKE) GOOS=linux GOARCH=amd64 ./builds/$(BIN_NAME)-linux-amd64
$(MAKE) GOOS=darwin GOARCH=amd64 ./builds/$(BIN_NAME)-darwin-amd64
$(MAKE) GOOS=windows GOARCH=amd64 ./builds/$(BIN_NAME)-windows-amd64
# generates all documentation: openapi spec, helm-docs
generate:
cd $(ROOT_DIR) && go generate ./... && \
helm-docs --chart-search-root=deploy/charts/
test: build
cd $(ROOT_DIR) && go test $(GOFLAGS) $(TEST_TAGS) ./...
coverage: test
go tool cover -html=cover.out -o cover.html
@echo "open ./cover.html to see coverage"
clean:
cd $(ROOT_DIR) && \
rm -rf ./builds && \
rm -rf kodata
lint:
golangci-lint run
format:
gofmt -l -s -w .
# generates the licenses used by the tool
licenses:
rm -rf kodata
go-licenses save . --save_path="kodata/licenses"