2
2
MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST ) ) )
3
3
PROJECT_PATH := $(patsubst % /,% ,$(dir $(MKFILE_PATH ) ) )
4
4
PROJECT_BIN := $(PROJECT_PATH ) /bin
5
+ GO := $(PROJECT_BIN ) /go1.19
5
6
6
7
# add tools bin directory
7
8
PATH := $(PROJECT_BIN ) :$(PATH )
@@ -56,7 +57,7 @@ api/grpc/ml_metadata/proto/metadata_store_service.proto:
56
57
sed -i ' s#syntax = "proto[23]";#&\noption go_package = "github.com/kubeflow/model-registry/internal/ml_metadata/proto";#' metadata_store_service.proto
57
58
58
59
internal/ml_metadata/proto/% .pb.go : api/grpc/ml_metadata/proto/% .proto
59
- protoc -I./api/grpc --go_out=./internal --go_opt=paths=source_relative \
60
+ bin/ protoc -I./api/grpc --go_out=./internal --go_opt=paths=source_relative \
60
61
--go-grpc_out=./internal --go-grpc_opt=paths=source_relative $<
61
62
62
63
.PHONY : gen/grpc
@@ -76,8 +77,8 @@ openapi/validate: bin/openapi-generator-cli
76
77
# generate the openapi server implementation
77
78
.PHONY : gen/openapi-server
78
79
gen/openapi-server : bin/openapi-generator-cli openapi/validate
79
- @if git diff --cached --name-only | grep -q " api/openapi/model-registry.yaml" || \
80
- git diff --name-only | grep -q " api/openapi/model-registry.yaml" || \
80
+ @if git diff --exit-code --name-only | grep -q " api/openapi/model-registry.yaml" || \
81
+ git diff --exit-code -- name-only | grep -q " api/openapi/model-registry.yaml" || \
81
82
[ -n " ${FORCE_SERVER_GENERATION} " ]; then \
82
83
ROOT_FOLDER=" ." ./scripts/gen_openapi_server.sh; \
83
84
else \
@@ -97,7 +98,7 @@ pkg/openapi/client.go: bin/openapi-generator-cli api/openapi/model-registry.yaml
97
98
98
99
.PHONY : vet
99
100
vet :
100
- go vet ./...
101
+ ${GO} vet ./...
101
102
102
103
.PHONY : clean
103
104
clean :
@@ -107,22 +108,29 @@ clean:
107
108
clean/odh :
108
109
rm -Rf ./model-registry
109
110
111
+ bin/go :
112
+ GOBIN=$(PROJECT_BIN ) go install golang.org/dl/go1.19@latest
113
+ $(PROJECT_BIN ) /go1.19 download
114
+
115
+ bin/protoc :
116
+ ./scripts/install_protoc.sh
117
+
110
118
bin/go-enum :
111
- GOBIN=
$(PROJECT_BIN ) go install github.com/searKing/golang/tools/
[email protected]
119
+ GOBIN=
$(PROJECT_BIN ) ${GO} install github.com/searKing/golang/tools/
[email protected]
112
120
113
121
bin/protoc-gen-go :
114
- GOBIN=
$(PROJECT_BIN ) go install google.golang.org/protobuf/cmd/
[email protected]
122
+ GOBIN=
$(PROJECT_BIN ) ${GO} install google.golang.org/protobuf/cmd/
[email protected]
115
123
116
124
bin/protoc-gen-go-grpc :
117
- GOBIN=
$(PROJECT_BIN ) go install google.golang.org/grpc/cmd/
[email protected]
125
+ GOBIN=
$(PROJECT_BIN ) ${GO} install google.golang.org/grpc/cmd/
[email protected]
118
126
119
127
GOLANGCI_LINT ?= ${PROJECT_BIN}/golangci-lint
120
128
bin/golangci-lint :
121
129
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(PROJECT_BIN ) v1.54.2
122
130
123
131
GOVERTER ?= ${PROJECT_BIN}/goverter
124
132
bin/goverter :
125
- GOBIN=
$(PROJECT_PATH ) /bin
go install github.com/jmattheis/goverter/cmd/
[email protected]
133
+ GOBIN=
$(PROJECT_PATH ) /bin
${GO} install github.com/jmattheis/goverter/cmd/
[email protected]
126
134
127
135
OPENAPI_GENERATOR ?= ${PROJECT_BIN}/openapi-generator-cli
128
136
NPM ?= "$(shell which npm) "
@@ -147,23 +155,23 @@ clean/deps:
147
155
rm -Rf bin/*
148
156
149
157
.PHONY : deps
150
- deps : bin/go-enum bin/protoc-gen-go bin/protoc-gen-go-grpc bin/golangci-lint bin/goverter bin/openapi-generator-cli
158
+ deps : bin/go bin/protoc bin/go -enum bin/protoc-gen-go bin/protoc-gen-go-grpc bin/golangci-lint bin/goverter bin/openapi-generator-cli
151
159
152
160
.PHONY : vendor
153
161
vendor :
154
- go mod vendor
162
+ ${GO} mod vendor
155
163
156
164
.PHONY : build
157
165
build : gen vet lint
158
- go build
166
+ ${GO} build -buildvcs=false
159
167
160
168
.PHONY : build/odh
161
169
build/odh : vet
162
- go build
170
+ ${GO} build -buildvcs=false
163
171
164
172
.PHONY : gen
165
173
gen : deps gen/grpc gen/openapi gen/openapi-server gen/converter
166
- go generate ./...
174
+ ${GO} generate ./...
167
175
168
176
.PHONY : lint
169
177
lint :
@@ -172,20 +180,20 @@ lint:
172
180
173
181
.PHONY : test
174
182
test : gen
175
- go test ./internal/... ./pkg/...
183
+ ${GO} test ./internal/... ./pkg/...
176
184
177
185
.PHONY : test-nocache
178
186
test-nocache : gen
179
- go test ./internal/... ./pkg/... -count=1
187
+ ${GO} test ./internal/... ./pkg/... -count=1
180
188
181
189
.PHONY : test-cover
182
190
test-cover : gen
183
- go test ./internal/... ./pkg/... -coverprofile=coverage.txt
184
- go tool cover -html=coverage.txt -o coverage.html
191
+ ${GO} test ./internal/... ./pkg/... -coverprofile=coverage.txt
192
+ ${GO} tool cover -html=coverage.txt -o coverage.html
185
193
186
194
.PHONY : run/proxy
187
195
run/proxy : gen
188
- go run main.go proxy --logtostderr=true
196
+ ${GO} run main.go proxy --logtostderr=true
189
197
190
198
.PHONY : proxy
191
199
proxy : build
0 commit comments