Skip to content

Commit

Permalink
makefile target to check compatibility of local version with other re…
Browse files Browse the repository at this point in the history
…pos (#437)
  • Loading branch information
fbm3307 authored Aug 23, 2024
1 parent d0c164a commit de5ee82
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
4 changes: 4 additions & 0 deletions make/go.mk
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@ GO_PACKAGE_PATH ?= github.com/${GO_PACKAGE_ORG_NAME}/${GO_PACKAGE_REPO_NAME}
build:
$(Q)CGO_ENABLED=0 GOARCH=amd64 GOOS=linux \
$(GO) build github.com/codeready-toolchain/api/api/v1alpha1/

.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" "${GH_BASE_URL_CRT}toolchain-common")
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 api version in dependent repos"
go mod edit -replace github.com/codeready-toolchain/api=${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

0 comments on commit de5ee82

Please sign in to comment.