@@ -24,6 +24,15 @@ model_url:=https://github.com/openshift-online/ocm-api-model.git
24
24
# Details of the metamodel to use:
25
25
metamodel_version: =v0.0.59
26
26
27
+ MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST ) ) )
28
+ PROJECT_PATH := $(patsubst % /,% ,$(dir $(MKFILE_PATH ) ) )
29
+ LOCAL_BIN_PATH := $(PROJECT_PATH ) /bin
30
+ # Add the project-level bin directory into PATH. Needed in order
31
+ # for `go generate` to use project-level bin directory binaries first
32
+ export PATH := $(LOCAL_BIN_PATH ) :$(PATH )
33
+ GINKGO := $(LOCAL_BIN_PATH ) /ginkgo
34
+ METAMODEL := $(LOCAL_BIN_PATH ) /metamodel
35
+
27
36
# Additional flags to pass to the `ginkgo` command. This is used in the GitHub
28
37
# actions environment to skip tests that are sensitive to the speed of the
29
38
# machine: the leadership flag and retry tests.
@@ -36,9 +45,18 @@ examples:
36
45
go build $$ {i} || exit 1; \
37
46
done
38
47
48
+ .PHONY : ginkgo-install
49
+ ginkgo-install :
50
+ @GOBIN=
$(LOCAL_BIN_PATH ) go install github.com/onsi/ginkgo/v2/
[email protected]
51
+
52
+ # Needed for the golang metamodel generator.
53
+ .PHONY : goimports-install
54
+ goimports-install :
55
+ @GOBIN=
$(LOCAL_BIN_PATH ) go install golang.org/x/tools/cmd/
[email protected]
56
+
39
57
.PHONY : test tests
40
- test tests :
41
- ginkgo run -r $(ginkgo_flags )
58
+ test tests : ginkgo-install
59
+ $( GINKGO ) run -r $(ginkgo_flags )
42
60
43
61
.PHONY : fmt
44
62
fmt :
50
68
golangci-lint run
51
69
52
70
.PHONY : generate
53
- generate : model metamodel
71
+ generate : model metamodel goimports-install
54
72
rm -rf \
55
73
accountsmgmt \
56
74
addonsmgmt \
@@ -65,11 +83,11 @@ generate: model metamodel
65
83
webrca \
66
84
osdfleetmgmt \
67
85
openapi
68
- metamodel generate go \
86
+ $( METAMODEL ) generate go \
69
87
--model=model/model \
70
88
--base=github.com/openshift-online/ocm-sdk-go \
71
89
--output=.
72
- metamodel generate openapi \
90
+ $( METAMODEL ) generate openapi \
73
91
--model=model/model \
74
92
--output=openapi
75
93
@@ -87,11 +105,11 @@ model:
87
105
88
106
.PHONY : metamodel
89
107
metamodel :
90
- go install github.com/openshift-online/ocm-api-metamodel/cmd/metamodel@$(metamodel_version )
108
+ @GOBIN= $( LOCAL_BIN_PATH ) go install github.com/openshift-online/ocm-api-metamodel/cmd/metamodel@$(metamodel_version )
91
109
92
110
.PHONY : clean
93
111
clean :
94
112
rm -rf \
95
- metamodel \
113
+ bin \
96
114
model \
97
115
$(NULL )
0 commit comments