diff --git a/Makefile b/Makefile index a3a4fc4802..7bdfbb0934 100644 --- a/Makefile +++ b/Makefile @@ -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): @@ -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)" diff --git a/build/format-vet.sh b/build/format-vet.sh new file mode 100755 index 0000000000..b782a893e5 --- /dev/null +++ b/build/format-vet.sh @@ -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" \ No newline at end of file diff --git a/build/test.sh b/build/test.sh index 58410d46b4..c5d956b41f 100755 --- a/build/test.sh +++ b/build/test.sh @@ -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