commit 4d0af400e34f7cbdb0025fc21f742397acc8ac88 Author: Derek Higgins Date: Wed May 15 10:16:30 2013 +0100 start of a ci script diff --git a/toci.sh b/toci.sh new file mode 100755 index 000000000..3ca804a29 --- /dev/null +++ b/toci.sh @@ -0,0 +1,24 @@ +#!/usr/bin/bash + +export STARTTIME=$(date) +export TOCI_WORKING_DIR=$(mktemp -d) +export TOCI_LOG_DIR=$(mktemp -d) + +echo $TOCI_LOG_DIR + +STATUS=0 + +./toci_setup.sh > $TOCI_LOG_DIR/setup.out 2>&1 || STATUS=1 +if [ $STATUS == 0 ] ; then + ./toci_test.sh > $TOCI_LOG_DIR/test.out 2>&1 || STATUS=1 +fi +./toci_cleanup.sh > $TOCI_LOG_DIR/cleanup.out 2>&1 || STATUS=1 + +cd $(dirname $TOCI_LOG_DIR) +tar -czf - $(basename $TOCI_LOG_DIR) | ssh ec2-user@toci_results tar -C /var/www/html/toci -xzf - + +if [ $STATUS == 0 ] ; then + ssh ec2-user@toci_results "echo \$STARTTIME : OK\\
>> /var/www/html/toci/index.html ; chmod -R 775 /var/www/html/toci/*" +else + ssh ec2-user@toci_results "echo \
$STARTTIME : ERR\\
>> /var/www/html/toci/index.html ; chmod -R 775 /var/www/html/toci/*" +fi diff --git a/toci_cleanup.sh b/toci_cleanup.sh new file mode 100755 index 000000000..4ca1c1eae --- /dev/null +++ b/toci_cleanup.sh @@ -0,0 +1,2 @@ +set -xe + diff --git a/toci_setup.sh b/toci_setup.sh new file mode 100755 index 000000000..4ca1c1eae --- /dev/null +++ b/toci_setup.sh @@ -0,0 +1,2 @@ +set -xe + diff --git a/toci_test.sh b/toci_test.sh new file mode 100755 index 000000000..4ca1c1eae --- /dev/null +++ b/toci_test.sh @@ -0,0 +1,2 @@ +set -xe + diff --git a/updated_launch.sh b/updated_launch.sh new file mode 100755 index 000000000..048f69584 --- /dev/null +++ b/updated_launch.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +LOCKFILE=/var/tmp/toci.lock +GITREF=${1:-origin/master} + +cd $(dirname $0) +git fetch origin + +# Exit if there is a script already running, otherwise update repo +# TODO : fix small race condition here (probably not a problem) +flock -x -n $LOCKFILE git reset --hard $GITREF || exit 0 +flock -x -n $LOCKFILE ./toci.sh +