@@ -20,20 +20,19 @@ set -o pipefail
2020
2121# shellcheck disable=SC2120
2222function caller() {
23- local stack_skip=${1:- 0}
24- stack_skip=$(( stack_skip + 1 ))
25- if [[ ${# FUNCNAME[@]} -gt ${stack_skip} ]]; then
26- local i
27- for (( i= 1 ; i <= ${# FUNCNAME[@]} - stack_skip ; i++ ))
28- do
29- local frame_no=$(( i - 1 + stack_skip))
30- local source_lineno=${BASH_LINENO[$((frame_no - 1))]}
31- local funcname=${FUNCNAME[${frame_no}]}
32- if [[ " $funcname " =~ ' e2e::' ]]; then
33- echo " ${source_lineno} "
34- fi
35- done
36- fi
23+ local stack_skip=${1:- 0}
24+ stack_skip=$(( stack_skip + 1 ))
25+ if [[ ${# FUNCNAME[@]} -gt ${stack_skip} ]]; then
26+ local i
27+ for (( i= 1 ; i <= ${# FUNCNAME[@]} - stack_skip ; i++ )) ; do
28+ local frame_no=$(( i - 1 + stack_skip))
29+ local source_lineno=${BASH_LINENO[$((frame_no - 1))]}
30+ local funcname=${FUNCNAME[${frame_no}]}
31+ if [[ " $funcname " =~ ' e2e::' ]]; then
32+ echo " ${source_lineno} "
33+ fi
34+ done
35+ fi
3736}
3837
3938function fail() {
@@ -193,20 +192,20 @@ E2E_TAG=$(git rev-parse --show-toplevel | sed 's|/|_|g')
193192# current tree.
194193build_container=false
195194if [[ " ${GIT_SYNC_E2E_IMAGE:- unset} " == " unset" ]]; then
196- GIT_SYNC_E2E_IMAGE=" e2e/git-sync:${E2E_TAG} __$( go env GOOS) _$( go env GOARCH) "
197- build_container=true
195+ GIT_SYNC_E2E_IMAGE=" e2e/git-sync:${E2E_TAG} __$( go env GOOS) _$( go env GOARCH) "
196+ build_container=true
198197fi
199198
200199# DIR is the directory in which all this test's state lives.
201200RUNID=" ${RANDOM}${RANDOM} "
202201DIR=" /tmp/git-sync-e2e.$RUNID "
203202mkdir " $DIR "
204203function final_cleanup() {
205- if [[ " ${CLEANUP:- } " == 0 ]]; then
206- echo " leaving logs in $DIR "
207- else
208- rm -rf " $DIR "
209- fi
204+ if [[ " ${CLEANUP:- } " == 0 ]]; then
205+ echo " leaving logs in $DIR "
206+ else
207+ rm -rf " $DIR "
208+ fi
210209}
211210# Set the trap to call the final_cleanup function on exit.
212211trap final_cleanup EXIT
@@ -216,38 +215,38 @@ required_env_vars=()
216215LOCAL_GITHUB_APP_PRIVATE_KEY_FILE=" github_app_private_key.pem"
217216GITHUB_APP_PRIVATE_KEY_MOUNT=()
218217if [[ " ${skip_github_app_test} " != " true" ]]; then
219- required_env_vars=(
220- " TEST_GITHUB_APP_AUTH_TEST_REPO"
221- " TEST_GITHUB_APP_APPLICATION_ID"
222- " TEST_GITHUB_APP_INSTALLATION_ID"
223- " TEST_GITHUB_APP_CLIENT_ID"
224- )
225-
226- if [[ -n " ${TEST_GITHUB_APP_PRIVATE_KEY_FILE:- } " && -n " ${TEST_GITHUB_APP_PRIVATE_KEY:- } " ]]; then
227- echo " ERROR: Both TEST_GITHUB_APP_PRIVATE_KEY_FILE and TEST_GITHUB_APP_PRIVATE_KEY were specified."
228- exit 1
229- fi
230- if [[ -n " ${TEST_GITHUB_APP_PRIVATE_KEY_FILE:- } " ]]; then
231- cp " ${TEST_GITHUB_APP_PRIVATE_KEY_FILE} " " ${DIR} /${LOCAL_GITHUB_APP_PRIVATE_KEY_FILE} "
232- elif [[ -n " ${TEST_GITHUB_APP_PRIVATE_KEY:- } " ]]; then
233- echo " ${TEST_GITHUB_APP_PRIVATE_KEY} " > " ${DIR} /${LOCAL_GITHUB_APP_PRIVATE_KEY_FILE} "
234- else
235- echo " ERROR: Neither TEST_GITHUB_APP_PRIVATE_KEY_FILE nor TEST_GITHUB_APP_PRIVATE_KEY was specified."
236- echo " Either provide a value or skip this test (SKIP_GITHUB_APP_TEST=true)."
237- exit 1
238- fi
239-
240- # Validate all required environment variables for the github-app-auth tests are provided.
241- for var in " ${required_env_vars[@]} " ; do
242- if [[ ! -v " ${var} " ]]; then
243- echo " ERROR: Required environment variable '${var} ' is not set."
244- echo " Either provide a value or skip this test (SKIP_GITHUB_APP_TEST=true)."
245- exit 1
218+ required_env_vars=(
219+ " TEST_GITHUB_APP_AUTH_TEST_REPO"
220+ " TEST_GITHUB_APP_APPLICATION_ID"
221+ " TEST_GITHUB_APP_INSTALLATION_ID"
222+ " TEST_GITHUB_APP_CLIENT_ID"
223+ )
224+
225+ if [[ -n " ${TEST_GITHUB_APP_PRIVATE_KEY_FILE:- } " && -n " ${TEST_GITHUB_APP_PRIVATE_KEY:- } " ]]; then
226+ echo " ERROR: Both TEST_GITHUB_APP_PRIVATE_KEY_FILE and TEST_GITHUB_APP_PRIVATE_KEY were specified."
227+ exit 1
228+ fi
229+ if [[ -n " ${TEST_GITHUB_APP_PRIVATE_KEY_FILE:- } " ]]; then
230+ cp " ${TEST_GITHUB_APP_PRIVATE_KEY_FILE} " " ${DIR} /${LOCAL_GITHUB_APP_PRIVATE_KEY_FILE} "
231+ elif [[ -n " ${TEST_GITHUB_APP_PRIVATE_KEY:- } " ]]; then
232+ echo " ${TEST_GITHUB_APP_PRIVATE_KEY} " > " ${DIR} /${LOCAL_GITHUB_APP_PRIVATE_KEY_FILE} "
233+ else
234+ echo " ERROR: Neither TEST_GITHUB_APP_PRIVATE_KEY_FILE nor TEST_GITHUB_APP_PRIVATE_KEY was specified."
235+ echo " Either provide a value or skip this test (SKIP_GITHUB_APP_TEST=true)."
236+ exit 1
246237 fi
247- done
248238
249- # Mount the GitHub App private key file to the git-sync container
250- GITHUB_APP_PRIVATE_KEY_MOUNT=(-v " ${DIR} /${LOCAL_GITHUB_APP_PRIVATE_KEY_FILE} " :" /${LOCAL_GITHUB_APP_PRIVATE_KEY_FILE} " :ro)
239+ # Validate all required environment variables for the github-app-auth tests are provided.
240+ for var in " ${required_env_vars[@]} " ; do
241+ if [[ ! -v " ${var} " ]]; then
242+ echo " ERROR: Required environment variable '${var} ' is not set."
243+ echo " Either provide a value or skip this test (SKIP_GITHUB_APP_TEST=true)."
244+ exit 1
245+ fi
246+ done
247+
248+ # Mount the GitHub App private key file to the git-sync container
249+ GITHUB_APP_PRIVATE_KEY_MOUNT=(-v " ${DIR} /${LOCAL_GITHUB_APP_PRIVATE_KEY_FILE} " :" /${LOCAL_GITHUB_APP_PRIVATE_KEY_FILE} " :ro)
251250fi
252251
253252# WORK is temp space and in reset for each testcase.
0 commit comments