ignore bin directory in various verification scripts
these scripts would choke in various ways on a vendored copy of go ignoring `bin` is the correct behaviour anyway, and should speed up running the scripts Signed-off-by: Ashley Davis <ashley.davis@jetstack.io>
This commit is contained in:
parent
c205b4d74f
commit
7a7a3951ed
@ -31,7 +31,7 @@ echo "+++ validating all scripts set '-o errexit'" >&2
|
||||
if [ "$*" != "" ]; then
|
||||
args="$*"
|
||||
else
|
||||
args=$(ls "$(pwd)" | grep -v 'bazel-' | grep -v 'external/' )
|
||||
args=$(ls "$(pwd)" | grep -v 'bazel-' | grep -v 'external/' | grep -v 'bin' )
|
||||
fi
|
||||
|
||||
# Gather the list of files that appear to be shell scripts.
|
||||
|
||||
@ -28,15 +28,20 @@ goimports=$(realpath "$1")
|
||||
# passing "-local" would be ideal, but it'll conflict with auto generated files ATM
|
||||
# and cause churn when we want to update those files
|
||||
#common_flags="-local github.com/cert-manager/cert-manager"
|
||||
|
||||
common_flags=""
|
||||
|
||||
echo "+++ running goimports" >&2
|
||||
|
||||
output=$($goimports $common_flags -l .)
|
||||
# find all directories except bin which contain go files, and output them on a single line
|
||||
|
||||
godirs=$(find . -not \( -path "./bin/*" -prune \) -name "*.go" | cut -d'/' -f2 | sort | uniq | tr '\n' ' ')
|
||||
|
||||
output=$($goimports $common_flags -l $godirs)
|
||||
|
||||
if [ ! -z "${output}" ]; then
|
||||
echo "${output}"
|
||||
echo "+++ goimports failed; the following command may fix:" >&2
|
||||
echo "+++ $goimports $common_flags -w ." &>2
|
||||
echo "+++ $goimports $common_flags -w $godirs" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@ -121,7 +121,7 @@ def file_extension(filename):
|
||||
SKIPPED_DIRS = [
|
||||
'Godeps', 'third_party', '_gopath', '_output',
|
||||
'external', '.git', 'vendor', '__init__.py',
|
||||
'node_modules',
|
||||
'node_modules', 'bin'
|
||||
]
|
||||
|
||||
# even when generated by bazel we will complain about some generated files
|
||||
@ -135,7 +135,16 @@ IGNORE_HEADERS = [
|
||||
|
||||
def has_ignored_header(pathname):
|
||||
with open(pathname, 'r', encoding="utf-8") as myfile:
|
||||
data = myfile.read()
|
||||
try:
|
||||
data = myfile.read()
|
||||
except Exception as e:
|
||||
# read() can fail if, e.g., the script tries to read a binary file;
|
||||
# we could handle UnicodeDecodeError but if the script is recursing
|
||||
# into a folder with binaries we probably want to know about it
|
||||
# so print the name of the failed file and fail loudly
|
||||
print("failed to read", pathname)
|
||||
raise
|
||||
|
||||
for header in IGNORE_HEADERS:
|
||||
if header in data:
|
||||
return True
|
||||
|
||||
Loading…
Reference in New Issue
Block a user