Skip to content
This repository was archived by the owner on Oct 28, 2024. It is now read-only.

Commit 9db9b9a

Browse files
adding scripts directory for prow jobs
Signed-off-by: Chris Hein <[email protected]>
1 parent 163817c commit 9db9b9a

File tree

4 files changed

+190
-0
lines changed

4 files changed

+190
-0
lines changed

scripts/ci-build.sh

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
3+
# Copyright 2018 The Kubernetes Authors.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
set -o errexit
18+
set -o nounset
19+
set -o pipefail
20+
21+
REPO_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
22+
# shellcheck source=../hack/ensure-go.sh
23+
source "${REPO_ROOT}/hack/ensure-go.sh"
24+
25+
cd "${REPO_ROOT}" && make binaries

scripts/ci-make.sh

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
3+
# Copyright 2018 The Kubernetes Authors.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
set -o errexit
18+
set -o nounset
19+
set -o pipefail
20+
21+
REPO_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
22+
# shellcheck source=../hack/ensure-go.sh
23+
source "${REPO_ROOT}/hack/ensure-go.sh"
24+
25+
cd "${REPO_ROOT}" && make docker-build

scripts/ci-test.sh

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash
2+
3+
# Copyright 2018 The Kubernetes Authors.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
set -o errexit
18+
set -o nounset
19+
set -o pipefail
20+
21+
REPO_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
22+
# shellcheck source=../hack/ensure-go.sh
23+
source "${REPO_ROOT}/hack/ensure-go.sh"
24+
25+
cd "${REPO_ROOT}" && \
26+
source ./scripts/fetch_ext_bins.sh && \
27+
fetch_tools && \
28+
setup_envs && \
29+
make generate lint test

scripts/fetch_ext_bins.sh

+111
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
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+
set -o errexit
17+
set -o nounset
18+
set -o pipefail
19+
20+
# Enable tracing in this script off by setting the TRACE variable in your
21+
# environment to any value:
22+
#
23+
# $ TRACE=1 test.sh
24+
TRACE=${TRACE:-""}
25+
if [[ -n "${TRACE}" ]]; then
26+
set -x
27+
fi
28+
29+
k8s_version=1.16.4
30+
goarch=amd64
31+
goos="unknown"
32+
33+
if [[ "${OSTYPE}" == "linux"* ]]; then
34+
goos="linux"
35+
elif [[ "${OSTYPE}" == "darwin"* ]]; then
36+
goos="darwin"
37+
fi
38+
39+
if [[ "$goos" == "unknown" ]]; then
40+
echo "OS '$OSTYPE' not supported. Aborting." >&2
41+
exit 1
42+
fi
43+
44+
# Turn colors in this script off by setting the NO_COLOR variable in your
45+
# environment to any value:
46+
#
47+
# $ NO_COLOR=1 test.sh
48+
NO_COLOR=${NO_COLOR:-""}
49+
if [[ -z "${NO_COLOR}" ]]; then
50+
header=$'\e[1;33m'
51+
reset=$'\e[0m'
52+
else
53+
header=''
54+
reset=''
55+
fi
56+
57+
function header_text {
58+
echo "$header$*$reset"
59+
}
60+
61+
tmp_root=/tmp
62+
63+
kb_root_dir=${tmp_root}/kubebuilder
64+
65+
# Skip fetching and untaring the tools by setting the SKIP_FETCH_TOOLS variable
66+
# in your environment to any value:
67+
#
68+
# $ SKIP_FETCH_TOOLS=1 ./fetch_ext_bins.sh
69+
#
70+
# If you skip fetching tools, this script will use the tools already on your
71+
# machine, but rebuild the kubebuilder and kubebuilder-bin binaries.
72+
SKIP_FETCH_TOOLS=${SKIP_FETCH_TOOLS:-""}
73+
74+
function prepare_staging_dir {
75+
header_text "preparing staging dir"
76+
77+
if [[ -z "${SKIP_FETCH_TOOLS}" ]]; then
78+
rm -rf "${kb_root_dir}"
79+
else
80+
rm -f "${kb_root_dir}/kubebuilder/bin/kubebuilder"
81+
rm -f "${kb_root_dir}/kubebuilder/bin/kubebuilder-gen"
82+
rm -f "${kb_root_dir}/kubebuilder/bin/vendor.tar.gz"
83+
fi
84+
}
85+
86+
# fetch k8s API gen tools and make it available under kb_root_dir/bin.
87+
function fetch_tools {
88+
if [[ -n "$SKIP_FETCH_TOOLS" ]]; then
89+
return 0
90+
fi
91+
92+
header_text "fetching tools"
93+
kb_tools_archive_name="kubebuilder-tools-${k8s_version}-${goos}-${goarch}.tar.gz"
94+
kb_tools_download_url="https://storage.googleapis.com/kubebuilder-tools/${kb_tools_archive_name}"
95+
96+
kb_tools_archive_path="${tmp_root}/${kb_tools_archive_name}"
97+
if [[ ! -f ${kb_tools_archive_path} ]]; then
98+
curl -fsL ${kb_tools_download_url} -o "${kb_tools_archive_path}"
99+
fi
100+
tar -zvxf "${kb_tools_archive_path}" -C "${tmp_root}/"
101+
}
102+
103+
function setup_envs {
104+
header_text "setting up env vars"
105+
106+
# Setup env vars
107+
export PATH=/tmp/kubebuilder/bin:$PATH
108+
export TEST_ASSET_KUBECTL=/tmp/kubebuilder/bin/kubectl
109+
export TEST_ASSET_KUBE_APISERVER=/tmp/kubebuilder/bin/kube-apiserver
110+
export TEST_ASSET_ETCD=/tmp/kubebuilder/bin/etcd
111+
}

0 commit comments

Comments
 (0)