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
51 changes: 43 additions & 8 deletions scripts/verify-replace.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ 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=()
ERRORREPOLIST=()
ERRORFILELIST=()
STDOUTFILELIST=()
GOLINTREGEX="[\s\w.\/]*:[0-9]*:[0-9]*:[\w\s)(*.\`]*"
LINTERERRORFILE=$(mktemp ${TMP_DIR}LinterError.XXX)
fbm3307 marked this conversation as resolved.
Show resolved Hide resolved

echo Initiating verify-replace on dependent repos
for repo in "${REPOS[@]}"
Expand All @@ -14,28 +18,59 @@ do
echo
echo "$(basename ${repo})"
echo
echo =========================================================================================
echo =========================================================================================
repo_path=${BASE_REPO_PATH}/$(basename ${repo})
ERRFILE=$(mktemp ${TMP_DIR}$(basename ${repo})-error.XXX)
STDOUTFILE=$(mktemp ${TMP_DIR}$(basename ${repo})-output.XXX)
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}))"
ERRORREPOLIST+="$(basename ${repo}) "
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> ${ERRFILE} 1> ${STDOUTFILE}
rc=$?
if [ ${rc} -ne 0 ]; then
ERRORREPOLIST+="$(basename ${repo}) "
ERRORFILELIST+="${ERRFILE} "
STDOUTFILELIST="${STDOUTFILE} "
fi
echo
echo =========================================================================================
echo
echo
done
if [ ${#ERRORLIST[@]} -ne 0 ]; then
echo "Summary"
if [ ${#ERRORREPOLIST[@]} -ne 0 ]; then
echo "Below are the repos with error: "
for e in ${ERRORLIST[*]}
for e in ${ERRORREPOLIST[*]}
do
echo "${e}"
for c in ${ERRORFILELIST[*]}
do
if [[ ${c} =~ ${e} ]]; then
echo
echo =========================================================================================
echo
echo "${e} has the following errors "
echo
echo =========================================================================================
echo
cat "${c}"
else
for s in ${STDOUTFILELIST[*]}
do
if [[ ${s} =~ ${e} ]]; then
cat "${s}" | grep -E ${GOLINTREGEX} > ${LINTERERRORFILE}
if ! [ -s "${LINTERERRORFILE}" ]; then
cat "${LINTERERRORFILE}"
fi
fbm3307 marked this conversation as resolved.
Show resolved Hide resolved
fi
done
fi
done
done
exit 1
else
Expand Down
Loading