Skip to content

Commit

Permalink
Skip Static test
Browse files Browse the repository at this point in the history
In order to run upstream tests in a container with make test we need to
be able to skip the static check

Signed-off-by: Benjamin Pickard <[email protected]>
  • Loading branch information
bpickard22 committed Nov 26, 2024
1 parent 5d5a98d commit 1206009
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 7 deletions.
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ COMPUTE_NODES ?= 2

OCI_BIN ?= docker

SKIP_STATIC_CHECK ?= false

build:
hack/build-go.sh

Expand All @@ -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)
Expand Down
29 changes: 23 additions & 6 deletions hack/test-go.sh
Original file line number Diff line number Diff line change
@@ -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 \
Expand Down

0 comments on commit 1206009

Please sign in to comment.