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-129: Makefile target to check compatibility of local version with other repos #417

Merged
merged 20 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
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
6 changes: 5 additions & 1 deletion make/go.mk
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,8 @@ tidy:

.PHONY: vet
vet:
go vet ./...
go vet ./...

.PHONY: verify-replace-run
verify-replace-run:
./scripts/verify-replace.sh;
39 changes: 39 additions & 0 deletions scripts/verify-replace.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash
TMP_DIR=/tmp/
BASE_REPO_PATH=$(mktemp -d ${TMP_DIR}replace-verify.XXX)
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=()

echo Initiating verify-replace on dependent repos
for repo in "${REPOS[@]}"
do
echo =========================================================================================
echo
echo "$(basename ${repo})"
echo
echo =========================================================================================
repo_path=${BASE_REPO_PATH}/$(basename ${repo})
echo "Cloning repo in /tmp"
git clone --depth=1 ${repo} ${repo_path}
echo "Repo cloned successfully"
cd ${repo_path}
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}))"
echo
echo =========================================================================================
echo
done
if [ ${#ERRORLIST[@]} -ne 0 ]; then
echo "Below are the repos with error: "
for e in ${ERRORLIST[*]}
do
echo "${e}"
done
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should exit with a non-zero value if something failed, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure if we require the non zero exit here ?,
here we are just displaying the error repo names, and error list is already being checked if its empty or not , so my understanding was we dont require exit here.?
Probably i am missing something here 🤔

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if one of the verification failed, then we want the whole makefile target to return non-zero value (in other words let it fail as well)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated it

exit 1
else
echo "No errors detected"
fi
Loading