-
Notifications
You must be signed in to change notification settings - Fork 74
/
Makefile
79 lines (60 loc) · 2.11 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
# Name of this service/application
SERVICE_NAME := kubewebhook
SHELL := $(shell which bash)
GID := $(shell id -g)
UID := $(shell id -u)
COMMIT=$(shell git rev-parse --short HEAD)
# cmds
UNIT_TEST_CMD := ./hack/scripts/unit-test.sh
INTEGRATION_TEST_CMD := ./hack/scripts/run-integration.sh
MOCKS_CMD := ./hack/scripts/mockgen.sh
DOCKER_RUN_CMD := docker run -v ${PWD}:/src --rm -it $(SERVICE_NAME)
DEPS_CMD := go mod tidy
CHECK_CMD := ./hack/scripts/check.sh
help: ## Show this help.
@echo "Help"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-20s\033[93m %s\n", $$1, $$2}'
.PHONY: default
default: help
.PHONY: build
build: ## Build the development docker images.
docker build -t $(SERVICE_NAME) --build-arg uid=$(UID) --build-arg gid=$(GID) -f ./docker/dev/Dockerfile .
build-binary: ## Build production stuff.
$(DOCKER_RUN_CMD) /bin/sh -c '$(BUILD_BINARY_CMD)'
.PHONY: build-image
build-image: ## Build docker image.
$(BUILD_IMAGE_CMD)
.PHONY: unit-test
unit-test: build ## Execute unit tests.
$(DOCKER_RUN_CMD) /bin/sh -c '$(UNIT_TEST_CMD)'
.PHONY: integration-test
integration-test: build ## Execute integration tests.
$(INTEGRATION_TEST_CMD)
.PHONY: test ## Alias for unit-test
test: unit-test
.PHONY: check
check: build ## Runs checks.
@$(DOCKER_RUN_CMD) /bin/sh -c '$(CHECK_CMD)'
.PHONY: ci-unit-test
ci-unit-test: ## Same as unit-test but for CI.
$(UNIT_TEST_CMD)
.PHONY: ci-integration-test
ci-integration-test: ## Same as integration-tests but for CI.
$(INTEGRATION_TEST_CMD)
.PHONY: ci ## Execute all the tests for CI.
ci: ci-unit-test ci-integration-test
.PHONY: mocks
mocks: build ## Generate mocks.
$(DOCKER_RUN_CMD) /bin/sh -c '$(MOCKS_CMD)'
.PHONY: godoc
godoc: ## Run library docs.
godoc -http=":6060"
.PHONY: deps
deps: ## Setup dependencies.
$(DEPS_CMD)
.PHONY: create-integration-test-certs
integration-create-certs: ## Creates certificates for the integration test.
./test/integration/create-certs.sh
.PHONY: generate-integration-test-crd
integration-gen-crd: ## Generates CRDs for the integration test.
./test/integration/gen-crd.sh