99WAS_ALREADY_PAIRED_FILE=/tmp/toolchain_e2e_already_paired
1010
1111get_repo () {
12- PAIRED=false
1312 if [[ -z ${PROVIDED_REPOSITORY_PATH} ]]; then
1413 REPOSITORY_PATH=" /tmp/codeready-toolchain/${REPOSITORY_NAME} "
15- rm -rf ${REPOSITORY_PATH}
16- # clone
17- git clone https://github.com/codeready-toolchain/${REPOSITORY_NAME} .git ${REPOSITORY_PATH}
18-
19- pair_repo_if_needed
14+
15+ ${PAIRING_EXEC} pair --clone-dir ${REPOSITORY_PATH} --organization codeready-toolchain --repository ${REPOSITORY_NAME}
2016 else
2117 REPOSITORY_PATH=${PROVIDED_REPOSITORY_PATH}
2218 fi
23-
2419}
2520
2621set_tags () {
@@ -47,117 +42,11 @@ set_tags() {
4742push_image () {
4843 GIT_COMMIT_ID=$( git --git-dir=${REPOSITORY_PATH} /.git --work-tree=${REPOSITORY_PATH} rev-parse --short HEAD)
4944 IMAGE_LOC=quay.io/codeready-toolchain/${REPOSITORY_NAME} :${GIT_COMMIT_ID}
50- if is_provided_or_paired; then
51- IMAGE_BUILDER=${IMAGE_BUILDER:- " podman" }
52- make -C ${REPOSITORY_PATH} ${IMAGE_BUILDER} -push QUAY_NAMESPACE=${QUAY_NAMESPACE} IMAGE_TAG=${TAGS}
53- IMAGE_LOC=quay.io/${QUAY_NAMESPACE} /${REPOSITORY_NAME} :${TAGS}
54- fi
45+ IMAGE_BUILDER=${IMAGE_BUILDER:- " podman" }
46+ make -C ${REPOSITORY_PATH} ${IMAGE_BUILDER} -push QUAY_NAMESPACE=${QUAY_NAMESPACE} IMAGE_TAG=${TAGS}
47+ IMAGE_LOC=quay.io/${QUAY_NAMESPACE} /${REPOSITORY_NAME} :${TAGS}
5548}
5649
57- is_provided_or_paired () {
58- [[ -n ${PROVIDED_REPOSITORY_PATH} ]] || [[ ${PAIRED} == true ]]
59- }
60-
61- pair_repo_if_needed () {
62- if [[ -n ${GITHUB_ACTIONS} ]]; then
63- PR_REPO_NAME=${GITHUB_REPOSITORY##*/ }
64- else
65- PR_REPO_NAME=$( echo ${REPO_NAME} | sed ' s/"//g' )
66- fi
67-
68-
69- if [[ -n " ${CI}${CLONEREFS_OPTIONS} " ]] && [[ ${PR_REPO_NAME} == " toolchain-e2e" ]]; then
70- if [[ -n ${CLONEREFS_OPTIONS} ]]; then
71- # get branch ref of the fork the PR was created from
72- AUTHOR_LINK=$( jq -r ' .refs[0].pulls[0].author_link' <<< ${CLONEREFS_OPTIONS} | tr -d ' [:space:]' )
73- PULL_PULL_SHA=${PULL_PULL_SHA:- $(jq -r ' .refs[0].pulls[0].sha' <<< ${CLONEREFS_OPTIONS} | tr -d ' [:space:]' )}
74- echo " using author link ${AUTHOR_LINK} "
75- echo " using pull sha ${PULL_PULL_SHA} "
76- # get branch ref of the fork the PR was created from
77- REPO_URL=${AUTHOR_LINK} /toolchain-e2e
78- echo " branches of ${REPO_URL} - trying to detect the branch name we should use for pairing."
79- curl ${REPO_URL} .git/info/refs? service=git-upload-pack --output -
80- GET_BRANCH_NAME=$( curl ${REPO_URL} .git/info/refs? service=git-upload-pack --output - 2> /dev/null | grep -a ${PULL_PULL_SHA} || true)
81- if [[ $( echo ${GET_BRANCH_NAME} | wc -l) > 1 ]]; then \
82- echo " ################################### ERROR DURING THE E2E TEST SETUP ###################################
83- There were found more branches with the same latest commit '${PULL_PULL_SHA} ' in the repo ${REPO_URL} - see:
84-
85- ${GET_BRANCH_NAME}
86-
87- It's not possible to detect the correct branch this PR is made for.
88- Please delete the unrelated branch from your fork and rerun the e2e tests.
89- Note: If you have already deleted the unrelated branch from your fork, it can take a few hours before the
90- github api is updated so the e2e tests may still fail with the same error until then.
91- ##########################################################################################################"
92- exit 1
93- fi
94- BRANCH_REF=$( echo ${GET_BRANCH_NAME} | awk ' {print $2}' )
95- echo " detected branch ref ${BRANCH_REF} "
96- # retrieve the branch name
97- BRANCH_NAME=$( echo ${BRANCH_REF} | awk -F' /' ' {print $3}' )
98- else
99- AUTHOR_LINK=https://github.com/${AUTHOR}
100- BRANCH_REF=refs/heads/${GITHUB_HEAD_REF}
101- BRANCH_NAME=${GITHUB_HEAD_REF}
102- REPO_URL=${AUTHOR_LINK} /toolchain-e2e
103- fi
104-
105- if [[ -n " ${BRANCH_REF} " ]]; then \
106- # check if a branch with the same ref exists in the user's fork of ${REPOSITORY_NAME} repo
107- echo " branches of ${AUTHOR_LINK} /${REPOSITORY_NAME} - checking if there is a branch ${BRANCH_REF} we could pair with."
108- curl ${AUTHOR_LINK} /${REPOSITORY_NAME} .git/info/refs? service=git-upload-pack --output -
109- REMOTE_E2E_BRANCH=$( curl ${AUTHOR_LINK} /${REPOSITORY_NAME} .git/info/refs? service=git-upload-pack --output - 2> /dev/null | grep -a " ${BRANCH_REF} $" | awk ' {print $2}' )
110- echo " branch ref of the user's fork: \" ${REMOTE_E2E_BRANCH} \" - if empty then not found"
111- # check if the branch with the same name exists, if so then merge it with master and use the merge branch, if not then use master \
112- if [[ -n " ${REMOTE_E2E_BRANCH} " ]]; then \
113- if [[ -f ${WAS_ALREADY_PAIRED_FILE} ]]; then \
114- echo " #################################### ERROR WHILE TRYING TO PAIR PRs ####################################
115- There was an error while trying to pair this e2e PR with ${AUTHOR_LINK} /${REPOSITORY_NAME} @${BRANCH_REF}
116- The reason is that there was already detected a branch from another repo this PR could be paired with - see:
117-
118- $( cat ${WAS_ALREADY_PAIRED_FILE} )
119-
120- It's not possible to pair a PR with multiple branches from other repositories.
121- Please delete one of the branches from your fork and rerun the e2e tests
122- Note: If you have already deleted one of the branches from your fork, it can take a few hours before the
123- github api is updated so the e2e tests may still fail with the same error until then.
124- ##########################################################################################################"
125- exit 1
126- fi
127-
128- git config --global user.email " devsandbox@redhat.com"
129- git config --global user.name " KubeSaw"
130-
131- echo -e " repository: ${AUTHOR_LINK} /${REPOSITORY_NAME} \nbranch: ${BRANCH_NAME} " > ${WAS_ALREADY_PAIRED_FILE}
132- # add the user's fork as remote repo
133- git --git-dir=${REPOSITORY_PATH} /.git --work-tree=${REPOSITORY_PATH} remote add external ${AUTHOR_LINK} /${REPOSITORY_NAME} .git
134- # fetch the branch
135- git --git-dir=${REPOSITORY_PATH} /.git --work-tree=${REPOSITORY_PATH} fetch external ${BRANCH_REF}
136-
137- echo " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
138- echo " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! WARNING !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
139- echo " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
140- echo " "
141- echo " The following command will try to merge the paired PR using fast-forward way."
142- echo " If the command fails, then it means that the paired PR https://github.com/codeready-toolchain/${REPOSITORY_NAME} / from branch ${BRANCH_NAME} "
143- echo " is not up-to-date with master and the fast-forward merge cannot be performed."
144- echo " If this happens, then rebase the PR with the latest changes from master and rerun this GH Actions build (or comment /retest in this PR)."
145- echo " https://github.com/codeready-toolchain/${REPOSITORY_NAME} /pulls?q=head%3A${BRANCH_NAME} "
146- echo " "
147- echo " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
148- echo " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
149- # merge the branch with master using fast-forward
150- git --git-dir=${REPOSITORY_PATH} /.git --work-tree=${REPOSITORY_PATH} merge --ff-only FETCH_HEAD
151- # print information about the last three commits, so we know what was merged plus some additional context/history
152- git --git-dir=${REPOSITORY_PATH} /.git --work-tree=${REPOSITORY_PATH} log --ancestry-path HEAD~3..HEAD
153-
154- PAIRED=true
155- fi
156- fi
157- fi
158- }
159-
160-
16150install_operator () {
16251 DISPLAYNAME=$( echo ${OPERATOR_NAME} | tr ' -' ' ' | awk ' {for (i=1;i<=NF;i++) $i=toupper(substr($i,1,1)) substr($i,2)} 1' )
16352
0 commit comments