Skip to content

Commit

Permalink
Fix root var and add sanity check
Browse files Browse the repository at this point in the history
  • Loading branch information
KnVerey committed Apr 4, 2022
1 parent 7440f97 commit 56758be
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Makefile-modules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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 's|kustomize/.*|kustomize/|')
include $(KUSTOMIZE_ROOT)/Makefile-tools.mk

.PHONY: lint test fix fmt tidy vet
Expand Down
19 changes: 14 additions & 5 deletions hack/for-each-module.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 | sed 's|.*/kustomize/||')
export KUSTOMIZE_ROOT

# verify all modules pass validation
for i in $(find . -name go.mod -not -path "./site/*"); do
Expand All @@ -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
1 change: 0 additions & 1 deletion kustomize/Makefile

This file was deleted.

3 changes: 3 additions & 0 deletions kustomize/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export KUSTOMIZE_ROOT ?= $(shell cd .. && pwd)

include ../Makefile-modules.mk

0 comments on commit 56758be

Please sign in to comment.