Skip to content

Commit

Permalink
Merge pull request openshift#115 from russellb/hack-scripts
Browse files Browse the repository at this point in the history
Add hack/shellcheck.sh and fix shellcheck warnings.
  • Loading branch information
metal3-io-bot authored Oct 9, 2019
2 parents 7b6f5eb + 2664ab6 commit 86c4639
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 8 deletions.
2 changes: 1 addition & 1 deletion hack/gofmt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ IS_CONTAINER=${IS_CONTAINER:-false}

if [ "${IS_CONTAINER}" != "false" ]; then
TOP_DIR="${1:-.}"
go fmt ${TOP_DIR}/pkg/... ${TOP_DIR}/cmd/...
go fmt "${TOP_DIR}"/pkg/... "${TOP_DIR}"/cmd/...
else
podman run --rm \
--env IS_CONTAINER=TRUE \
Expand Down
2 changes: 1 addition & 1 deletion hack/govet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ IS_CONTAINER=${IS_CONTAINER:-false}

if [ "${IS_CONTAINER}" != "false" ]; then
TOP_DIR="${1:-.}"
go vet ${TOP_DIR}/pkg/... ${TOP_DIR}/cmd/...
go vet "${TOP_DIR}"/pkg/... "${TOP_DIR}"/cmd/...
else
podman run --rm \
--env IS_CONTAINER=TRUE \
Expand Down
18 changes: 18 additions & 0 deletions hack/shellcheck.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/sh

set -eux

IS_CONTAINER=${IS_CONTAINER:-false}

if [ "${IS_CONTAINER}" != "false" ]; then
TOP_DIR="${1:-.}"
find "${TOP_DIR}" -path ./vendor -prune -o -name '*.sh' -exec shellcheck -s bash {} \+
else
podman run --rm \
--env IS_CONTAINER=TRUE \
--volume "${PWD}:/workdir:ro,z" \
--entrypoint sh \
--workdir /workdir \
registry.hub.docker.com/koalaman/shellcheck-alpine:stable \
/workdir/hack/shellcheck.sh "${@}"
fi;
6 changes: 3 additions & 3 deletions hack/unit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ IS_CONTAINER=${IS_CONTAINER:-false}
if [ "${IS_CONTAINER}" != "false" ]; then
TOP_DIR="${1:-$(pwd)}"
cd /
${TOP_DIR}/tools/install_kustomize.sh
${TOP_DIR}/tools/install_kubebuilder.sh
"${TOP_DIR}"/tools/install_kustomize.sh
"${TOP_DIR}"/tools/install_kubebuilder.sh
mv kubebuilder /usr/local/.
cd ${TOP_DIR}
cd "${TOP_DIR}"
go test ./pkg/... ./cmd/... -coverprofile /cover.out
else
podman run --rm \
Expand Down
6 changes: 3 additions & 3 deletions tools/install_kustomize.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash -x
mkdir -p $GOPATH/bin
curl -L https://github.com/kubernetes-sigs/kustomize/releases/download/v2.0.3/kustomize_2.0.3_linux_amd64 -o $GOPATH/bin/kustomize
chmod +x $GOPATH/bin/kustomize
mkdir -p "$GOPATH"/bin
curl -L https://github.com/kubernetes-sigs/kustomize/releases/download/v2.0.3/kustomize_2.0.3_linux_amd64 -o "$GOPATH"/bin/kustomize
chmod +x "$GOPATH"/bin/kustomize

0 comments on commit 86c4639

Please sign in to comment.