Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip Static test #516

Merged
merged 1 commit into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ COMPUTE_NODES ?= 2

OCI_BIN ?= docker


build:
hack/build-go.sh

Expand All @@ -23,7 +24,10 @@ install-tools:
hack/install-kubebuilder-tools.sh

test: build install-tools
hack/test-go.sh
hack/test-go.sh

test-skip-static: build
hack/test-go.sh --skip-static-check

kind:
hack/e2e-setup-kind-cluster.sh -n $(COMPUTE_NODES)
Expand Down
30 changes: 24 additions & 6 deletions hack/test-go.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,38 @@
#!/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}
SKIP_STATIC_CHECK=$false
#parse args
while [[ $# -gt 0 ]]; do
case "$1" in
-s|--skip-static-check)
SKIP_STATIC_CHECK=true
shift
;;
*)
echo "Invalid arguement: $1"
echo "Usage: $0 [-s|--skip-static-check]"
exit 1
esac
done
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SKIP_STATIC_CHECK=true

# Parse arguments
while [[ $# -gt 0 ]]; do
  case "$1" in
    -s|--skip-static-check)
      SKIP_STATIC_CHECK=false
      shift
      ;;
    *)
      echo "Invalid argument: $1"
      echo "Usage: $0 [-s|--skip-static-check]"
      exit 1
      ;;
  esac
done

And then you can use it just like ./test.sh --flag-here and not set true/false


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
Loading