-
Notifications
You must be signed in to change notification settings - Fork 13
/
Makefile
128 lines (98 loc) · 3.37 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
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
120
121
122
123
124
125
126
127
128
# Set Shell to bash, otherwise some targets fail with dash/zsh etc.
SHELL := /bin/bash
.SHELLFLAGS := -eu -o pipefail -c
# Disable built-in rules
MAKEFLAGS += --no-builtin-rules
MAKEFLAGS += --no-builtin-variables
.SUFFIXES:
.SECONDARY:
.DEFAULT_GOAL := help
# extensible array of targets. Modules can add target to this variable for the all-in-one target.
clean_targets := build-clean release-clean
test_targets := test-unit
# General variables
include Makefile.vars.mk
# Following includes do not print warnings or error if files aren't found
# Optional Documentation module.
-include docs/docs.mk
# Optional kind module
-include kind/kind.mk
# Optional Helm chart module
-include charts/charts.mk
# Local Env & testing
include test/integration.mk test/e2e.mk test/media.mk
# UI
include ui/ui.mk
.PHONY: help
help: ## Show this help
@grep -E -h '\s##\s' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
.PHONY: build
build: build-ui build-docker ## All-in-one build
.PHONY: build-bin
build-bin: export CGO_ENABLED = 0
build-bin: fmt vet ## Build binary
@go build $(go_build_args) -o $(BIN_FILENAME) .
.PHONY: build-docker
build-docker: build-bin ## Build docker image
$(DOCKER_CMD) build -t $(CONTAINER_IMG) .
build-clean: ## Deletes binary and docker image
rm -rf $(BIN_FILENAME) dist/ cover.out
$(DOCKER_CMD) rmi $(CONTAINER_IMG) || true
.PHONY: test
test: $(test_targets) ## All-in-one test
.PHONY: test-unit
test-unit: ## Run unit tests against code
go test -race -coverprofile cover.out -covermode atomic ./...
.PHONY: fmt
fmt: ## Run 'go fmt' against code
go fmt ./...
.PHONY: vet
vet: ## Run 'go vet' against code
go vet ./...
.PHONY: lint
lint: lint-go lint-ui git-diff ## All-in-one linting
.PHONY: lint-go
lint-go: fmt vet generate ## Run linting for Go code
.PHONY: git-diff
git-diff:
@echo 'Check for uncommitted changes ...'
git diff --exit-code
.PHONY: generate
generate: generate-go generate-docs ## All-in-one code generation
.PHONY: generate-go
generate-go: ## Generate Go artifacts
@go generate ./...
.PHONY: generate-docs
generate-docs: generate-go ## Generate example code snippets for documentation
.PHONY: install-crd
install-crd: export KUBECONFIG = $(KIND_KUBECONFIG)
install-crd: generate kind-setup ## Install CRDs into cluster
kubectl apply -f package/crds
.PHONY: install-samples
install-samples: export KUBECONFIG = $(KIND_KUBECONFIG)
install-samples: kind-setup ## Install samples into cluster
yq ./samples/*.yaml | kubectl apply -f -
.PHONY: delete-samples
delete-samples: export KUBECONFIG = $(KIND_KUBECONFIG)
delete-samples: kind-setup
yq ./samples/*.yaml | kubectl delete --ignore-not-found -f -
.PHONY: run-operator
run-operator: ## Run in Operator mode against your current kube context
go run . -v 1 operator
.PHONY: run-webui
run-webui: ## Run in webui mode on localhost:8080
go run . -v 1 webui
.PHONY: run
run: ## Run webui and vite in local mode
$(MAKE) -j 2 run-webui run-ui
.PHONY: release-prepare
release-prepare: .github/crds.yaml .github/ui.tar.gz ## Prepares artifacts for releases
.PHONY: release-clean
release-clean:
rm -rf .github/ui.tar.gz .github/crds.yaml
.github/crds.yaml: generate-go
@cat package/crds/*.yaml | yq > .github/crds.yaml
.github/ui.tar.gz: build-ui
@tar -czf .github/ui.tar.gz ui/dist
.PHONY: clean
clean: $(clean_targets) ## All-in-one target to cleanup local artifacts