Fix root var and add sanity check

This commit is contained in:
Katrina Verey
2022-04-04 12:59:54 -04:00
parent 7440f974b8
commit 08924dc2f5
3 changed files with 19 additions and 8 deletions

View File

@@ -4,8 +4,8 @@ MYGOBIN = $(shell go env GOPATH)/bin
endif
export PATH := $(MYGOBIN):$(PATH)
export KUSTOMIZE_ROOT=$(shell pwd | sed 's|kustomize/.*|kustomize/|')
# only set this if not already set, so importing makefiles can override it
export KUSTOMIZE_ROOT ?= $(shell pwd | sed -E 's|(.*\/kustomize).*|\1|')
include $(KUSTOMIZE_ROOT)/Makefile-tools.mk
.PHONY: lint test fix fmt tidy vet

View File

@@ -15,8 +15,10 @@ fi
cmd=$1
seen=""
kustomize_root=$(pwd | sed 's|kustomize/.*|kustomize/|')
seen=()
# Hack scripts must be run from the root of the repository.
KUSTOMIZE_ROOT=$(pwd)
export KUSTOMIZE_ROOT
# verify all modules pass validation
for i in $(find . -name go.mod -not -path "./site/*"); do
@@ -25,18 +27,25 @@ for i in $(find . -name go.mod -not -path "./site/*"); do
set +x
dir=$(pwd)
module="${dir#$kustomize_root}"
module="${dir#$KUSTOMIZE_ROOT}"
echo -e "\n----------------------------------------------------------"
echo "Running command in $module"
echo -e "----------------------------------------------------------"
set -x
bash -c "$cmd"
seen+=" - $module\n"
seen+=("$module")
popd
done
set +x
echo -e "\n\n----------------------------------------------------------"
echo -e "SUCCESS: Ran '$cmd' on the following modules:"
echo -e "$seen"
printf " - %s\n" "${seen[@]}"
EXPECTED_MODULE_COUNT=44
if [[ "${#seen[@]}" -ne $EXPECTED_MODULE_COUNT ]]; then
echo
echo "SANITY CHECK FAILURE: Expected to see $EXPECTED_MODULE_COUNT modules, but saw ${#seen[@]}"
exit 1
fi

View File

@@ -1 +0,0 @@
../Makefile-modules.mk

3
kustomize/Makefile Normal file
View File

@@ -0,0 +1,3 @@
export KUSTOMIZE_ROOT=$(shell cd .. && pwd)
include ../Makefile-modules.mk