
Right now some of the hack/* tools use `go run` and build almost every time. There are some which expect you to have already run `go install`. And in all cases the pre-commit hook, which runs a full build wouldn't want to do either, since it just built! This creates a new hack/after-build/ directory and has the scripts which REQUIRE that the binary already be built. It doesn't test and complain. It just fails miserably. Users should not be in this directory. Users should just use hack/verify-* which will just do the build and then call the "after-build" version. The pre-commit hook or anything which KNOWS the binaries have been built can use the fast version.
144 lines
3.8 KiB
Bash
Executable File
144 lines
3.8 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
readonly reset=$(tput sgr0)
|
|
readonly red=$(tput bold; tput setaf 1)
|
|
readonly green=$(tput bold; tput setaf 2)
|
|
|
|
exit_code=0
|
|
|
|
echo -ne "Checking that it builds... "
|
|
if ! OUT=$("hack/build-go.sh" 2>&1); then
|
|
echo
|
|
echo "${red}${OUT}"
|
|
exit_code=1
|
|
else
|
|
echo "${green}OK"
|
|
fi
|
|
echo "${reset}"
|
|
|
|
echo -ne "Checking for files that need gofmt... "
|
|
files_need_gofmt=()
|
|
files=($(git diff --cached --name-only --diff-filter ACM | grep "\.go" | grep -v -e "third_party" -e "Godeps"))
|
|
for file in "${files[@]}"; do
|
|
# Check for files that fail gofmt.
|
|
diff="$(git show ":${file}" | gofmt -s -d 2>&1)"
|
|
if [[ -n "$diff" ]]; then
|
|
files_need_gofmt+=("${file}")
|
|
fi
|
|
done
|
|
|
|
if [[ "${#files_need_gofmt[@]}" -ne 0 ]]; then
|
|
echo "${red}ERROR!"
|
|
echo "Some files have not been gofmt'd. To fix these errors, "
|
|
echo "cut and paste the following:"
|
|
echo " gofmt -s -w ${files_need_gofmt[@]}"
|
|
exit_code=1
|
|
else
|
|
echo "${green}OK"
|
|
fi
|
|
echo "${reset}"
|
|
|
|
echo -ne "Checking for files that need boilerplate... "
|
|
out=($(hack/verify-boilerplate.sh))
|
|
if [[ $? -ne 0 ]]; then
|
|
echo "${red}ERROR!"
|
|
echo "Some files are missing the required boilerplate header"
|
|
echo "from hooks/boilerplate.txt:"
|
|
for f in "${out[@]}"; do
|
|
echo " ${f}"
|
|
done
|
|
exit_code=1
|
|
else
|
|
echo "${green}OK"
|
|
fi
|
|
echo "${reset}"
|
|
|
|
echo -ne "Checking for API descriptions... "
|
|
files_need_description=()
|
|
# Check API schema definitions for field descriptions
|
|
for file in $(git diff --cached --name-only --diff-filter ACM | egrep "pkg/api/v.[^/]*/types\.go" | grep -v "third_party"); do
|
|
# Check for files with fields without description tags
|
|
descriptionless=$(hack/after-build/verify-description.sh "${file}")
|
|
if [[ "$descriptionless" != "" ]]; then
|
|
files_need_description+=("${file}")
|
|
fi
|
|
done
|
|
|
|
if [[ "${#files_need_description[@]}" -ne 0 ]]; then
|
|
echo "${red}ERROR!"
|
|
echo "Some API files are missing the required field descriptions."
|
|
echo "Add description tags to all non-inline fields in the following files:"
|
|
for file in "${files_need_description[@]}"; do
|
|
echo " ${file}"
|
|
done
|
|
exit_code=1
|
|
else
|
|
echo "${green}OK"
|
|
fi
|
|
echo "${reset}"
|
|
|
|
echo -ne "Checking for links in API descriptions... "
|
|
if ! hack/after-build/verify-linkcheck.sh > /dev/null; then
|
|
echo "${red}ERROR!"
|
|
echo "Some links in pkg/api/.*types.go are outdated. They require a manual fix."
|
|
exit_code=1
|
|
else
|
|
echo "${green}OK"
|
|
fi
|
|
echo "${reset}"
|
|
|
|
echo -ne "Checking for docs that need updating... "
|
|
if ! hack/after-build/verify-generated-docs.sh > /dev/null; then
|
|
echo "${red}ERROR!"
|
|
echo "Some docs are out of sync between CLI and markdown."
|
|
echo "To regenerate docs, run:"
|
|
echo " hack/update-generated-docs.sh"
|
|
exit_code=1
|
|
else
|
|
echo "${green}OK"
|
|
fi
|
|
echo "${reset}"
|
|
|
|
echo -ne "Checking for conversions that need updating... "
|
|
if ! hack/after-build/verify-generated-conversions.sh > /dev/null; then
|
|
echo "${red}ERROR!"
|
|
echo "Some conversions functions need regeneration."
|
|
echo "To regenerate conversions, run:"
|
|
echo " hack/update-generated-conversions.sh"
|
|
exit_code=1
|
|
else
|
|
echo "${green}OK"
|
|
fi
|
|
echo "${reset}"
|
|
|
|
echo -ne "Checking for deep-copies that need updating... "
|
|
if ! hack/after-build/verify-generated-deep-copies.sh > /dev/null; then
|
|
echo "${red}ERROR!"
|
|
echo "Some deep-copy functions need regeneration."
|
|
echo "To regenerate deep-copies, run:"
|
|
echo " hack/update-generated-deep-copies.sh"
|
|
exit_code=1
|
|
else
|
|
echo "${green}OK"
|
|
fi
|
|
echo "${reset}"
|
|
|
|
echo -ne "Checking for swagger spec that need updating... "
|
|
if ! hack/after-build/verify-swagger-spec.sh > /dev/null; then
|
|
echo "${red}ERROR!"
|
|
echo "Swagger spec needs to be updated."
|
|
echo "To regenerate the spec, run:"
|
|
echo " hack/update-swagger-spec.sh"
|
|
exit_code=1
|
|
else
|
|
echo "${green}OK"
|
|
fi
|
|
echo "${reset}"
|
|
|
|
if [[ "${exit_code}" != 0 ]]; then
|
|
echo "${red}Aborting commit${reset}"
|
|
fi
|
|
exit ${exit_code}
|
|
|
|
# ex: ts=2 sw=2 et filetype=sh
|