2014-06-06 23:40:48 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2015-05-13 19:59:04 +00:00
|
|
|
readonly reset=$(tput sgr0)
|
2016-04-20 03:36:14 +00:00
|
|
|
readonly red=$(tput bold; tput setaf 1)
|
2015-05-13 19:59:04 +00:00
|
|
|
readonly green=$(tput bold; tput setaf 2)
|
|
|
|
|
2015-05-13 05:47:24 +00:00
|
|
|
exit_code=0
|
2015-05-01 18:57:03 +00:00
|
|
|
|
2015-07-02 21:29:59 +00:00
|
|
|
echo -ne "Checking that it builds... "
|
2016-05-24 15:40:44 +00:00
|
|
|
if ! OUT=$(make 2>&1); then
|
2015-07-02 21:29:59 +00:00
|
|
|
echo
|
|
|
|
echo "${red}${OUT}"
|
|
|
|
exit_code=1
|
|
|
|
else
|
|
|
|
echo "${green}OK"
|
|
|
|
fi
|
|
|
|
echo "${reset}"
|
|
|
|
|
2016-02-12 19:33:32 +00:00
|
|
|
# Check if changes to Godeps are reproducible...
|
2015-08-04 04:45:39 +00:00
|
|
|
files=($(git diff --cached --name-only --diff-filter ACM | grep "Godeps"))
|
|
|
|
if [[ "${#files[@]}" -ne 0 ]]; then
|
2016-02-12 19:33:32 +00:00
|
|
|
echo -ne "Check if changes to Godeps are reproducible (this is pretty slow)..."
|
2015-08-04 04:45:39 +00:00
|
|
|
if ! OUT=$("hack/verify-godeps.sh" 2>&1); then
|
|
|
|
echo
|
|
|
|
echo "${red}${OUT}"
|
|
|
|
exit_code=1
|
|
|
|
else
|
|
|
|
echo "${green}OK"
|
|
|
|
fi
|
|
|
|
echo "${reset}"
|
2015-12-08 21:23:59 +00:00
|
|
|
|
2016-06-18 17:00:49 +00:00
|
|
|
echo -ne "Check if Godep licenses are up to date..."
|
2015-12-08 21:23:59 +00:00
|
|
|
if ! OUT=$("hack/verify-godep-licenses.sh" 2>&1); then
|
|
|
|
echo
|
|
|
|
echo "${red}${OUT}"
|
|
|
|
exit_code=1
|
|
|
|
else
|
|
|
|
echo "${green}OK"
|
|
|
|
fi
|
|
|
|
echo "${reset}"
|
2015-08-04 04:45:39 +00:00
|
|
|
fi
|
|
|
|
|
2015-05-13 05:47:24 +00:00
|
|
|
echo -ne "Checking for files that need gofmt... "
|
|
|
|
files_need_gofmt=()
|
2016-04-14 06:30:15 +00:00
|
|
|
files=($(git diff --cached --name-only --diff-filter ACM | grep "\.go" | grep -v -e "^third_party" -e "^vendor"))
|
2015-05-01 18:57:03 +00:00
|
|
|
for file in "${files[@]}"; do
|
2014-06-24 22:01:08 +00:00
|
|
|
# Check for files that fail gofmt.
|
2015-07-02 21:29:59 +00:00
|
|
|
diff="$(git show ":${file}" | gofmt -s -d 2>&1)"
|
2014-06-06 23:40:48 +00:00
|
|
|
if [[ -n "$diff" ]]; then
|
2014-11-20 00:05:55 +00:00
|
|
|
files_need_gofmt+=("${file}")
|
2014-06-06 23:40:48 +00:00
|
|
|
fi
|
2014-06-26 00:11:48 +00:00
|
|
|
done
|
|
|
|
|
2015-05-13 05:47:24 +00:00
|
|
|
if [[ "${#files_need_gofmt[@]}" -ne 0 ]]; then
|
2015-05-13 19:59:04 +00:00
|
|
|
echo "${red}ERROR!"
|
2016-06-18 17:00:49 +00:00
|
|
|
echo "Some files have not been gofmt'd. To fix these errors, "
|
|
|
|
echo "copy and paste the following:"
|
2015-05-13 05:47:24 +00:00
|
|
|
echo " gofmt -s -w ${files_need_gofmt[@]}"
|
|
|
|
exit_code=1
|
|
|
|
else
|
2015-05-13 19:59:04 +00:00
|
|
|
echo "${green}OK"
|
2015-05-13 05:47:24 +00:00
|
|
|
fi
|
2015-05-13 19:59:04 +00:00
|
|
|
echo "${reset}"
|
2015-05-13 05:47:24 +00:00
|
|
|
|
2016-11-29 08:52:32 +00:00
|
|
|
echo -ne "Checking for package aliases... "
|
|
|
|
if ! hack/verify-pkg-names.sh > /dev/null; then
|
|
|
|
echo "${red}ERROR!"
|
|
|
|
echo "Some package aliase break go conventions. To fix these errors, "
|
|
|
|
echo "do not use capitalizaed or underlined characters in pkg aliases. "
|
|
|
|
echo "Refer to https://blog.golang.org/package-names for more info."
|
|
|
|
exit_code=1
|
|
|
|
else
|
|
|
|
echo "${green}OK"
|
|
|
|
fi
|
|
|
|
echo "${reset}"
|
|
|
|
|
2015-05-13 05:47:24 +00:00
|
|
|
echo -ne "Checking for files that need boilerplate... "
|
2015-05-09 16:21:10 +00:00
|
|
|
files=($(git diff --cached --name-only --diff-filter ACM))
|
2015-08-17 02:58:22 +00:00
|
|
|
# We always make sure there is one file in the files list. Some tools check
|
|
|
|
# the whole repo if they get no files, so in fact, this is much faster on
|
|
|
|
# git commit --amend
|
|
|
|
if [[ ${#files[@]} -eq 0 ]]; then
|
|
|
|
files+=("README.md")
|
|
|
|
fi
|
2015-05-09 16:21:10 +00:00
|
|
|
out=($(hack/boilerplate/boilerplate.py "${files[@]}"))
|
|
|
|
if [[ "${#out}" -ne 0 ]]; then
|
2015-05-13 19:59:04 +00:00
|
|
|
echo "${red}ERROR!"
|
2015-05-13 05:47:24 +00:00
|
|
|
echo "Some files are missing the required boilerplate header"
|
2015-05-09 16:21:10 +00:00
|
|
|
echo "from hack/boilerplate/boilerplate.*.txt:"
|
2015-07-20 00:02:47 +00:00
|
|
|
for f in "${out[@]}"; do
|
|
|
|
echo " ${f}"
|
2015-05-13 05:47:24 +00:00
|
|
|
done
|
|
|
|
exit_code=1
|
|
|
|
else
|
2015-05-13 19:59:04 +00:00
|
|
|
echo "${green}OK"
|
2015-05-13 05:47:24 +00:00
|
|
|
fi
|
2015-05-13 19:59:04 +00:00
|
|
|
echo "${reset}"
|
2015-05-13 05:47:24 +00:00
|
|
|
|
2015-08-07 14:02:34 +00:00
|
|
|
echo -ne "Checking for problems with flag names... "
|
2015-08-17 02:58:22 +00:00
|
|
|
invalid_flag_lines=$(hack/verify-flags-underscore.py "${files[@]}")
|
2015-08-07 14:02:34 +00:00
|
|
|
if [[ "${invalid_flag_lines:-}" != "" ]]; then
|
|
|
|
echo "${red}ERROR!"
|
2016-06-18 17:00:49 +00:00
|
|
|
echo "There appear to be problems with the following:"
|
2015-08-07 14:02:34 +00:00
|
|
|
for line in "${invalid_flag_lines[@]}"; do
|
|
|
|
echo " ${line}"
|
|
|
|
done
|
|
|
|
exit_code=1
|
|
|
|
else
|
|
|
|
echo "${green}OK"
|
|
|
|
fi
|
|
|
|
echo "${reset}"
|
|
|
|
|
2015-05-13 05:47:24 +00:00
|
|
|
echo -ne "Checking for API descriptions... "
|
|
|
|
files_need_description=()
|
2014-11-20 00:05:55 +00:00
|
|
|
# Check API schema definitions for field descriptions
|
2015-05-01 18:10:50 +00:00
|
|
|
for file in $(git diff --cached --name-only --diff-filter ACM | egrep "pkg/api/v.[^/]*/types\.go" | grep -v "third_party"); do
|
2014-11-20 00:05:55 +00:00
|
|
|
# Check for files with fields without description tags
|
2016-05-04 05:00:27 +00:00
|
|
|
descriptionless=$(hack/verify-description.sh "${file}" > /dev/null; echo $?)
|
2015-07-05 17:15:36 +00:00
|
|
|
if [[ "$descriptionless" -ne "0" ]]; then
|
2014-11-20 00:05:55 +00:00
|
|
|
files_need_description+=("${file}")
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
if [[ "${#files_need_description[@]}" -ne 0 ]]; then
|
2015-05-13 19:59:04 +00:00
|
|
|
echo "${red}ERROR!"
|
2015-05-13 05:47:24 +00:00
|
|
|
echo "Some API files are missing the required field descriptions."
|
|
|
|
echo "Add description tags to all non-inline fields in the following files:"
|
2015-05-13 04:59:44 +00:00
|
|
|
for file in "${files_need_description[@]}"; do
|
2015-05-13 05:47:24 +00:00
|
|
|
echo " ${file}"
|
2015-05-13 04:59:44 +00:00
|
|
|
done
|
2015-05-13 05:47:24 +00:00
|
|
|
exit_code=1
|
|
|
|
else
|
2015-05-13 19:59:04 +00:00
|
|
|
echo "${green}OK"
|
2014-11-20 00:05:55 +00:00
|
|
|
fi
|
2015-05-13 19:59:04 +00:00
|
|
|
echo "${reset}"
|
2015-01-15 05:27:13 +00:00
|
|
|
|
2015-07-05 17:15:36 +00:00
|
|
|
echo -ne "Checking for swagger type documentation that need updating... "
|
2016-05-04 05:00:27 +00:00
|
|
|
if ! hack/verify-generated-swagger-docs.sh > /dev/null; then
|
2015-07-05 17:15:36 +00:00
|
|
|
echo "${red}ERROR!"
|
|
|
|
echo "Swagger type documentation needs to be updated."
|
|
|
|
echo "To regenerate the spec, run:"
|
|
|
|
echo " hack/update-generated-swagger-docs.sh"
|
|
|
|
exit_code=1
|
|
|
|
else
|
|
|
|
echo "${green}OK"
|
|
|
|
fi
|
|
|
|
echo "${reset}"
|
|
|
|
|
2015-06-08 08:38:08 +00:00
|
|
|
echo -ne "Checking for swagger spec that need updating... "
|
2016-05-04 05:00:27 +00:00
|
|
|
if ! hack/verify-swagger-spec.sh > /dev/null; then
|
2015-06-08 08:38:08 +00:00
|
|
|
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}"
|
|
|
|
|
2016-09-28 06:55:45 +00:00
|
|
|
echo -ne "Checking for openapi spec that need updating... "
|
|
|
|
if ! hack/verify-openapi-spec.sh > /dev/null; then
|
|
|
|
echo "${red}ERROR!"
|
|
|
|
echo "Openapi spec needs to be updated."
|
|
|
|
echo "To regenerate the spec, run:"
|
|
|
|
echo " hack/update-openapi-spec.sh"
|
|
|
|
exit_code=1
|
|
|
|
else
|
|
|
|
echo "${green}OK"
|
|
|
|
fi
|
|
|
|
echo "${reset}"
|
|
|
|
|
2016-11-04 00:10:07 +00:00
|
|
|
echo -ne "Checking for federation openapi spec that need updating... "
|
|
|
|
if ! hack/verify-federation-openapi-spec.sh > /dev/null; then
|
|
|
|
echo "${red}ERROR!"
|
|
|
|
echo "Federation OpenAPI spec needs to be updated."
|
|
|
|
echo "To regenerate the spec, run:"
|
|
|
|
echo " hack/update-federation-openapi-spec.sh"
|
|
|
|
exit_code=1
|
|
|
|
else
|
|
|
|
echo "${green}OK"
|
|
|
|
fi
|
|
|
|
echo "${reset}"
|
|
|
|
|
2015-07-02 21:29:59 +00:00
|
|
|
if [[ "${exit_code}" != 0 ]]; then
|
|
|
|
echo "${red}Aborting commit${reset}"
|
|
|
|
fi
|
|
|
|
exit ${exit_code}
|
2015-08-10 16:38:15 +00:00
|
|
|
|
|
|
|
# ex: ts=2 sw=2 et filetype=sh
|