diff --git a/release-tools/prow.sh b/release-tools/prow.sh index 1f5da48a5..05473f919 100644 --- a/release-tools/prow.sh +++ b/release-tools/prow.sh @@ -48,6 +48,10 @@ # (if available), otherwise it is built from source. : ${CSI_PROW_KIND_VERSION:=447f3a0a68c202e69dd8e648cf494e0ddc35e513} +# ginkgo test runner version to use. If the pre-installed version is +# different, the desired version is built from source. +: ${CSI_PROW_GINKGO_VERSION:=v1.7.0} + # Enables building the code in the repository. On by default, can be # disabled in jobs which only use pre-built components. : ${CSI_PROW_BUILD_JOB:=true} @@ -105,6 +109,11 @@ die () { exit 1 } +# For additional tools. +CSI_PROW_BIN="${CSI_PROW_WORK}/bin" +mkdir -p "${CSI_PROW_BIN}" +PATH="${CSI_PROW_BIN}:$PATH" + # Ensure that PATH has the desired version of the Go tools. install_go () { if go version 2>/dev/null | grep -q "go${CSI_PROW_GO_VERSION}"; then @@ -112,31 +121,32 @@ install_go () { fi curl "https://dl.google.com/go/go${CSI_PROW_GO_VERSION}.linux-amd64.tar.gz" | tar -C "${CSI_PROW_WORK}" -zxf - - PATH="$CSI_PROW_WORK/go/bin:$PATH" + PATH="${CSI_PROW_WORK}/go/bin:$PATH" } -# Ensure that PATH has the desired version of the kind tool. +# Ensure that we have the desired version of kind. install_kind () { - if kind --version 2>/dev/null | grep -q '${CSI_PROW_KIND_VERSION}$'; then + if kind --version 2>/dev/null | grep -q " ${CSI_PROW_KIND_VERSION}$"; then return fi - mkdir -p "${CSI_PROW_WORK}/bin" if curl --fail --location -o "${CSI_PROW_WORK}/bin/kind" "https://github.com/kubernetes-sigs/kind/releases/download/${CSI_PROW_KIND_VERSION}/kind-linux-amd64"; then chmod u+x "${CSI_PROW_WORK}/bin/kind" else - # Fetching by revision not supported by GitHub (https://github.com/isaacs/github/issues/436). - mkdir -p "$GOPATH/src/sigs.k8s.io" - if [ -d "$GOPATH/src/sigs.k8s.io/kind" ]; then - (cd "$GOPATH/src/sigs.k8s.io/kind" && git fetch origin) - else - git clone https://github.com/kubernetes-sigs/kind "$GOPATH/src/sigs.k8s.io/kind" - fi - (cd "$GOPATH/src/sigs.k8s.io/kind" && git checkout ${CSI_PROW_KIND_VERSION}) + git_checkout https://github.com/kubernetes-sigs/kind "$GOPATH/src/sigs.k8s.io/kind" "${CSI_PROW_KIND_VERSION}" --depth=1 go build -o "${CSI_PROW_WORK}/bin/kind" sigs.k8s.io/kind fi - PATH="$CSI_PROW_WORK/bin:$PATH" } +# Ensure that we have the desired version of the ginkgo test runner. +install_ginkgo () { + if ginkgo version 2>/dev/null | grep -q " ${CSI_PROW_GINKGO_VERSION}$"; then + return + fi + git_checkout https://github.com/onsi/ginkgo "$GOPATH/src/github.com/onsi/ginkgo" "${CSI_PROW_GINKGO_VERSION}" --depth=1 + # We have to get dependencies and hence can't call just "go build". + go get github.com/onsi/ginkgo/ginkgo || die "building ginkgo failed" + mv $GOPATH/bin/ginkgo "${CSI_PROW_BIN}" +} # This checks out a repo ("https://github.com/kubernetes/kubernetes") # in a certain location ("$GOPATH/src/k8s.io/kubernetes") at @@ -155,8 +165,15 @@ git_checkout () { if ! [ -d "$path/.git" ]; then git init "$path" fi - (cd "$path" && git fetch "$@" "$repo" "$revision") || die "fetching $repo $revision failed" - (cd "$path" && git checkout FETCH_HEAD) || die "checking out $repo $revision failed" + if (cd "$path" && git fetch "$@" "$repo" "$revision"); then + (cd "$path" && git checkout FETCH_HEAD) || die "checking out $repo $revision failed" + else + # Might have been because fetching by revision is not + # supported by GitHub (https://github.com/isaacs/github/issues/436). + # Fall back to fetching everything. + (cd "$path" && git fetch "$@" "$repo" 'refs/heads/*:refs/remotes/csiprow/heads/*' 'refs/tags/*:refs/tags/*') || die "fetching $repo failed" + (cd "$path" && git checkout "$revision") || die "checking out $repo $revision failed" + fi } # Brings up a Kubernetes cluster and sets KUBECONFIG.