-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
More controlled environment in the build
Signed-off-by: Andrea Peruffo <[email protected]>
- Loading branch information
Showing
6 changed files
with
70 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
bin | ||
include |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,3 +34,7 @@ log.html | |
output.xml | ||
report.html | ||
__pycache__ | ||
|
||
# Protoc files | ||
include/ | ||
readme.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST))) | ||
PROJECT_PATH := $(patsubst %/,%,$(dir $(MKFILE_PATH))) | ||
PROJECT_BIN := $(PROJECT_PATH)/bin | ||
GO := $(PROJECT_BIN)/go1.19 | ||
|
||
# add tools bin directory | ||
PATH := $(PROJECT_BIN):$(PATH) | ||
|
@@ -56,7 +57,7 @@ api/grpc/ml_metadata/proto/metadata_store_service.proto: | |
sed -i 's#syntax = "proto[23]";#&\noption go_package = "github.com/kubeflow/model-registry/internal/ml_metadata/proto";#' metadata_store_service.proto | ||
|
||
internal/ml_metadata/proto/%.pb.go: api/grpc/ml_metadata/proto/%.proto | ||
protoc -I./api/grpc --go_out=./internal --go_opt=paths=source_relative \ | ||
bin/protoc -I./api/grpc --go_out=./internal --go_opt=paths=source_relative \ | ||
--go-grpc_out=./internal --go-grpc_opt=paths=source_relative $< | ||
|
||
.PHONY: gen/grpc | ||
|
@@ -76,8 +77,8 @@ openapi/validate: bin/openapi-generator-cli | |
# generate the openapi server implementation | ||
.PHONY: gen/openapi-server | ||
gen/openapi-server: bin/openapi-generator-cli openapi/validate | ||
@if git diff --cached --name-only | grep -q "api/openapi/model-registry.yaml" || \ | ||
git diff --name-only | grep -q "api/openapi/model-registry.yaml" || \ | ||
@if git diff --exit-code --name-only | grep -q "api/openapi/model-registry.yaml" || \ | ||
git diff --exit-code --name-only | grep -q "api/openapi/model-registry.yaml" || \ | ||
[ -n "${FORCE_SERVER_GENERATION}" ]; then \ | ||
ROOT_FOLDER="." ./scripts/gen_openapi_server.sh; \ | ||
else \ | ||
|
@@ -97,7 +98,7 @@ pkg/openapi/client.go: bin/openapi-generator-cli api/openapi/model-registry.yaml | |
|
||
.PHONY: vet | ||
vet: | ||
go vet ./... | ||
${GO} vet ./... | ||
|
||
.PHONY: clean | ||
clean: | ||
|
@@ -107,22 +108,29 @@ clean: | |
clean/odh: | ||
rm -Rf ./model-registry | ||
|
||
bin/go: | ||
GOBIN=$(PROJECT_BIN) go install golang.org/dl/go1.19@latest | ||
$(PROJECT_BIN)/go1.19 download | ||
|
||
bin/protoc: | ||
./scripts/install_protoc.sh | ||
|
||
bin/go-enum: | ||
GOBIN=$(PROJECT_BIN) go install github.com/searKing/golang/tools/[email protected] | ||
GOBIN=$(PROJECT_BIN) ${GO} install github.com/searKing/golang/tools/[email protected] | ||
|
||
bin/protoc-gen-go: | ||
GOBIN=$(PROJECT_BIN) go install google.golang.org/protobuf/cmd/[email protected] | ||
GOBIN=$(PROJECT_BIN) ${GO} install google.golang.org/protobuf/cmd/[email protected] | ||
|
||
bin/protoc-gen-go-grpc: | ||
GOBIN=$(PROJECT_BIN) go install google.golang.org/grpc/cmd/[email protected] | ||
GOBIN=$(PROJECT_BIN) ${GO} install google.golang.org/grpc/cmd/[email protected] | ||
|
||
GOLANGCI_LINT ?= ${PROJECT_BIN}/golangci-lint | ||
bin/golangci-lint: | ||
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(PROJECT_BIN) v1.54.2 | ||
|
||
GOVERTER ?= ${PROJECT_BIN}/goverter | ||
bin/goverter: | ||
GOBIN=$(PROJECT_PATH)/bin go install github.com/jmattheis/goverter/cmd/[email protected] | ||
GOBIN=$(PROJECT_PATH)/bin ${GO} install github.com/jmattheis/goverter/cmd/[email protected] | ||
|
||
OPENAPI_GENERATOR ?= ${PROJECT_BIN}/openapi-generator-cli | ||
NPM ?= "$(shell which npm)" | ||
|
@@ -147,23 +155,23 @@ clean/deps: | |
rm -Rf bin/* | ||
|
||
.PHONY: deps | ||
deps: bin/go-enum bin/protoc-gen-go bin/protoc-gen-go-grpc bin/golangci-lint bin/goverter bin/openapi-generator-cli | ||
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 | ||
|
||
.PHONY: vendor | ||
vendor: | ||
go mod vendor | ||
${GO} mod vendor | ||
|
||
.PHONY: build | ||
build: gen vet lint | ||
go build | ||
${GO} build -buildvcs=false | ||
|
||
.PHONY: build/odh | ||
build/odh: vet | ||
go build | ||
${GO} build -buildvcs=false | ||
|
||
.PHONY: gen | ||
gen: deps gen/grpc gen/openapi gen/openapi-server gen/converter | ||
go generate ./... | ||
${GO} generate ./... | ||
|
||
.PHONY: lint | ||
lint: | ||
|
@@ -172,20 +180,20 @@ lint: | |
|
||
.PHONY: test | ||
test: gen | ||
go test ./internal/... ./pkg/... | ||
${GO} test ./internal/... ./pkg/... | ||
|
||
.PHONY: test-nocache | ||
test-nocache: gen | ||
go test ./internal/... ./pkg/... -count=1 | ||
${GO} test ./internal/... ./pkg/... -count=1 | ||
|
||
.PHONY: test-cover | ||
test-cover: gen | ||
go test ./internal/... ./pkg/... -coverprofile=coverage.txt | ||
go tool cover -html=coverage.txt -o coverage.html | ||
${GO} test ./internal/... ./pkg/... -coverprofile=coverage.txt | ||
${GO} tool cover -html=coverage.txt -o coverage.html | ||
|
||
.PHONY: run/proxy | ||
run/proxy: gen | ||
go run main.go proxy --logtostderr=true | ||
${GO} run main.go proxy --logtostderr=true | ||
|
||
.PHONY: proxy | ||
proxy: build | ||
|
@@ -204,7 +212,7 @@ endif | |
# build docker image | ||
.PHONY: image/build | ||
image/build: | ||
${DOCKER} build . -f ${DOCKERFILE} -t ${IMG}:$(IMG_VERSION) | ||
${DOCKER} build . -f ${DOCKERFILE} -t ${IMG}:$(IMG_VERSION) --network host | ||
|
||
# push docker image | ||
.PHONY: image/push | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#! /bin/bash | ||
set -euxo pipefail | ||
|
||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) | ||
|
||
VERSION="24.3" | ||
OS="linux" | ||
if [[ "$OSTYPE" == "darwin"* ]]; then | ||
# Mac OSX | ||
OS="osx" | ||
fi | ||
# TODO: support for arm | ||
ARCH="x86_64" | ||
|
||
mkdir -p ${SCRIPT_DIR}/../bin | ||
|
||
wget -q https://github.com/protocolbuffers/protobuf/releases/download/v${VERSION}/protoc-${VERSION}-${OS}-${ARCH}.zip -O ${SCRIPT_DIR}/../protoc.zip && \ | ||
unzip -qo ${SCRIPT_DIR}/../protoc.zip -d ${SCRIPT_DIR}/.. && \ | ||
bin/protoc --version && \ | ||
rm ${SCRIPT_DIR}/../protoc.zip |