Skip to content

Commit 01993fd

Browse files
committed
install ginkgo, updated building from git repo
1 parent cab97d9 commit 01993fd

File tree

1 file changed

+32
-15
lines changed

1 file changed

+32
-15
lines changed

release-tools/prow.sh

+32-15
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@
4848
# (if available), otherwise it is built from source.
4949
: ${CSI_PROW_KIND_VERSION:=447f3a0a68c202e69dd8e648cf494e0ddc35e513}
5050

51+
# ginkgo test runner version to use. If the pre-installed version is
52+
# different, the desired version is built from source.
53+
: ${CSI_PROW_GINKGO_VERSION:=v1.7.0}
54+
5155
# Enables building the code in the repository. On by default, can be
5256
# disabled in jobs which only use pre-built components.
5357
: ${CSI_PROW_BUILD_JOB:=true}
@@ -105,38 +109,44 @@ die () {
105109
exit 1
106110
}
107111

112+
# For additional tools.
113+
CSI_PROW_BIN="${CSI_PROW_WORK}/bin"
114+
mkdir -p "${CSI_PROW_BIN}"
115+
PATH="${CSI_PROW_BIN}:$PATH"
116+
108117
# Ensure that PATH has the desired version of the Go tools.
109118
install_go () {
110119
if go version 2>/dev/null | grep -q "go${CSI_PROW_GO_VERSION}"; then
111120
return
112121
fi
113122

114123
curl "https://dl.google.com/go/go${CSI_PROW_GO_VERSION}.linux-amd64.tar.gz" | tar -C "${CSI_PROW_WORK}" -zxf -
115-
PATH="$CSI_PROW_WORK/go/bin:$PATH"
124+
PATH="${CSI_PROW_WORK}/go/bin:$PATH"
116125
}
117126

118-
# Ensure that PATH has the desired version of the kind tool.
127+
# Ensure that we have the desired version of kind.
119128
install_kind () {
120-
if kind --version 2>/dev/null | grep -q '${CSI_PROW_KIND_VERSION}$'; then
129+
if kind --version 2>/dev/null | grep -q " ${CSI_PROW_KIND_VERSION}$"; then
121130
return
122131
fi
123-
mkdir -p "${CSI_PROW_WORK}/bin"
124132
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
125133
chmod u+x "${CSI_PROW_WORK}/bin/kind"
126134
else
127-
# Fetching by revision not supported by GitHub (https://github.com/isaacs/github/issues/436).
128-
mkdir -p "$GOPATH/src/sigs.k8s.io"
129-
if [ -d "$GOPATH/src/sigs.k8s.io/kind" ]; then
130-
(cd "$GOPATH/src/sigs.k8s.io/kind" && git fetch origin)
131-
else
132-
git clone https://github.com/kubernetes-sigs/kind "$GOPATH/src/sigs.k8s.io/kind"
133-
fi
134-
(cd "$GOPATH/src/sigs.k8s.io/kind" && git checkout ${CSI_PROW_KIND_VERSION})
135+
git_checkout https://github.com/kubernetes-sigs/kind "$GOPATH/src/sigs.k8s.io/kind" "${CSI_PROW_KIND_VERSION}" --depth=1
135136
go build -o "${CSI_PROW_WORK}/bin/kind" sigs.k8s.io/kind
136137
fi
137-
PATH="$CSI_PROW_WORK/bin:$PATH"
138138
}
139139

140+
# Ensure that we have the desired version of the ginkgo test runner.
141+
install_ginkgo () {
142+
if ginkgo version 2>/dev/null | grep -q " ${CSI_PROW_GINKGO_VERSION}$"; then
143+
return
144+
fi
145+
git_checkout https://github.com/onsi/ginkgo "$GOPATH/src/github.com/onsi/ginkgo" "${CSI_PROW_GINKGO_VERSION}" --depth=1
146+
# We have to get dependencies and hence can't call just "go build".
147+
go get github.com/onsi/ginkgo/ginkgo || die "building ginkgo failed"
148+
mv $GOPATH/bin/ginkgo "${CSI_PROW_BIN}"
149+
}
140150

141151
# This checks out a repo ("https://github.com/kubernetes/kubernetes")
142152
# in a certain location ("$GOPATH/src/k8s.io/kubernetes") at
@@ -155,8 +165,15 @@ git_checkout () {
155165
if ! [ -d "$path/.git" ]; then
156166
git init "$path"
157167
fi
158-
(cd "$path" && git fetch "$@" "$repo" "$revision") || die "fetching $repo $revision failed"
159-
(cd "$path" && git checkout FETCH_HEAD) || die "checking out $repo $revision failed"
168+
if (cd "$path" && git fetch "$@" "$repo" "$revision"); then
169+
(cd "$path" && git checkout FETCH_HEAD) || die "checking out $repo $revision failed"
170+
else
171+
# Might have been because fetching by revision is not
172+
# supported by GitHub (https://github.com/isaacs/github/issues/436).
173+
# Fall back to fetching everything.
174+
(cd "$path" && git fetch "$@" "$repo" 'refs/heads/*:refs/remotes/csiprow/heads/*' 'refs/tags/*:refs/tags/*') || die "fetching $repo failed"
175+
(cd "$path" && git checkout "$revision") || die "checking out $repo $revision failed"
176+
fi
160177
}
161178

162179
# Brings up a Kubernetes cluster and sets KUBECONFIG.

0 commit comments

Comments
 (0)