Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 45 additions & 7 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")
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 @@ -16,26 +22,58 @@ do
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 toolchain common version in dependent repos"
go mod edit -replace github.com/codeready-toolchain/toolchain-common=${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
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