Skip to content

Commit

Permalink
test: add faster test target go-test which does not run go vet (#3138)
Browse files Browse the repository at this point in the history
  • Loading branch information
hairyhum authored Sep 18, 2024
1 parent e1652d2 commit 875333f
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 27 deletions.
9 changes: 7 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ push-name:
version:
@echo $(VERSION)

.PHONY: deploy test codegen build-dirs run clean container-clean bin-clean docs start-kind tiller stop-kind release-snapshot go-mod-download
.PHONY: deploy format-vet go-test test codegen build-dirs run clean container-clean bin-clean docs start-kind tiller stop-kind release-snapshot go-mod-download

deploy: release-controller .deploy-$(DOTFILE_IMAGE)
.deploy-$(DOTFILE_IMAGE):
Expand All @@ -158,9 +158,14 @@ deploy: release-controller .deploy-$(DOTFILE_IMAGE)
bundle.yaml.in > .deploy-$(DOTFILE_IMAGE)
@kubectl apply -f .deploy-$(DOTFILE_IMAGE)

test: build-dirs
format-vet: build-dirs
@$(MAKE) run CMD="./build/format-vet.sh $(SRC_DIRS)"

go-test: build-dirs
@$(MAKE) run CMD="TEST_FILTER=$(TEST_FILTER) ./build/test.sh $(SRC_DIRS)"

test: format-vet go-test

helm-test: build-dirs
@$(MAKE) run CMD="./build/helm-test.sh $(SRC_DIRS)"

Expand Down
41 changes: 41 additions & 0 deletions build/format-vet.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/bash

# Copyright 2024 The Kanister 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 -o errexit
set -o nounset

export CGO_ENABLED=0
export GO111MODULE=on

TARGETS=$(for d in "$@"; do echo ./$d/...; done)

echo -n "Checking gofmt: "
ERRS=$(find "$@" -type f -name \*.go | xargs gofmt -l 2>&1 || true)
if [ -n "${ERRS}" ]; then
echo "FAIL - the following files need to be gofmt'ed:"
for e in ${ERRS}; do
echo " $e"
done
echo
exit 1
fi
echo "PASS"
echo

echo -n "Checking go vet: "
go vet ${TARGETS}
echo "PASS"
25 changes: 0 additions & 25 deletions build/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,31 +33,6 @@ fi

TARGETS=$(for d in "$@"; do echo ./$d/...; done)

echo -n "Checking gofmt: "
ERRS=$(find "$@" -type f -name \*.go | xargs gofmt -l 2>&1 || true)
if [ -n "${ERRS}" ]; then
echo "FAIL - the following files need to be gofmt'ed:"
for e in ${ERRS}; do
echo " $e"
done
echo
exit 1
fi
echo "PASS"
echo

echo -n "Checking go vet: "
ERRS=$(go vet ${TARGETS} 2>&1 || true)
if [ -n "${ERRS}" ]; then
echo "FAIL"
echo "${ERRS}"
echo
# TODO: Renable govet. Currently generated code fails to pass go vet. report,
# but don't exit on failures.
#exit 1
fi
echo

check_dependencies() {
# Check if minio is already deployed. We suppress only `stdout` and not `stderr` to make sure we catch errors if `helm status` fails
if helm status minio -n minio 1> /dev/null ; then
Expand Down

0 comments on commit 875333f

Please sign in to comment.