diff --git a/Makefile b/Makefile index 61440079b..9809e3eae 100644 --- a/Makefile +++ b/Makefile @@ -9,6 +9,8 @@ COMPUTE_NODES ?= 2 OCI_BIN ?= docker +SKIP_STATIC_CHECK ?= false + build: hack/build-go.sh @@ -23,7 +25,10 @@ install-tools: hack/install-kubebuilder-tools.sh test: build install-tools - hack/test-go.sh + hack/test-go.sh --skip-static-check + +test-skip-static: build + hack/test-go.sh --skip-static-check true kind: hack/e2e-setup-kind-cluster.sh -n $(COMPUTE_NODES) diff --git a/hack/test-go.sh b/hack/test-go.sh index 1327e4cb6..69c56836e 100755 --- a/hack/test-go.sh +++ b/hack/test-go.sh @@ -1,20 +1,37 @@ #!/usr/bin/env bash # single test: go test -v ./pkg/storage/ # without cache: go test -count=1 -v ./pkg/storage/ -set -e -x +set -eox pipefail GO=${GO:-go} + +while true; do + case "$1" in + -s|--skip-static-check) + SKIP_STATIC_CHECK=false + break + ;; + *) + echo "define argument -s (skip static check)" + exit 1 + esac +done + echo "Running go vet ..." ${GO} vet --tags=test ./cmd/... ./pkg/... BASEDIR=$(pwd) -echo "Installing golang staticcheck ..." -GOBIN=${BASEDIR}/bin go install honnef.co/go/tools/cmd/staticcheck@latest - -echo "Running golang staticcheck ..." -${BASEDIR}/bin/staticcheck --tags=test ./... +if [ $SKIP_STATIC_CHECK ] +then + echo "SKipped golang staticcheck" +else + echo "Installing golang staticcheck ..." + GOBIN=${BASEDIR}/bin go install honnef.co/go/tools/cmd/staticcheck@latest + echo "Running golang staticcheck ..." + ${BASEDIR}/bin/staticcheck --tags=test ./... +fi echo "Running go tests..." KUBEBUILDER_ASSETS="$(pwd)/bin" ${GO} test \