diff --git a/make/go.mk b/make/go.mk index ccfd807a..dba57125 100644 --- a/make/go.mk +++ b/make/go.mk @@ -27,4 +27,8 @@ tidy: .PHONY: vet vet: - go vet ./... \ No newline at end of file + go vet ./... + +.PHONY: verify-replace-run +verify-replace-run: + ./scripts/verify-replace.sh; \ No newline at end of file diff --git a/scripts/verify-replace.sh b/scripts/verify-replace.sh new file mode 100755 index 00000000..3dbc8d9e --- /dev/null +++ b/scripts/verify-replace.sh @@ -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 + exit 1 +else + echo "No errors detected" +fi \ No newline at end of file