diff --git a/hack/build.sh b/hack/build.sh index 942b174dc..d76311dcc 100755 --- a/hack/build.sh +++ b/hack/build.sh @@ -35,8 +35,8 @@ export GOOS="${OS}" export GO111MODULE=on export GOFLAGS="-mod=vendor" -go install \ - -installsuffix "static" \ +go install \ + -installsuffix "static" \ -ldflags " \ -X main.Version=${VERSION} \ -X main.VersionStrategy=${version_strategy:-} \ @@ -47,5 +47,5 @@ go install \ -X main.GoVersion=$(go version | cut -d " " -f 3) \ -X main.Compiler=$(go env CC) \ -X main.Platform=${OS}/${ARCH} \ - " \ + " \ ./... diff --git a/hack/coverage.sh b/hack/coverage.sh new file mode 100755 index 000000000..2c6e2b541 --- /dev/null +++ b/hack/coverage.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash + +# Copyright The Stash Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -eou pipefail + +GOPATH=$(go env GOPATH) +REPO_ROOT="$GOPATH/src/stash.appscode.dev/stash" + +pushd $REPO_ROOT + +echo "" >coverage.txt + +for d in $(go list ./... | grep -v -e vendor -e test); do + go test -v -race -coverprofile=profile.out -covermode=atomic "$d" + if [ -f profile.out ]; then + cat profile.out >>coverage.txt + rm profile.out + fi +done + +popd diff --git a/hack/e2e.sh b/hack/e2e.sh index 7a8f05da0..4611994a3 100755 --- a/hack/e2e.sh +++ b/hack/e2e.sh @@ -26,4 +26,5 @@ DOCKER_REGISTRY=${DOCKER_REGISTRY:-} echo "Running e2e tests:" cmd="ginkgo -r --v -race --progress --trace --noisyPendings=false ${GINKGO_ARGS} test -- --docker-registry=${DOCKER_REGISTRY} ${TEST_ARGS}" -echo $cmd; $cmd +echo $cmd +$cmd diff --git a/hack/fmt.sh b/hack/fmt.sh index 307373fd3..793db8583 100755 --- a/hack/fmt.sh +++ b/hack/fmt.sh @@ -22,17 +22,27 @@ export GOFLAGS="-mod=vendor" TARGETS="$@" -echo "Running reimport.py" -cmd="reimport3.py ${REPO_PKG} ${TARGETS}" -$cmd -echo +if [ -n "$TARGETS" ]; then + echo "Running reimport.py" + cmd="reimport3.py ${REPO_PKG} ${TARGETS}" + $cmd + echo -echo "Running goimports:" -cmd="goimports -w ${TARGETS}" -echo $cmd; $cmd -echo + echo "Running goimports:" + cmd="goimports -w ${TARGETS}" + echo "$cmd" + $cmd + echo + + echo "Running gofmt:" + cmd="gofmt -s -w ${TARGETS}" + echo "$cmd" + $cmd + echo +fi -echo "Running gofmt:" -cmd="gofmt -s -w ${TARGETS}" -echo $cmd; $cmd +echo "Running shfmt:" +cmd="find . -path ./vendor -prune -o -name '*.sh' -exec shfmt -l -w -ci -i 4 {} \;" +echo "$cmd" +eval "$cmd" # xref: https://stackoverflow.com/a/5615748/244009 echo diff --git a/hack/gendocs/make.sh b/hack/gendocs/make.sh index bb2df5ba3..33f895aaf 100755 --- a/hack/gendocs/make.sh +++ b/hack/gendocs/make.sh @@ -14,7 +14,6 @@ # See the License for the specific language governing permissions and # limitations under the License. - pushd $GOPATH/src/stash.appscode.dev/cli/hack/gendocs go run main.go popd diff --git a/hack/license/go.txt b/hack/license/go.txt index d68e18716..6d8cecd45 100644 --- a/hack/license/go.txt +++ b/hack/license/go.txt @@ -13,3 +13,4 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +