-
Notifications
You must be signed in to change notification settings - Fork 9
/
Makefile
90 lines (70 loc) · 2.28 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
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
GOBIN=$(shell go env GOPATH)/bin
else
GOBIN=$(shell go env GOBIN)
endif
INIT_OPTS=init \
--workload-config .workloadConfig/workload.yaml \
--repo github.com/acme/acme-cnp-mgr \
--skip-go-version-check \
--controller-image controller:latest \
--enable-olm=true
CREATE_OPTS=create api \
--workload-config .workloadConfig/workload.yaml \
--resource \
--controller \
--enable-olm=true
define create_path
if [ ! -d $(1)/.workloadConfig ]; then\
mkdir -p $(1)/.workloadConfig;\
fi
endef
export BASE_DIR := $(shell pwd)
export OPERATOR_BUILDER_PATH := $(BASE_DIR)/bin
.PHONY: build install test debug
build_command = go build -o bin/operator-builder cmd/operator-builder/main.go
build:
$(call build_command)
install: build
sudo cp bin/operator-builder /usr/local/bin/operator-builder
#
# traditional testing
#
GOLANGCI_LINT_VERSION ?= v1.57.1
install-linter:
go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION)
lint:
golangci-lint run
test:
go test -cover -coverprofile=./bin/coverage.out ./...
test-coverage-view: test
go tool cover -html=./bin/coverage.out
test-commit:
test/scripts/commit-check-latest.sh
#
# debug testing with delve
#
TEST_WORKLOAD_PATH ?= test/cases/standalone
debug-clean:
rm -rf $(TEST_WORKLOAD_PATH)/*
debug-init: debug-clean
dlv debug ./cmd/operator-builder --wd $(TEST_WORKLOAD_PATH) -- $(INIT_OPTS)
debug-create:
dlv debug ./cmd/operator-builder --wd $(TEST_WORKLOAD_PATH) -- $(CREATE_OPTS)
debug: debug-init debug-create
#
# simple functional code generation testing outside of codebase itself
#
FUNC_TEST_PATH ?= /tmp/operator-builder-func-test
func-test-clean:
if [ -d $(FUNC_TEST_PATH) ]; then rm -rf $(FUNC_TEST_PATH)/*; fi
INIT_BUILD ?= true
func-test-init: func-test-clean
if [ "$(INIT_BUILD)" == "true" ]; then $(call build_command); fi
$(call create_path,$(FUNC_TEST_PATH))
cp -r $(BASE_DIR)/$(TEST_WORKLOAD_PATH)/.workloadConfig/* $(FUNC_TEST_PATH)/.workloadConfig ;
cd $(FUNC_TEST_PATH) && $(OPERATOR_BUILDER_PATH)/operator-builder $(INIT_OPTS)
func-test-create:
cd $(FUNC_TEST_PATH) && $(OPERATOR_BUILDER_PATH)/operator-builder $(CREATE_OPTS)
func-test: func-test-init func-test-create