From 938d68ead9649060f38ae529c7135ed84f3b663b Mon Sep 17 00:00:00 2001 From: Isabella do Amaral Date: Mon, 12 Aug 2024 14:41:51 -0300 Subject: [PATCH] drop use of GOBIN Signed-off-by: Isabella do Amaral --- .github/workflows/build.yml | 2 ++ Dockerfile | 2 +- Makefile | 39 +++++++++++++------------------------ README.md | 10 ++++++++++ csi/Dockerfile.dev | 2 +- csi/Makefile | 26 ++++++------------------- 6 files changed, 34 insertions(+), 47 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7ccc89b4..2a910789 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,6 +23,8 @@ jobs: uses: actions/setup-go@v5 with: go-version: "1.21" + - name: install go deps + run: make go-deps - name: Set up Python uses: actions/setup-python@v5 with: diff --git a/Dockerfile b/Dockerfile index 89a741c5..99217286 100644 --- a/Dockerfile +++ b/Dockerfile @@ -30,7 +30,7 @@ COPY patches/ patches/ COPY templates/ templates/ # Download tools -RUN make deps +RUN make deps go-deps # Build USER root diff --git a/Makefile b/Makefile index d350155a..a28e8508 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST))) PROJECT_PATH := $(patsubst %/,%,$(dir $(MKFILE_PATH))) PROJECT_BIN := $(PROJECT_PATH)/bin -GO := $(PROJECT_BIN)/go1.21.9 +GO ?= "$(shell which go)" # add tools bin directory PATH := $(PROJECT_BIN):$(PATH) @@ -64,7 +64,7 @@ internal/ml_metadata/proto/%.pb.go: api/grpc/ml_metadata/proto/%.proto gen/grpc: internal/ml_metadata/proto/metadata_store.pb.go internal/ml_metadata/proto/metadata_store_service.pb.go internal/converter/generated/converter.go: internal/converter/*.go - ${GOVERTER} gen github.com/kubeflow/model-registry/internal/converter/ + goverter gen github.com/kubeflow/model-registry/internal/converter/ .PHONY: gen/converter gen/converter: gen/grpc internal/converter/generated/converter.go @@ -104,34 +104,23 @@ vet: clean: rm -Rf ./model-registry internal/ml_metadata/proto/*.go internal/converter/generated/*.go pkg/openapi -.PHONY: clean/odh -clean/odh: +.PHONY: clean/docker +clean/docker: rm -Rf ./model-registry -bin/go: - GOBIN=$(PROJECT_BIN) go install golang.org/dl/go1.21.9@latest - $(PROJECT_BIN)/go1.21.9 download - bin/protoc: ./scripts/install_protoc.sh -bin/go-enum: - GOBIN=$(PROJECT_BIN) ${GO} install github.com/searKing/golang/tools/go-enum@v1.2.97 - -bin/protoc-gen-go: - GOBIN=$(PROJECT_BIN) ${GO} install google.golang.org/protobuf/cmd/protoc-gen-go@v1.31.0 - -bin/protoc-gen-go-grpc: - GOBIN=$(PROJECT_BIN) ${GO} install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.3.0 +go-deps: + ${GO} install github.com/searKing/golang/tools/go-enum@v1.2.97 + ${GO} install google.golang.org/protobuf/cmd/protoc-gen-go@v1.31.0 + ${GO} install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.3.0 + ${GO} install github.com/jmattheis/goverter/cmd/goverter@v1.4.1 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.59.1 -GOVERTER ?= ${PROJECT_BIN}/goverter -bin/goverter: - GOBIN=$(PROJECT_PATH)/bin ${GO} install github.com/jmattheis/goverter/cmd/goverter@v1.4.1 - OPENAPI_GENERATOR ?= ${PROJECT_BIN}/openapi-generator-cli NPM ?= "$(shell which npm)" bin/openapi-generator-cli: @@ -155,7 +144,7 @@ clean/deps: rm -Rf bin/* .PHONY: deps -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 +deps: bin/protoc bin/golangci-lint bin/openapi-generator-cli .PHONY: vendor vendor: @@ -163,11 +152,11 @@ vendor: .PHONY: build build: gen vet lint - ${GO} build -buildvcs=false + ${GO} build -.PHONY: build/odh -build/odh: vet - ${GO} build -buildvcs=false +.PHONY: build/docker +build/docker: vet + ${GO} build .PHONY: gen gen: deps gen/grpc gen/openapi gen/openapi-server gen/converter diff --git a/README.md b/README.md index 910857cd..be4041e3 100644 --- a/README.md +++ b/README.md @@ -10,11 +10,21 @@ Model registry provides a central repository for model developers to store and m ## Pre-requisites: - go >= 1.21 +- go-enum >= 1.2.97 +- protoc-gen-go >= 1.31.0 +- protoc-gen-go-grpc >= 1.3.0 +- goverter >= 1.4.1 - protoc v24.3 - [Protocol Buffers v24.3 Release](https://github.com/protocolbuffers/protobuf/releases/tag/v24.3) - npm >= 10.2.0 - [Installing Node.js and npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm) - Java >= 11.0 - python 3.9 +To install the go dependencies you can use + +```sh +make go-deps +``` + ## OpenAPI Proxy Server The model registry proxy server implementation follows a contract-first approach, where the contract is identified by [model-registry.yaml](api/openapi/model-registry.yaml) OpenAPI specification. diff --git a/csi/Dockerfile.dev b/csi/Dockerfile.dev index 3f3cf8ec..021be636 100644 --- a/csi/Dockerfile.dev +++ b/csi/Dockerfile.dev @@ -42,4 +42,4 @@ WORKDIR / COPY --from=builder /modelregistry/csi/bin/mr-storage-initializer . USER 65532:65532 -ENTRYPOINT ["/mr-storage-initializer"] \ No newline at end of file +ENTRYPOINT ["/mr-storage-initializer"] diff --git a/csi/Makefile b/csi/Makefile index d40da2c4..eb705e69 100644 --- a/csi/Makefile +++ b/csi/Makefile @@ -1,11 +1,4 @@ -# Useful paths -MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST))) -PROJECT_PATH := $(patsubst %/,%,$(dir $(MKFILE_PATH))) -PROJECT_BIN := $(PROJECT_PATH)/bin -GO := $(PROJECT_BIN)/go1.21.9 - -# add tools bin directory -PATH := $(PROJECT_BIN):$(PATH) +GO ?= "$(shell which go)" # container tool DOCKER ?= docker @@ -32,33 +25,26 @@ help: ## Display this help. ##@ Development -bin-go: ## Install go tool - GOBIN=$(PROJECT_BIN) go install golang.org/dl/go1.21.9@latest - $(PROJECT_BIN)/go1.21.9 download - -.PHONY: bin -bin: bin-go ## Install required dependencies - .PHONY: tidy tidy: ## Run go mod tidy. ${GO} mod tidy .PHONY: fmt -fmt: bin ## Run go fmt against code. +fmt: ## Run go fmt against code. ${GO} fmt ./... .PHONY: vet -vet: bin ## Run go vet against code. +vet: ## Run go vet against code. ${GO} vet ./... .PHONY: test -test: fmt vet bin ## Run tests. +test: fmt vet ## Run tests. ${GO} test ./... -coverprofile cover.out ##@ Build .PHONY: build -build: fmt vet bin ## Build binary. +build: fmt vet ## Build binary. ${GO} build -o bin/mr-storage-initializer main.go .PHONY: run @@ -75,4 +61,4 @@ docker-build-dev: ## Build container image using local model-registry module. .PHONY: docker-push docker-push: ## Push container image. - ${DOCKER} push ${IMG}:$(IMG_VERSION) \ No newline at end of file + ${DOCKER} push ${IMG}:$(IMG_VERSION)