Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KUBESAW-174: Print error output for repos where verification failed #458

Merged
merged 13 commits into from
Jan 31, 2025
56 changes: 47 additions & 9 deletions scripts/verify-replace.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@ GH_BASE_URL_KS=https://github.com/kubesaw/
GH_BASE_URL_CRT=https://github.com/codeready-toolchain/
declare -a REPOS=("${GH_BASE_URL_KS}ksctl" "${GH_BASE_URL_CRT}host-operator" "${GH_BASE_URL_CRT}member-operator" "${GH_BASE_URL_CRT}registration-service" "${GH_BASE_URL_CRT}toolchain-e2e" "${GH_BASE_URL_CRT}toolchain-common")
C_PATH=${PWD}
ERRORLIST=()
ERROR_REPO_LIST=()
ERROR_FILE_LIST=()
STD_OUT_FILE_LIST=()
GO_LINT_REGEX="[\s\w.\/]*:[0-9]*:[0-9]*:[\w\s)(*.\`]*"
ERROR_REGEX="[E\|e][R\|r][R\|r][O\|o][R\|r][:]*\|[F\|f][A\|a][I\|i][l\|L][:]*\|expected[:]*\|actual[:]*" #unit test or any other failure we log from our controllers or other places goes into stdoutput
#(since we log it and its not a failure in running the command or dependency check),
#hence making that regex too, to fetch the error more precisely

echo Initiating verify-replace on dependent repos
for repo in "${REPOS[@]}"
Expand All @@ -14,28 +20,60 @@ do
echo
echo "$(basename ${repo})"
echo
echo =========================================================================================
echo =========================================================================================
repo_path=${BASE_REPO_PATH}/$(basename ${repo})
err_file=$(mktemp ${BASE_REPO_PATH}/$(basename ${repo})-error.XXX)
echo "error output file : ${err_file}"
std_out_file=$(mktemp ${BASE_REPO_PATH}/$(basename ${repo})-output.XXX)
echo "std output file : ${std_out_file}"
echo "Cloning repo in /tmp"
git clone --depth=1 ${repo} ${repo_path}
echo "Repo cloned successfully"
cd ${repo_path}
if ! make pre-verify; then
ERRORLIST+="($(basename ${repo}))"
make pre-verify 2> >(tee ${err_file})
rc=$?
if [ ${rc} -ne 0 ]; then
ERROR_REPO_LIST+="$(basename ${repo}) "
ERROR_FILE_LIST+="${err_file} "
continue
fi
echo "Initiating 'go mod replace' of current api version in dependent repos"
go mod edit -replace github.com/codeready-toolchain/api=${C_PATH}
make verify-dependencies || ERRORLIST+="($(basename ${repo}))"
make verify-dependencies 2> >(tee ${err_file}) 1> >(tee ${std_out_file})
rc=$?
if [ ${rc} -ne 0 ]; then
ERROR_REPO_LIST+="$(basename ${repo}) "
ERROR_FILE_LIST+="${err_file} "
STD_OUT_FILE_LIST+="${std_out_file} "
fi
echo
echo =========================================================================================
echo
echo
done
if [ ${#ERRORLIST[@]} -ne 0 ]; then
echo "Summary"
if [ ${#ERROR_REPO_LIST[@]} -ne 0 ]; then
echo "Below are the repos with error: "
for e in ${ERRORLIST[*]}
for error_repo_name in ${ERROR_REPO_LIST[*]}
do
echo "${e}"
echo
echo =========================================================================================
echo
echo "${error_repo_name} has the following errors "
echo
echo =========================================================================================
echo
for error_file_name in ${ERROR_FILE_LIST[*]}
do
if [[ ${error_file_name} =~ ${error_repo_name} ]]; then
cat "${error_file_name}"
fi
done
for std_out_file_name in ${STD_OUT_FILE_LIST[*]}
do
if [[ ${std_out_file_name} =~ ${error_repo_name} ]]; then
cat "${std_out_file_name}" | grep -C 5 "${GO_LINT_REGEX}\|${ERROR_REGEX}"
fi
done
done
exit 1
else
Expand Down
Loading