11#! /bin/bash
22
3+ env
4+
35# set default value of DOCKER_HOST and BRANCH
46if [[ " $DOCKER_HOST " == " " ]]; then
57 DOCKER_HOST=" tcp://us-west-1.hyper.sh:443"
68fi
7- if [[ " $BRANCH " == " " ]]; then
8- BRANCH=" master"
9+
10+ PR=" "
11+ if [[ " ${BRANCH: 0: 1} " == " #" ]]; then
12+ PR=${BRANCH: 1}
13+ BRANCH=" "
14+ echo " ========== Task: test PR #${PR} =========="
15+ else
16+ if [[ " ${BRANCH} " == " " ]]; then
17+ BRANCH=" master"
18+ fi
19+ echo " ========== Task: test BRANCH ${BRANCH} =========="
920fi
1021
1122
@@ -23,8 +34,6 @@ if [[ "$@" != "./build.sh" ]];then
2334}
2435EOF
2536
26- env
27-
2837echo " ========== config git proxy =========="
2938if [ " ${http_proxy} " != " " ]; then
3039 git config --global http.proxy ${http_proxy}
@@ -34,16 +43,27 @@ if [ "${https_proxy}" != "" ];then
3443fi
3544git config --list | grep proxy
3645
46+ echo " ========== ping github.com =========="
47+ ping -c 6 -W 10 github.com
48+
3749echo " ========== Clone hypercli repo =========="
3850mkdir -p /go/src/github.com/{hyperhq,docker}
3951cd /go/src/github.com/hyperhq
4052git clone https://github.com/hyperhq/hypercli.git
4153
4254echo " ========== Build hypercli =========="
4355cd /go/src/github.com/hyperhq/hypercli
44- git checkout $BRANCH
56+ if [[ " ${BRANCH} " != " " ]]; then
57+ echo " checkout branch :${BRANCH} "
58+ git checkout ${BRANCH}
59+ elif [[ " ${PR} " != " " ]]; then
60+ echo " checkout pr :#$PR "
61+ git fetch origin pull/${PR} /head:pr-${PR}
62+ git checkout pr-${PR}
63+ fi
64+
4565if [[ $? -ne 0 ]]; then
46- echo " Branch $BRANCH not exist!"
66+ echo " Branch ${ BRANCH} not exist!"
4767 exit 1
4868fi
4969./build.sh
6787
6888# execute command
6989if [[ $# -ne 0 ]]; then
90+ echo " ========== Test Cmd: $@ =========="
7091 cd /go/src/github.com/hyperhq/hypercli/integration-cli && eval $@
7192 if [[ " $@ " == " ./build.sh" ]]; then
7293 # show make result
0 commit comments