From 8b17d54737ba37bc96f91bfcd69590acb3f728e9 Mon Sep 17 00:00:00 2001 From: Aleksandar Pokopec Date: Tue, 19 Oct 2010 18:47:08 +0000 Subject: For all those using .git who like their build a... For all those using .git who like their build and tests being run on a different machine - remotetest. Uses ssh, git and the remote home directory to push the current tree to a bare repo, then check it out remotely and run the full build and tests. Usage: remotetest [--init] Modifying .ssh/authorized_keys on the is recommended. To be run with --init first time. No review. --- tools/remotetest | 131 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 131 insertions(+) create mode 100755 tools/remotetest (limited to 'tools') diff --git a/tools/remotetest b/tools/remotetest new file mode 100755 index 0000000000..699d9e5d8a --- /dev/null +++ b/tools/remotetest @@ -0,0 +1,131 @@ + + +# +# Remote build&test script. +# Author: Aleksandar Prokopec +# + + +SCRIPTNAME="..:: RemoteTest ::.." +DESC="This script pushes the current git repo to a remote bare repo. \ +It then checks out the source tree in a workspace repo and starts the\ + build and all the tests. It can also initialize the remote bare repo\ + and the workspace repo. It assumes that the current repo refspec has\ + been set for the remote bare repository - .git/config of the current\ + repo must have a remote called and the corresponding master\ + branch. Git should, naturally, be installed on both systems.\ + " +USAGE=" Usage: remotetest [--init] " + + +function usage() +{ + echo $SCRIPTNAME + echo $DESC + echo + echo $USAGE +} + + +function error() +{ + echo "Failed." + exit 1 +} + +function success() +{ + echo "Success!" + exit 0 +} + +function instruct() +{ + usage + error +} + + + +if [ $# -lt 1 ] +then + instruct +fi + + +if [[ $1 = "--init" ]] +then + if [ $# -ne 5 ] + then + instruct + fi + USER=$2 + LOCATION=$3 + BAREREPO=$4 + WORKREPO=$5 +else + if [ $# -ne 4 ] + then + instruct + fi + USER=$1 + LOCATION=$2 + BAREREPO=$3 + WORKREPO=$4 +fi + +if [[ $1 = "--init" ]] +then + # init bare repo + ssh $USER@$LOCATION "mkdir $BAREREPO" + ssh $USER@$LOCATION "cd $BAREREPO; git init --bare" + if [ $? -ne 0 ] + then + error "Could not initialize bare repo." + fi + + # push to bare repo + git push --all + if [ $? -ne 0 ] + then + error "Could not push to bare repo." + fi + + # init and checkout work repo + ssh $USER@$LOCATION "mkdir $WORKREPO" + ssh $USER@$LOCATION "cd $WORKREPO; git clone --local $BAREREPO ." + if [ $? -ne 0 ] + then + error "Could not init working repo." + fi + + success +fi + + + + +# if it's not the init operation, proceed normally +# push to remote bare repo +git push $LOCATION $LOCATION/master +if [ $? -ne 0 ] +then + error "Could not push to bare repo." +fi + +# remotely checkout the repo +ssh $USER@$LOCATION "cd $WORKREPO; git pull origin master" +if [ $? -ne 0 ] +then + error "Could remotely pull from bare repo to work repo." +fi + +# run the build and tests +ssh $USER@$LOCATION "cd $WORKREPO; ant all.clean; ant test" + + +success + + + + -- cgit v1.2.3