Skip to content

Commit 7467920

Browse files
committed
🏃 enable running tests in prow
1 parent c838130 commit 7467920

File tree

4 files changed

+55
-2
lines changed

4 files changed

+55
-2
lines changed

.travis.yml

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ services:
2626
before_install:
2727
# NOTE: The latest version of dep requires go 1.13
2828
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then mkdir -p /Users/travis/gopath/bin; fi
29-
- GO111MODULE=on curl https://raw.githubusercontent.com/golang/dep/v0.5.1/install.sh | sh
3029
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then GO111MODULE=on scripts/install_and_setup.sh; fi
3130

3231
before_script:

common.sh

+30-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,11 @@ function fetch_tools {
116116
if [ -n "$SKIP_FETCH_TOOLS" ]; then
117117
return 0
118118
fi
119+
fetch_go_tools
120+
fetch_kb_tools
121+
}
119122

123+
function fetch_kb_tools {
120124
header_text "fetching tools"
121125
kb_tools_archive_name="kubebuilder-tools-$k8s_version-$goos-$goarch.tar.gz"
122126
kb_tools_download_url="https://storage.googleapis.com/kubebuilder-tools/$kb_tools_archive_name"
@@ -138,7 +142,32 @@ function build_kb {
138142
opts=-ldflags "-X sigs.k8s.io/kubebuilder/cmd/version.kubeBuilderVersion=$INJECT_KB_VERSION"
139143
fi
140144

141-
go build $opts -o $tmp_root/kubebuilder/bin/kubebuilder ./cmd
145+
GO111MODULE=on go build $opts -o $tmp_root/kubebuilder/bin/kubebuilder ./cmd
146+
}
147+
148+
function fetch_go_tools {
149+
header_text "Checking for dep"
150+
export PATH=$(go env GOPATH)/src/github.com/golang/dep/bin:$PATH
151+
if ! is_installed dep ; then
152+
header_text "Installing dep"
153+
DEP_DIR=$(go env GOPATH)/src/github.com/golang/dep
154+
mkdir -p $DEP_DIR
155+
pushd $DEP_DIR
156+
git clone https://github.com/golang/dep.git .
157+
DEP_LATEST=$(git describe --abbrev=0 --tags)
158+
git checkout $DEP_LATEST
159+
mkdir bin
160+
go build -ldflags="-X main.version=$DEP_LATEST" -o bin/dep ./cmd/dep
161+
popd
162+
fi
163+
164+
}
165+
166+
function is_installed {
167+
if command -v $1 &>/dev/null; then
168+
return 0
169+
fi
170+
return 1
142171
}
143172

144173
function prepare_testdir_under_gopath {

scripts/install.sh

+6
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@ curl -L "$URL"| tar xz -C $TMP_DIR
7777
echo "Downloaded executable files"
7878
ls "${KUBEBUILDER_VERSION_NAME}_${OSEXT}_${ARCH}/bin"
7979

80+
if [[ -z "${PROW}" ]]; then
81+
MOVE="sudo mv"
82+
else
83+
MOVE="mv"
84+
fi
85+
8086
echo "Moving files to $KUBEBUILDER_DIR folder\n"
8187
mv ${KUBEBUILDER_VERSION_NAME}_${OSEXT}_${ARCH} kubebuilder && sudo mv -f kubebuilder /usr/local/
8288

test_ci.sh

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env bash
2+
# Copyright 2018 The Kubernetes Authors.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
export TRACE=1
17+
export GO111MODULE=on
18+
19+
./test.sh

0 commit comments

Comments
 (0)