-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathMakefile
82 lines (70 loc) · 1.97 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
SHELL := /bin/bash
GOBIN := $(PWD)/bin
PATH := $(GOBIN):$(PATH)
CLUSTER_NAME ?= kubejob-cluster
KUBECONFIG ?= $(CURDIR)/.kube/config
export KUBECONFIG
export GOBIN
.PHONY: tools
tools:
go install sigs.k8s.io/[email protected]
go install github.com/bufbuild/buf/cmd/[email protected]
go install google.golang.org/protobuf/cmd/[email protected]
go install google.golang.org/grpc/cmd/[email protected]
cluster/create: tools
@{ \
set -e ;\
if [ "$$(kind get clusters --quiet | grep $(CLUSTER_NAME))" = "" ]; then \
$(GOBIN)/kind create cluster --name $(CLUSTER_NAME) --config testdata/config/cluster.yaml ;\
fi ;\
}
cluster/delete:
$(GOBIN)/kind delete clusters $(CLUSTER_NAME)
.PHONY: deploy
deploy: cluster/create deploy/image
kubectl apply -f testdata/config/manifest.yaml
deploy/image:
docker build --progress plain -f Dockerfile --target agent . -t 'kubejob:latest'
$(GOBIN)/kind load docker-image --name $(CLUSTER_NAME) 'kubejob:latest'
.PHONY: wait
wait:
{ \
set -e ;\
while true; do \
POD_NAME=$$(KUBECONFIG=$(KUBECONFIG) kubectl get pod | grep Running | grep kubejob-deployment | awk '{print $$1}'); \
if [ "$$POD_NAME" != "" ]; then \
exit 0; \
fi; \
sleep 1; \
done; \
}
.PHONY: test
test:
{ \
set -e ;\
while true; do \
POD_NAME=$$(KUBECONFIG=$(KUBECONFIG) kubectl get pod | grep Running | grep kubejob-deployment | awk '{print $$1}'); \
if [ "$$POD_NAME" != "" ]; then \
kubectl exec -it $$POD_NAME -- go test -v -coverprofile=coverage.out ./ -count=1 -timeout 0; \
exit $$?; \
fi; \
sleep 1; \
done; \
}
.PHONY: test-run
test-run:
{ \
set -e ;\
while true; do \
POD_NAME=$$(KUBECONFIG=$(KUBECONFIG) kubectl get pod | grep Running | grep kubejob-deployment | awk '{print $$1}'); \
if [ "$$POD_NAME" != "" ]; then \
kubectl exec -it $$POD_NAME -- go test -v -coverprofile=coverage.out ./ -count=1 -run $(TEST); \
exit $$?; \
fi; \
sleep 1; \
done; \
}
.PHONY: generate
generate: generate/buf
generate/buf:
$(GOBIN)/buf generate