Skip to content

Commit

Permalink
Add scripts to generate Go mock files to Makefile
Browse files Browse the repository at this point in the history
Signed-off-by: tenzen-y <yuki.iwai.tz@gmail.com>
  • Loading branch information
tenzen-y committed Nov 4, 2022
1 parent 68ecb1c commit 859dc1c
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ HAS_LINT := $(shell command -v golangci-lint;)
HAS_YAMLLINT := $(shell command -v yamllint;)
HAS_SHELLCHECK := $(shell command -v shellcheck;)
HAS_SETUP_ENVTEST := $(shell command -v setup-envtest;)
HAS_MOCKGEN := $(shell command -v mockgen;)

COMMIT := v1beta1-$(shell git rev-parse --short=7 HEAD)
KATIB_REGISTRY := docker.io/kubeflowkatib
CPU_ARCH ?= amd64
ENVTEST_K8S_VERSION ?= 1.24
MOCKGEN_VERSION ?= $(shell grep 'github.com/golang/mock' go.mod | cut -d ' ' -f 2)

# for pytest
PYTHONPATH := $(PYTHONPATH):$(CURDIR)/pkg/apis/manager/v1beta1/python:$(CURDIR)/pkg/apis/manager/health/python
Expand All @@ -21,9 +23,9 @@ test: envtest
envtest:
ifndef HAS_SETUP_ENVTEST
go install sigs.k8s.io/controller-runtime/tools/setup-envtest@c7a98aa706379c4e5c79ea675c7f333192677971 # v0.12.3
@echo "setup-envtest has been installed"
$(info "setup-envtest has been installed")
endif
@echo "setup-envtest has already installed"
$(info "setup-envtest has already installed")

check: generate fmt vet lint

Expand All @@ -33,14 +35,14 @@ fmt:
lint:
ifndef HAS_LINT
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.50.1
@echo "golangci-lint has been installed"
$(info "golangci-lint has been installed")
endif
hack/verify-golangci-lint.sh

yamllint:
ifndef HAS_YAMLLINT
pip install yamllint
@echo "yamllint has been installed"
$(info "yamllint has been installed")
endif
hack/verify-yamllint.sh

Expand All @@ -50,7 +52,7 @@ vet:
shellcheck:
ifndef HAS_SHELLCHECK
bash hack/install-shellcheck.sh
@echo "shellcheck has been installed"
$(info "shellcheck has been installed")
endif
hack/verify-shellcheck.sh

Expand All @@ -66,18 +68,24 @@ undeploy:
bash scripts/v1beta1/undeploy.sh

# Run this if you update any existing controller APIs.
# 1. Genereate deepcopy, clientset, listers, informers for the APIs (hack/update-codegen.sh)
# 1. Generate deepcopy, clientset, listers, informers for the APIs (hack/update-codegen.sh)
# 2. Generate open-api for the APIs (hack/update-openapigen)
# 3. Generate Python SDK for Katib (hack/gen-python-sdk/gen-sdk.sh)
# 4. Generate gRPC manager APIs (pkg/apis/manager/v1beta1/build.sh and pkg/apis/manager/health/build.sh)
# 5. Generate Go mock codes
generate:
ifndef GOPATH
$(error GOPATH not defined, please define GOPATH. Run "go help gopath" to learn more about GOPATH)
endif
ifndef HAS_MOCKGEN
go install github.com/golang/mock/mockgen@$(MOCKGEN_VERSION)
$(info "mockgen has been installed")
endif
go generate ./pkg/... ./cmd/...
hack/gen-python-sdk/gen-sdk.sh
pkg/apis/manager/v1beta1/build.sh
pkg/apis/manager/health/build.sh
hack/update-mockgen.sh

# Build images for the Katib v1beta1 components.
build: generate
Expand Down

0 comments on commit 859dc1c

Please sign in to comment.