Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
119 lines (93 loc) Β· 3.43 KB
/
Copy pathMakefile
File metadata and controls
119 lines (93 loc) Β· 3.43 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
113
114
115
116
117
118
119
.DEFAULT_GOAL := build
VERSION ?= latest
# Go variables
GO ?= go
GO_RELEASER ?= $(GO_TOOL) github.com/goreleaser/goreleaser/v2
GO_LINT ?= $(GO_TOOL) github.com/golangci/golangci-lint/v2/cmd/golangci-lint
GO_TOOL ?= $(GO) tool
GO_TEST ?= $(GO_TOOL) gotest.tools/gotestsum --format pkgname
GO_AIR ?= $(GO_TOOL) github.com/air-verse/air
GO_KIND ?= $(GO_TOOL) sigs.k8s.io/kind/cmd/kind
# HELM
HELM_INDEX ?= $(GO_TOOL) github.com/zeiss/pkg/cmd/helm/index
HELM_PACKAGE ?= $(GO_TOOL) github.com/zeiss/pkg/cmd/helm/package
HELM_RELEASE ?= $(GO_TOOL) github.com/zeiss/pkg/cmd/helm/release
HELM_UPDATE ?= $(GO_TOOL) github.com/zeiss/pkg/cmd/helm/update
# Variables
CLUSTER_NAME ?= kind-builder
CLUSTER_CONFIG ?= cluster.yaml
.PHONY: build
build: ## Build the binary file.
$(GO_RELEASER) build --snapshot --clean
.PHONY: release
release: ## Release the binary file.
$(GO_RELEASER) release --clean
.PHONY: release-server
release-server: ## Release the server binary file.
$(GO_RELEASER) release --clean --config .goreleaser.server.yml
.PHONY: nightly
nightly: ## Release the nightly binary file.
$(GO_RELEASER) release --clean --config .goreleaser-nightly.yml --skip validate,announce
.PHONY: generate
generate: ## Generate code.
$(GO) run api/gen.go openapi > api/api.yml
$(GO) generate ./...
.PHONY: mocks
mocks: ## Generate mocks.
$(GO_TOOL) github.com/vektra/mockery/v2
.PHONY: dex
dex: ## Generate mocks.
$(GO_TOOL) github.com/dexidp/dex/cmd/dex serve dex-dev.yml
.PHONY: fmt
fmt: ## Run go fmt against code.
$(GO_TOOL) mvdan.cc/gofumpt -w .
.PHONY: air
air: ## Run air.
$(GO_AIR) -c .air.toml
.PHONY: start
start: air ## Run the application.
.PHONY: helm/update
helm/update: ## Update helm dependencies.
$(GO_HELM_UPDATE) --file helm/Chart.yaml --version ${RELEASE_VERSION}
.PHONY: cluster-create
cluster-create: ## Create a local Kubernetes cluster using kind.
$(GO_KIND) create cluster --config $(CLUSTER_CONFIG)
@echo "β
Kind cluster created successfully."
.PHONY: cluster-delete
cluster-delete: ## Destroy the local Kubernetes cluster using kind.
$(GO_KIND) delete cluster --name $(CLUSTER_NAME)
@echo "β
Kind cluster destroyed successfully."
.PHONY: cluster-export
cluster-export: ## Export the kind cluster configuration.
$(GO_KIND) export kubeconfig --name $(CLUSTER_NAME)
@echo "β
Kind cluster configuration exported successfully."
.PHONY: cluster-install
cluster-install: ## Install the application on the local Kubernetes cluster.
helm upgrade --install builder ./helm \
--namespace my-namespace \
--create-namespace
@echo "β
Application installed successfully."
.PHONY: vet
vet: ## Run go vet against code.
$(GO) vet ./...
.PHONY: test
test: fmt vet ## Run tests.
mkdir -p .test/reports
$(GO_TEST) --junitfile .test/reports/unit-test.xml -- -race ./... -count=1 -short -cover -coverprofile .test/reports/unit-test-coverage.out
.PHONY: lint
lint: fmt ## Run lint.
$(GO_LINT) run --timeout 5m -c .golangci.yml
.PHONY: fix
fix: ## Run lint auto-fixes.
$(GO_LINT) run --fix --timeout 5m -c .golangci.yml
.PHONY: secret
secret: ## Generate a new secret.
openssl rand -base64 12
.PHONY: clean
clean: ## Remove previous build.
@rm -rf .test .dist
@find . -type f -name '*.gen.go' -exec rm {} +
@git checkout go.mod
.PHONY: help
help: ## Display this help screen.
@grep -E '^[a-z.A-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'