Skip to content

Commit

Permalink
install ginkgo, updated building from git repo
Browse files Browse the repository at this point in the history
  • Loading branch information
pohly committed Feb 28, 2019
1 parent cab97d9 commit 01993fd
Showing 1 changed file with 32 additions and 15 deletions.
47 changes: 32 additions & 15 deletions release-tools/prow.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -105,38 +109,44 @@ 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
return
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
Expand All @@ -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.
Expand Down

0 comments on commit 01993fd

Please sign in to comment.