Skip to content

Commit

Permalink
nit shell scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
BenTheElder committed Aug 23, 2019
1 parent 3b89a4e commit 7e5fb90
Show file tree
Hide file tree
Showing 21 changed files with 56 additions and 86 deletions.
3 changes: 1 addition & 2 deletions hack/build/go_container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@

# Simple posix sh reproducible build container script with (go) caching
# Only requires docker on the host
set -o nounset
set -o errexit
set -o nounset -o errexit

# get the repo root for defaulting OUT_DIR and SOURCE_DIR
# we assume the repo root is two levels up from this script
Expand Down
4 changes: 1 addition & 3 deletions hack/ci/build-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@
# simple CI script to verify kind's own sources
# TODO(bentheelder): rename / refactor. consider building kindnetd

set -o errexit
set -o nounset
set -o pipefail
set -o errexit -o nounset -o pipefail

# cd to the repo root
REPO_ROOT=$(git rev-parse --show-toplevel)
Expand Down
4 changes: 3 additions & 1 deletion hack/ci/e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

set -o errexit -o nounset -o pipefail -o xtrace

REPO_ROOT="$(cd "${BASH_SOURCE[0]}"/../.. && pwd -P)"

# our exit handler (trap)
cleanup() {
# always attempt to dump logs
Expand All @@ -39,7 +41,7 @@ cleanup() {
# install kind to a tempdir GOPATH from this script's kind checkout
install_kind() {
mkdir -p "${TMP_DIR}/bin"
make -C "$(dirname "${BASH_SOURCE[0]}")/../.." install INSTALL_PATH="${TMP_DIR}/bin"
make -C "${REPO_ROOT}" install INSTALL_PATH="${TMP_DIR}/bin"
export PATH="${TMP_DIR}/bin:${PATH}"
}

Expand Down
3 changes: 1 addition & 2 deletions hack/release/build/cross.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@
# limitations under the License.

# simple script to build binaries for release

set -o errexit -o nounset -o pipefail

# cd to the repo root
REPO_ROOT=$(git rev-parse --show-toplevel)
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../../.." && pwd -P)"
cd "${REPO_ROOT}"

# controls the number of concurrent builds
Expand Down
7 changes: 2 additions & 5 deletions hack/release/build/ctr/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,10 @@
# NOTE: this is temporary, we only need to build ctr until our (tiny!)
# --no-unpack patch is available in the standard package

set -o errexit
set -o nounset
set -o pipefail
set -o xtrace
set -o errexit -o nounset -o pipefail

# cd to the repo root
REPO_ROOT=$(git rev-parse --show-toplevel)
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../../../.." && pwd -P)"
cd "${REPO_ROOT}"

# options
Expand Down
6 changes: 2 additions & 4 deletions hack/release/build/push-base.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

set -o errexit
set -o nounset
set -o pipefail
set -o errexit -o nounset -o pipefail

# cd to the repo root
REPO_ROOT=$(git rev-parse --show-toplevel)
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../../.." && pwd -P)"
cd "${REPO_ROOT}"

# ensure we have up to date kind
Expand Down
6 changes: 2 additions & 4 deletions hack/release/build/push-node.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

set -o errexit
set -o nounset
set -o pipefail
set -o errexit -o nounset -o pipefail

# cd to the repo root
REPO_ROOT=$(git rev-parse --show-toplevel)
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../../.." && pwd -P)"
cd "${REPO_ROOT}"

# ensure we have up to date kind
Expand Down
15 changes: 7 additions & 8 deletions hack/release/create.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@
# builds binaries between the commits
# Use like: create.sh <release-version> <next-prerelease-version>
# EG: create.sh v0.3.0 v0.4.0-alpha
set -o nounset
set -o errexit
set -o pipefail
set -o errexit -o nounset -o pipefail

# cd to the repo root
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd -P)"
cd "${REPO_ROOT}"

# check for arguments
if [ "$#" -ne 2 ]; then
echo "Usage: create.sh release-version next-prerelease-version"
exit 1
fi

REPO_ROOT=$(git rev-parse --show-toplevel)
cd "${REPO_ROOT}"

# darwin is great
SED="sed"
if which gsed &>/dev/null; then
Expand Down Expand Up @@ -65,8 +65,7 @@ set_version "${1}"
make_commit "${1}"
add_tag "${1}"
echo "Building ..."
make clean
./hack/release/build/cross.sh
make clean && ./hack/release/build/cross.sh

# update to the second version
set_version "${2}"
Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions hack/update/all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
# limitations under the License.

# script to run all update scripts (except deps)
set -o errexit
set -o nounset
set -o pipefail
set -o errexit -o nounset -o pipefail

REPO_ROOT=$(git rev-parse --show-toplevel)
# cd to the repo root
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd -P)"
cd "${REPO_ROOT}"

"${REPO_ROOT}"/hack/update/deps.sh
"${REPO_ROOT}"/hack/update/generated.sh
Expand Down
10 changes: 3 additions & 7 deletions hack/update/deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.


# Runs go mod tidy, go mod vendor, and then prun vendor
# Runs go mod tidy, go mod vendor, and then prunes vendor
#
# Usage:
# deps.sh

set -o nounset
set -o errexit
set -o pipefail
set -o errexit -o nounset -o pipefail

# cd to the repo root
REPO_ROOT=$(git rev-parse --show-toplevel)
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd -P)"
cd "${REPO_ROOT}"

# enable modules and the proxy cache
Expand Down
17 changes: 8 additions & 9 deletions hack/update/generated.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@
# limitations under the License.

# 'go generate's kind, using tools from vendor (go-bindata)
set -o nounset
set -o errexit
set -o pipefail
set -o errexit -o nounset -o pipefail

REPO_ROOT="${REPO_ROOT:-$(git rev-parse --show-toplevel)}"
# cd to the repo root
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd -P)"
cd "${REPO_ROOT}"

# enable modules and the proxy cache
Expand Down Expand Up @@ -54,12 +53,12 @@ export GOPATH="${FAKE_GOPATH}"
cd "${FAKE_REPOPATH}"

# run the generators
"${BINDIR}/deepcopy-gen" -i ./pkg/internal/apis/config/ -O zz_generated.deepcopy --go-header-file hack/boilerplate.go.txt
"${BINDIR}/defaulter-gen" -i ./pkg/internal/apis/config/ -O zz_generated.default --go-header-file hack/boilerplate.go.txt
"${BINDIR}/deepcopy-gen" -i ./pkg/internal/apis/config/ -O zz_generated.deepcopy --go-header-file hack/tools/boilerplate.go.txt
"${BINDIR}/defaulter-gen" -i ./pkg/internal/apis/config/ -O zz_generated.default --go-header-file hack/tools/boilerplate.go.txt

"${BINDIR}/deepcopy-gen" -i ./pkg/apis/config/v1alpha3 -O zz_generated.deepcopy --go-header-file hack/boilerplate.go.txt
"${BINDIR}/defaulter-gen" -i ./pkg/apis/config/v1alpha3 -O zz_generated.default --go-header-file hack/boilerplate.go.txt
"${BINDIR}/conversion-gen" -i ./pkg/internal/apis/config/v1alpha3 -O zz_generated.conversion --go-header-file hack/boilerplate.go.txt
"${BINDIR}/deepcopy-gen" -i ./pkg/apis/config/v1alpha3 -O zz_generated.deepcopy --go-header-file hack/tools/boilerplate.go.txt
"${BINDIR}/defaulter-gen" -i ./pkg/apis/config/v1alpha3 -O zz_generated.default --go-header-file hack/tools/boilerplate.go.txt
"${BINDIR}/conversion-gen" -i ./pkg/internal/apis/config/v1alpha3 -O zz_generated.conversion --go-header-file hack/tools/boilerplate.go.txt

export GO111MODULE="on"
cd "${REPO_ROOT}"
Expand Down
8 changes: 5 additions & 3 deletions hack/update/gofmt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
# limitations under the License.

# script to run gofmt over our code (not vendor)
set -o errexit
set -o nounset
set -o pipefail
set -o errexit -o nounset -o pipefail

# cd to the repo root
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd -P)"
cd "${REPO_ROOT}"

find . -name "*.go" -type f -print0 | xargs -0 gofmt -s -w
8 changes: 3 additions & 5 deletions hack/verify/all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

set -o errexit
set -o nounset
set -o pipefail
set -o errexit -o nounset -o pipefail

# cd to repo root
REPO_ROOT=$(git rev-parse --show-toplevel)
# cd to the repo root
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd -P)"
cd "${REPO_ROOT}"

# exit code, if a script fails we'll set this to 1
Expand Down
7 changes: 2 additions & 5 deletions hack/verify/generated.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.

set -o errexit
set -o nounset
set -o pipefail
set -o errexit -o nounset -o pipefail

# cd to the repo root
REPO_ROOT=$(git rev-parse --show-toplevel)
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd -P)"
cd "${REPO_ROOT}"


# place to stick temp binaries
BINDIR="${REPO_ROOT}/bin"
mkdir -p "${BINDIR}"
Expand Down
6 changes: 2 additions & 4 deletions hack/verify/gofmt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

set -o errexit
set -o nounset
set -o pipefail
set -o errexit -o nounset -o pipefail

# cd to the repo root
REPO_ROOT=$(git rev-parse --show-toplevel)
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd -P)"
cd "${REPO_ROOT}"

# check for gofmt diffs
Expand Down
6 changes: 2 additions & 4 deletions hack/verify/golint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@
# limitations under the License.

# CI script to run go lint over our code
set -o errexit
set -o nounset
set -o pipefail
set -o errexit -o nounset -o pipefail

# cd to the repo root
REPO_ROOT=$(git rev-parse --show-toplevel)
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd -P)"
cd "${REPO_ROOT}"

# enable modules and the proxy cache
Expand Down
6 changes: 2 additions & 4 deletions hack/verify/govet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@
# limitations under the License.

# CI script to run go vet over our code
set -o errexit
set -o nounset
set -o pipefail
set -o errexit -o nounset -o pipefail

# cd to the repo root
REPO_ROOT=$(git rev-parse --show-toplevel)
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd -P)"
cd "${REPO_ROOT}"

# enable modules and the proxy cache
Expand Down
6 changes: 2 additions & 4 deletions hack/verify/shellcheck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@
# limitations under the License.

# CI script to run shellcheck
set -o errexit
set -o nounset
set -o pipefail
set -o errexit -o nounset -o pipefail

# cd to the repo root
REPO_ROOT=$(git rev-parse --show-toplevel)
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd -P)"
cd "${REPO_ROOT}"

# upstream shellcheck latest stable image as of January 10th, 2019
Expand Down
6 changes: 2 additions & 4 deletions hack/verify/spelling.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

set -o errexit
set -o nounset
set -o pipefail
set -o errexit -o nounset -o pipefail

# cd to the repo root
REPO_ROOT=$(git rev-parse --show-toplevel)
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd -P)"
cd "${REPO_ROOT}"

# enable modules and the proxy cache
Expand Down
6 changes: 2 additions & 4 deletions hack/verify/staticcheck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@
# limitations under the License.

# CI script to run staticcheck
set -o errexit
set -o nounset
set -o pipefail
set -o errexit -o nounset -o pipefail

# cd to the repo root
REPO_ROOT=$(git rev-parse --show-toplevel)
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd -P)"
cd "${REPO_ROOT}"

# enable modules and the proxy cache
Expand Down

0 comments on commit 7e5fb90

Please sign in to comment.