Merge pull request #5113 from SgtCoDFish/verify-improve
Improve various verification scripts
This commit is contained in:
commit
7c5e5d6f65
@ -18,13 +18,14 @@ set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
if [ -z "${1:-}" ]; then
|
||||
chart_tarball=${1:-}
|
||||
DOCKER=${DOCKER:-docker}
|
||||
|
||||
if [ -z "${chart_tarball}" ]; then
|
||||
echo "usage: $0 <path to helm chart tarball>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
chart_tarball=$1
|
||||
|
||||
chart_dir="deploy/charts/cert-manager"
|
||||
|
||||
echo "Linting chart '${chart_tarball}' using internal dir '${chart_dir}'"
|
||||
@ -34,8 +35,8 @@ trap "rm -rf ${tmpdir}" EXIT
|
||||
|
||||
tar -C "${tmpdir}" -xvf $chart_tarball
|
||||
|
||||
if ! docker run -v "${tmpdir}":/workspace --workdir /workspace \
|
||||
quay.io/helmpack/chart-testing:v3.5.0 \
|
||||
if ! ${DOCKER} run -v "${tmpdir}":/workspace --workdir /workspace \
|
||||
quay.io/helmpack/chart-testing:v3.5.1 \
|
||||
ct lint \
|
||||
--check-version-increment=false \
|
||||
--validate-maintainers=false \
|
||||
|
||||
@ -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
|
||||
|
||||
@ -9,7 +9,7 @@ verify-imports: bin/tools/goimports
|
||||
|
||||
.PHONY: verify-chart
|
||||
verify-chart: bin/cert-manager-$(RELEASE_VERSION).tgz
|
||||
./hack/verify-chart-version.sh $<
|
||||
DOCKER=$(CTR) ./hack/verify-chart-version.sh $<
|
||||
|
||||
.PHONY: verify-errexit
|
||||
verify-errexit:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user