upgrade kubebuilder envtest way

Signed-off-by: yuswift <yuswift2018@gmail.com>
This commit is contained in:
yuswift
2021-08-27 22:59:29 +08:00
parent d313d8f307
commit 60977b150c
2 changed files with 12 additions and 1 deletions

1
.gitignore vendored
View File

@@ -32,3 +32,4 @@ kustomize/network/etcd
apiserver.local.config apiserver.local.config
tmp/ tmp/
kubesphere.yaml kubesphere.yaml
testbin/

View File

@@ -2,6 +2,13 @@
# Use of this source code is governed by a Apache license # Use of this source code is governed by a Apache license
# that can be found in the LICENSE file. # that can be found in the LICENSE file.
# Setting SHELL to bash allows bash commands to be executed by recipes.
# This is a requirement for 'setup-envtest.sh' in the test target.
# Options are set to exit when a recipe line exits non-zero or a piped command fails.
SHELL = /usr/bin/env bash -o pipefail
.SHELLFLAGS = -ec
# Produce CRDs that work back to Kubernetes 1.11 (no version conversion) # Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
CRD_OPTIONS ?= "crd:trivialVersions=true" CRD_OPTIONS ?= "crd:trivialVersions=true"
@@ -137,8 +144,11 @@ helm-uninstall: ; $(info $(M)...Begin to helm-uninstall.) @ ## Helm-uninstall.
kubectl delete -f https://raw.githubusercontent.com/kubesphere/ks-installer/master/roles/ks-core/prepare/files/ks-init/role-templates.yaml kubectl delete -f https://raw.githubusercontent.com/kubesphere/ks-installer/master/roles/ks-core/prepare/files/ks-init/role-templates.yaml
# Run tests # Run tests
ENVTEST_ASSETS_DIR=$(shell pwd)/testbin
test: vet ;$(info $(M)...Begin to run tests.) @ ## Run tests. test: vet ;$(info $(M)...Begin to run tests.) @ ## Run tests.
export KUBEBUILDER_CONTROLPLANE_START_TIMEOUT=2m; go test ./pkg/... ./cmd/... -covermode=atomic -coverprofile=coverage.txt mkdir -p ${ENVTEST_ASSETS_DIR}
test -f ${ENVTEST_ASSETS_DIR}/setup-envtest.sh || curl -sSLo ${ENVTEST_ASSETS_DIR}/setup-envtest.sh https://raw.githubusercontent.com/kubernetes-sigs/controller-runtime/v0.8.3/hack/setup-envtest.sh
source ${ENVTEST_ASSETS_DIR}/setup-envtest.sh; fetch_envtest_tools $(ENVTEST_ASSETS_DIR); setup_envtest_env $(ENVTEST_ASSETS_DIR); go test ./pkg/... ./cmd/... -covermode=atomic -coverprofile=coverage.txt
cd staging/src/kubesphere.io/api ; GOFLAGS="" go test ./... cd staging/src/kubesphere.io/api ; GOFLAGS="" go test ./...
cd staging/src/kubesphere.io/client-go ; GOFLAGS="" go test ./... cd staging/src/kubesphere.io/client-go ; GOFLAGS="" go test ./...