forked from spotahome/kooper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
85 lines (70 loc) · 2.41 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
# Name of this service/application
SERVICE_NAME := kooper
# Path of the go service inside docker
DOCKER_GO_SERVICE_PATH := /go/src/github.com/spotahome/kooper
# Shell to use for running scripts
SHELL := $(shell which bash)
# Get docker path or an empty string
DOCKER := $(shell command -v docker)
# Get the main unix group for the user running make (to be used by docker-compose later)
GID := $(shell id -g)
# Get the unix user id for the user running make (to be used by docker-compose later)
UID := $(shell id -u)
# cmds
UNIT_TEST_CMD := ./hack/scripts/unit-test.sh
INTEGRATION_TEST_CMD := ./hack/scripts/integration-test.sh
CI_INTEGRATION_TEST_CMD := ./hack/scripts/integration-test-minikube.sh
MOCKS_CMD := ./hack/scripts/mockgen.sh
DOCKER_RUN_CMD := docker run -v ${PWD}:$(DOCKER_GO_SERVICE_PATH) --rm -it $(SERVICE_NAME)
RUN_EXAMPLE_POD_ECHO := go run ./examples/echo-pod-controller/cmd/* --development
RUN_EXAMPLE_POD_ECHO_ONEFILE := go run ./examples/onefile-echo-pod-controller/main.go --development
RUN_EXAMPLE_POD_TERM := go run ./examples/pod-terminator-operator/cmd/* --development
# environment dirs
DEV_DIR := docker/dev
# The default action of this Makefile is to build the development docker image
.PHONY: default
default: build
# Test if the dependencies we need to run this Makefile are installed
.PHONY: deps-development
deps-development:
ifndef DOCKER
@echo "Docker is not available. Please install docker"
@exit 1
endif
# Build the development docker image
.PHONY: build
build:
docker build -t $(SERVICE_NAME) --build-arg uid=$(UID) --build-arg gid=$(GID) -f ./docker/dev/Dockerfile .
# Test stuff in dev
.PHONY: unit-test
unit-test: build
$(DOCKER_RUN_CMD) /bin/sh -c '$(UNIT_TEST_CMD)'
.PHONY: integration-test
integration-test: build
echo "[WARNING] Requires a kubernetes cluster configured (and running) on your kubeconfig!!"
$(INTEGRATION_TEST_CMD)
.PHONY: test
test: unit-test
# Test stuff in ci
.PHONY: ci-unit-test
ci-unit-test:
$(UNIT_TEST_CMD)
.PHONY: ci-integration-test
ci-integration-test:
$(CI_INTEGRATION_TEST_CMD)
.PHONY: ci
ci: ci-unit-test ci-integration-test
# Mocks stuff in dev
.PHONY: mocks
mocks: build
$(DOCKER_RUN_CMD) /bin/sh -c '$(MOCKS_CMD)'
# Run examples.
.PHONY: controller-example
controller-example:
$(RUN_EXAMPLE_POD_ECHO)
.PHONY: controller-example-onefile
controller-example-onefile:
$(RUN_EXAMPLE_POD_ECHO_ONEFILE)
.PHONY: operator-example
operator-example:
$(RUN_EXAMPLE_POD_TERM)