1
1
SHELL := /bin/bash
2
- GOCMD =go
3
- GOTEST =$(GOCMD ) test
4
- GOVET =$(GOCMD ) vet
5
2
BINARY_NAME =nutanixclient
6
3
EXPORT_RESULT? =false # for CI please set EXPORT_RESULT to true
7
4
@@ -20,94 +17,54 @@ build: ## Build your project and put the output binary in bin/
20
17
mkdir -p bin
21
18
$(GOCMD ) build -o bin/$(BINARY_NAME ) .
22
19
23
- # go-get-tool will 'go install' any package $2 and install it to $1.
24
- # originally copied from kubebuilder
25
- define go-get-tool
26
- @[ -f $(1 ) ] || { \
27
- set -e ;\
28
- BIN_PATH=$$(realpath $$(dirname $(1 ) ) ) ;\
29
- PKG_BIN_NAME=$$(echo "$(2 ) " | sed 's,^.*/\(.*\ ) @v.*$$,\1,') ;\
30
- BIN_NAME=$$(basename $(1 ) ) ;\
31
- echo "Install dir $$BIN_PATH" ;\
32
- echo "Downloading $(2 ) " ;\
33
- GOBIN=$$BIN_PATH go install $(2 ) ;\
34
- [[ $$PKG_BIN_NAME == $$BIN_NAME ]] || mv -f $$BIN_PATH/$$PKG_BIN_NAME $$BIN_PATH/$$BIN_NAME ;\
35
- }
36
- endef
37
-
38
20
TOOLS_BIN_DIR := hack/tools/bin
39
21
40
22
$(TOOLS_BIN_DIR ) :
41
23
mkdir -p $(TOOLS_BIN_DIR )
42
24
43
- CONTROLLER_GEN_BIN := controller-gen
44
- CONTROLLER_GEN := $(TOOLS_BIN_DIR ) /$(CONTROLLER_GEN_BIN )
45
25
# CRD_OPTIONS define options to add to the CONTROLLER_GEN
46
26
CRD_OPTIONS ?= "crd:crdVersions=v1"
47
27
48
- $(CONTROLLER_GEN ) : $(TOOLS_BIN_DIR )
49
- $(call go-get-tool,$(CONTROLLER_GEN ) ,sigs.k8s.io/controller-tools/cmd/controller-gen@v0.14.0)
50
-
51
- KEPLOY_VER := v0.7.12
52
- KEPLOY_BIN := server-$(KEPLOY_VER )
53
- KEPLOY := $(TOOLS_BIN_DIR ) /$(KEPLOY_BIN )
54
- KEPLOY_PKG := go.keploy.io/server/cmd/server
55
-
56
- .PHONY : $(KEPLOY )
57
- $(KEPLOY ) : $(TOOLS_BIN_DIR )
58
- $(call go-get-tool,$(KEPLOY ) ,$(KEPLOY_PKG ) @$(KEPLOY_VER ) )
59
-
60
28
.PHONY : run-keploy
61
- run-keploy : $( KEPLOY )
62
- $( KEPLOY ) run &
29
+ run-keploy :
30
+ server run &
63
31
64
32
.PHONY : stop-keploy
65
33
stop-keploy :
66
- @-pkill " $( KEPLOY_BIN ) "
34
+ @-pkill " server "
67
35
68
36
generate : $(CONTROLLER_GEN ) # # Generate zz_generated.deepcopy.go
69
37
$(CONTROLLER_GEN ) paths=" ./..." object:headerFile=" hack/boilerplate.go.txt"
70
38
71
39
clean : # # Remove build related file
72
40
rm -fr ./bin vendor hack/tools/bin
73
- rm -f ./junit-report.xml checkstyle-report.xml ./coverage.xml ./profile.cov yamllint-checkstyle.xml
41
+ rm -f checkstyle-report.xml ./coverage.out ./profile.cov yamllint-checkstyle.xml
74
42
75
43
# # Test:
76
44
test : run-keploy # # Run the tests of the project
77
- ifeq ($(EXPORT_RESULT ) , true)
78
- go install github.com/jstemmer/go-junit-report
79
- $(eval OUTPUT_OPTIONS = | tee /dev/tty | go-junit-report -set-exit-code > junit-report.xml)
80
- endif
81
- $(GOTEST) -v -race ./... $(OUTPUT_OPTIONS)
45
+ go test -race -v ./...
82
46
@$(MAKE ) stop-keploy
83
47
84
48
coverage : run-keploy # # Run the tests of the project and export the coverage
85
- $(GOTEST ) -cover -covermode=count -coverprofile=profile.cov ./...
86
- $(GOCMD ) tool cover -func profile.cov
87
- ifeq ($(EXPORT_RESULT ) , true)
88
- go install github.com/AlekSi/gocov-xml
89
- go install github.com/axw/gocov/gocov
90
- gocov convert profile.cov | gocov-xml > coverage.xml
91
- endif
49
+ go test -race -coverprofile=coverage.out -covermode=atomic ./...
92
50
@$(MAKE ) stop-keploy
93
51
94
52
# # Lint:
95
53
lint : lint-go lint-yaml lint-kubebuilder # # Run all available linters
96
54
97
55
lint-go : # # Use golintci-lint on your project
98
56
$(eval OUTPUT_OPTIONS = $(shell [ "${EXPORT_RESULT}" == "true" ] && echo "--out-format checkstyle ./... | tee /dev/tty > checkstyle-report.xml" || echo "" ) )
99
- docker run --rm -v $( shell pwd) :/app -w /app golangci/golangci -lint:latest-alpine golangci-lint run --enable gofmt --fix --enable gofumpt $( OUTPUT_OPTIONS )
57
+ golangci-lint run -v
100
58
101
59
lint-yaml : # # Use yamllint on the yaml file of your projects
102
60
ifeq ($(EXPORT_RESULT ) , true)
103
- go install github.com/thomaspoignant/yamllint-checkstyle
104
61
$(eval OUTPUT_OPTIONS = | tee /dev/tty | yamllint-checkstyle > yamllint-checkstyle.xml)
105
62
endif
106
- docker run --rm -it -v $(shell pwd):/data cytopia/ yamllint -c yamllint-config.yaml -f parsable $(shell git ls-files '*.yml' '*.yaml') $(OUTPUT_OPTIONS)
63
+ yamllint -c . yamllint --no-warnings -f parsable $(shell git ls-files '*.yml' '*.yaml') $(OUTPUT_OPTIONS)
107
64
108
65
.PHONY : lint-kubebuilder
109
- lint-kubebuilder : $( CONTROLLER_GEN ) # # Lint Kubebuilder annotations by generating objects and checking if it is successful
110
- $( CONTROLLER_GEN ) $(CRD_OPTIONS ) rbac:roleName=manager-role webhook paths=" ./..." output:crd:artifacts:config=.
66
+ lint-kubebuilder : # # Lint Kubebuilder annotations by generating objects and checking if it is successful
67
+ controller-gen $(CRD_OPTIONS ) rbac:roleName=manager-role webhook paths=" ./..." output:crd:artifacts:config=.
111
68
112
69
# # Help:
113
70
help : # # Show this help.
0 commit comments