From 72441f4f14ebf729e8f7daa452b556b85c969bae Mon Sep 17 00:00:00 2001 From: "Roland.Ma" Date: Mon, 22 Feb 2021 02:01:13 +0000 Subject: [PATCH] update e2e build script Signed-off-by: Roland.Ma --- Makefile | 4 +++ hack/build_e2e.sh | 48 ++++++++++++++++++++++++++++++++++ hack/lib/util.sh | 2 +- hack/update-vendor.sh | 14 ++++++++++ vendor/kubesphere.io/client-go | 1 + vendor/modules.txt | 3 +++ 6 files changed, 71 insertions(+), 1 deletion(-) create mode 100755 hack/build_e2e.sh create mode 120000 vendor/kubesphere.io/client-go diff --git a/Makefile b/Makefile index cab4df019..99e72e6ca 100644 --- a/Makefile +++ b/Makefile @@ -44,6 +44,10 @@ ks-apiserver: fmt vet ks-controller-manager: fmt vet hack/gobuild.sh cmd/controller-manager +# Build e2e binary +e2e: fmt vet + hack/build_e2e.sh test/e2e + # Run go fmt against code fmt: gofmt -w ./pkg ./cmd ./tools ./api diff --git a/hack/build_e2e.sh b/hack/build_e2e.sh new file mode 100755 index 000000000..4481003d2 --- /dev/null +++ b/hack/build_e2e.sh @@ -0,0 +1,48 @@ +#!/usr/bin/env bash + +# Copyright 2020 KubeSphere Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script builds and link stamps the output + +set -o errexit +set -o nounset +set -o pipefail + +KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. +source "${KUBE_ROOT}/hack/lib/init.sh" + +VERBOSE=${VERBOSE:-"0"} +V="" +if [[ "${VERBOSE}" == "1" ]];then + V="-x" + set -x +fi + +ROOTDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" + +OUTPUT_DIR=bin +BUILDPATH=./${1:?"path to build"} +OUT=${OUTPUT_DIR}/${1:?"output path"} + +BUILD_GOOS=${GOOS:-$(go env GOOS)} +BUILD_GOARCH=${GOARCH:-$(go env GOARCH)} +GOBINARY=${GOBINARY:-go} +LDFLAGS=$(kube::version::ldflags) + +time GOOS=${BUILD_GOOS} GOARCH=${BUILD_GOARCH} ${GOBINARY} test \ + -c \ + -ldflags "${LDFLAGS}" \ + -o ${OUT} \ + ${BUILDPATH} diff --git a/hack/lib/util.sh b/hack/lib/util.sh index 9c1c2093a..2bb1a14ba 100755 --- a/hack/lib/util.sh +++ b/hack/lib/util.sh @@ -540,7 +540,7 @@ EOF # $KUBE_ROOT must be set. function kube::util::list_staging_repos() { ( - cd "${KUBE_ROOT}/staging/src/k8s.io" && \ + cd "${KUBE_ROOT}/staging/src/kubesphere.io" && \ find . -mindepth 1 -maxdepth 1 -type d | cut -c 3- | sort ) } diff --git a/hack/update-vendor.sh b/hack/update-vendor.sh index 798dc37ee..0af9ce8db 100755 --- a/hack/update-vendor.sh +++ b/hack/update-vendor.sh @@ -122,6 +122,17 @@ function add_generated_comments() { # Phase 1: ensure go.mod files for staging modules and main module +for repo in $(kube::util::list_staging_repos); do + pushd "staging/src/kubesphere.io/${repo}" >/dev/null 2>&1 + if [[ ! -f go.mod ]]; then + kube::log::status "go.mod: initialize ${repo}" + rm -f Godeps/Godeps.json # remove before initializing, staging Godeps are not authoritative + go mod init "kubesphere.io/${repo}" + go mod edit -fmt + fi + popd >/dev/null 2>&1 +done + if [[ ! -f go.mod ]]; then kube::log::status "go.mod: initialize kubesphere.io/kubesphere" go mod init "kubesphere.io/kubesphere" @@ -134,6 +145,9 @@ kube::log::status "go.mod: update references" # Prune go mod edit -json | jq -r '.Require[]? | select(.Version == "v0.0.0") | "-droprequire \(.Path)"' | xargs -L 100 go mod edit -fmt go mod edit -json | jq -r '.Replace[]? | select(.New.Path | startswith("./staging/")) | "-dropreplace \(.Old.Path)"' | xargs -L 100 go mod edit -fmt +# Readd +kube::util::list_staging_repos | xargs -n 1 -I {} echo "-require kubesphere.io/{}@v0.0.0" | xargs -L 100 go mod edit -fmt +kube::util::list_staging_repos | xargs -n 1 -I {} echo "-replace kubesphere.io/{}=./staging/src/kubesphere.io/{}" | xargs -L 100 go mod edit -fmt # Phase 3: capture required (minimum) versions from all modules, and replaced (pinned) versions from the root module diff --git a/vendor/kubesphere.io/client-go b/vendor/kubesphere.io/client-go new file mode 120000 index 000000000..0bee05eff --- /dev/null +++ b/vendor/kubesphere.io/client-go @@ -0,0 +1 @@ +../../staging/src/kubesphere.io/client-go \ No newline at end of file diff --git a/vendor/modules.txt b/vendor/modules.txt index 807904705..7b78f3a31 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1530,6 +1530,9 @@ k8s.io/utils/net k8s.io/utils/path k8s.io/utils/pointer k8s.io/utils/trace +# kubesphere.io/client-go v0.0.0 => ./staging/src/kubesphere.io/client-go +kubesphere.io/client-go/client +kubesphere.io/client-go/client/generic # openpitrix.io/openpitrix v0.4.9-0.20200611125425-ae07f141e797 => openpitrix.io/openpitrix v0.4.9-0.20200611125425-ae07f141e797 openpitrix.io/openpitrix/pkg/config openpitrix.io/openpitrix/pkg/constants