[Libreoffice-commits] 2 commits - tb/tb tb/tb_internals.sh

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Fri Jan 25 15:30:07 PST 2013


 tb/tb              |    6 +--
 tb/tb_internals.sh |   90 ++++++++++++++++++++++++++++++++++++++++-------------
 2 files changed, 71 insertions(+), 25 deletions(-)

New commits:
commit 128dd21f840f4250ff67c94bd6b55e45ac6651d3
Author: Norbert Thiebaud <nthiebaud at gmail.com>
Date:   Fri Jan 25 16:42:38 2013 -0600

    tb: try to intercept Ctrl-C in subshell to avoid reporting 'fail'

diff --git a/tb/tb_internals.sh b/tb/tb_internals.sh
index 658a4f6..3cdb5c7 100644
--- a/tb/tb_internals.sh
+++ b/tb/tb_internals.sh
@@ -504,6 +504,7 @@ determine_make()
 die()
 {
     echo "[$(print_date) ${P}:${B}] Error:" "$@" | tee -a ${tb_LOGFILE?}
+    R=-1
     exit -1;
 }
 
@@ -584,6 +585,24 @@ get_committers()
     get_commits_since_last_good people | sort | uniq | tr '\n' ','
 }
 
+interupted_build()
+{
+    mgs_log "Interrupted by Signal"
+    if [ "$tb_BUILD_TYPE" = "gerrit" ] ; then
+        if [ -n "${GERRIT_TASK_TICKET}" ] ;then
+            # repport a cancellation if we already acquired the ticket
+            R=2
+            report_gerrit
+        fi
+    elif [ "$tb_BUILD_TYPE" = "tb" ] ; then
+        if [ -n "${tb_LAST_CHECKOUT_DATE?}" ] ; then
+            # repport a cancellation if we already notified a start
+            report_to_tinderbox "${tb_LAST_CHECKOUT_DATE?}" "fold" "no"
+        fi
+    fi
+    exit 4
+}
+
 load_config()
 {
     tb_CONFIG_DIR="$HOME/.tb"
@@ -921,7 +940,7 @@ EOF
 report_gerrit()
 {
 local log_type="$1"
-local status="failed"
+local status=
 local gzlog=
 
     [ $V ] && echo "report to gerrit retval=${R} log_type=${log_type}"
@@ -956,14 +975,14 @@ local gzlog=
     if [ "${R?}" = "0" ] ; then
         log_msgs "Report Success for gerrit ref ${GERRIT_TASK_TICKET?}"
         status="success"
-    elif [ "${R?}" = "2" ] ; then
+    elif [ "${R?}" = "1" ] ; then
+        log_msgs "Report Failure for gerrit ref ${GERRIT_TASK_TICKET?}"
+        status="failed"
+    else
         log_msgs "Report Cancellation for gerrit ref ${GERRIT_TASK_TICKET?}"
         status="canceled"
-    else
-        log_msgs "Report Failure for gerrit ref ${GERRIT_TASK_TICKET?}"
     fi
     cat "${gzlog}" | ssh ${TB_GERRIT_HOST?} buildbot put --id ${TB_ID?} --ticket "${GERRIT_TASK_TICKET?}" --status $status --log -
-
 }
 
 
@@ -1114,6 +1133,8 @@ run_one_gerrit()
 {
     R=0
     (
+        trap 'interupted_build' SIGINT SIGQUIT
+
         log_msgs "Starting tb build gerrit ref:${GERRIT_TASK_TICKET?}"
         # source branch-level configuration
         source_branch_level_config "${B?}" "gerrit"
@@ -1140,9 +1161,14 @@ run_one_gerrit()
         report_gerrit
 
         popd > /dev/null
-        exit $R
+        exit ${R?}
     )
     R="$?"
+
+    # check we we intercepted a signal, if so bail
+    if [ "${R?}" = "4" ] ; then
+        exit -1
+    fi
 }
 
 #
@@ -1154,6 +1180,8 @@ run_one_tb()
 {
     R=0
     (
+        trap 'interupted_build' SIGINT SIGQUIT
+
         log_msgs "Starting tb build for sha:$(cat "${TB_METADATA_DIR?}/${P}_${B?}_current-git-head.log")"
         source_branch_level_config "${B?}" "${tb_BUILD_TYPE?}"
         if [ -z "$TB_BUILD_DIR" ] ; then
@@ -1166,12 +1194,12 @@ run_one_tb()
             prepare_git_repo_for_tb
         fi
 
-        local last_checkout_date="$(cat "${TB_METADATA_DIR?}/${P}_${B?}_current-git-timestamp.log")"
+        tb_LAST_CHECKOUT_DATE="$(cat "${TB_METADATA_DIR?}/${P}_${B?}_current-git-timestamp.log")"
         local phase_list
         local retry_count=3
 
-        report_to_tinderbox "${last_checkout_date?}" "building" "no"
-
+        report_to_tinderbox "${tb_LAST_CHECKOUT_DATE?}" "building" "no"
+        tb_TB_BUILD_REPORTED=1
 
         if [ "$TB_INCREMENTAL" = "1" ] ; then
             phase_list="autogen make test push"
@@ -1186,13 +1214,10 @@ run_one_tb()
             do_build ${phase_list?}
 
             if [ "$R" = "0" ] ; then
-                report_to_tinderbox "$last_checkout_date" "success" "yes"
+                report_to_tinderbox "${tb_LAST_CHECKOUT_DATE?}" "success" "yes"
                 phase_list=
                 log_msgs "Successful tb build for sha:$(cat "${TB_METADATA_DIR?}/${P}_${B?}_current-git-head.log")"
             elif [ "$R" = "2" ] ; then
-                if [ "${tb_ONE_SHOT?}" != "1" ] ; then
-                    report_to_tinderbox "${last_checkout_date?}" "fold" "no"
-                fi
                 log_msgs "False negative build, skip reporting"
                     # false negative does not need a full clean build, let's just redo make and after
                 retry_count=$((retry_count - 1))
@@ -1200,6 +1225,9 @@ run_one_tb()
                     log_msgs "False Negative Failed tb build for sha:$(cat "${TB_METADATA_DIR?}/${P}_${B?}_current-git-head.log")"
                     phase_list=""
                     R=2
+                    if [ "${tb_ONE_SHOT?}" != "1" ] ; then
+                        report_to_tinderbox "${tb_LAST_CHECKOUT_DATE?}" "fold" "no"
+                    fi
                 else
                     log_msgs "False Negative Retry tb build for sha:$(cat "${TB_METADATA_DIR?}/${P}_${B?}_current-git-head.log")"
                     phase_list="make test push"
@@ -1213,18 +1241,23 @@ run_one_tb()
                 else
                     cat ${tb_REPORT_LOG?} >> report_error.log
                 fi
-                report_error committer "$last_checkout_date" report_error.log
-                report_to_tinderbox "${last_checkout_date?}" "build_failed" "yes"
+                report_error committer "${tb_LAST_CHECKOUT_DATE?}" report_error.log
+                report_to_tinderbox "${tb_LAST_CHECKOUT_DATE?}" "build_failed" "yes"
                 phase_list=""
                 log_msgs "Failed tb build for sha:$(cat "${TB_METADATA_DIR?}/${P}_${B?}_current-git-head.log")"
             fi
         done
+        tb_LAST_CHECKOUT_DATE=
         rotate_logs
         popd > /dev/null
         exit $R
     )
     R="$?"
 
+    # check we we intercepted a signal, if so bail
+    if [ "${R?}" = "4" ] ; then
+        exit -1
+    fi
 }
 
 #
commit 6f59268812a63da308a33d0ef704413c99c82d5f
Author: Norbert Thiebaud <nthiebaud at gmail.com>
Date:   Fri Jan 25 16:42:05 2013 -0600

    tb: fix tb_Mode/Priority handling

diff --git a/tb/tb b/tb/tb
index 90708c8..f03183a 100755
--- a/tb/tb
+++ b/tb/tb
@@ -323,14 +323,14 @@ while [ "${1}" != "" ]; do
             case "$arg" in
                 fair)
                     tb_MODE="dual"
-                    TB_DUAL_PRIORITY="fair"
+                    tb_DUAL_PRIORITY="fair"
                     ;;
                 gerrit)
                     tb_MODE="gerrit"
                     ;;
                 gerrit-tb)
                     tb_MODE="dual"
-                    TB_DUAL_PRIORITY="gerrit"
+                    tb_DUAL_PRIORITY="gerrit"
                     ;;
                 prime)
                     tb_MODE="tb"
@@ -341,7 +341,7 @@ while [ "${1}" != "" ]; do
                     ;;
                 tb-gerrit)
                     tb_MODE="dual"
-                    TB_DUAL_PRIORITY="tb"
+                    tb_DUAL_PRIORITY="tb"
                     ;;
                 *)
                     die "Unsupported mode of operation : $arg"
diff --git a/tb/tb_internals.sh b/tb/tb_internals.sh
index f121de5..658a4f6 100644
--- a/tb/tb_internals.sh
+++ b/tb/tb_internals.sh
@@ -659,7 +659,7 @@ prepare_git_repo_for_gerrit()
     [ $V ] && echo "fetching gerrit path from ssh://${TB_GERRIT_HOST?}/core ${GERRIT_TASK_REF}"
 
     (
-        git clean -fd && git fetch -q ssh://${GERRIT_HOST?}/core ${GERRIT_TASK_REF}
+        git clean -fd && git fetch -q ssh://${TB_GERRIT_HOST?}/core ${GERRIT_TASK_REF}
         if [ "$?" = "0" ] ; then
             git checkout -q FETCH_HEAD
             git submodule -q update
@@ -667,12 +667,13 @@ prepare_git_repo_for_gerrit()
             exit -1
         fi
     ) 2>&1 > ${TB_BUILD_DIR}/error_log.log
-    popd > /dev/null
 
     if [ "$?" != "0" ] ; then
+        popd > /dev/null
         report_error owner "$(print_date)" error_log.log
         die "Cannot reposition repo ${TB_GIT_DIR} to the proper branch"
     fi
+    popd > /dev/null
 
 }
 
@@ -713,6 +714,7 @@ prepare_git_repo_for_tb()
     ) 2>&1 > ${TB_BUILD_DIR}/error_log.log
 
     if [ "$?" != "0" ] ; then
+        popd > /dev/null
         report_error owner "$(print_date)" error_log.log
         die "Cannot reposition repo ${TB_GIT_DIR} to the proper branch"
     fi
@@ -1309,7 +1311,7 @@ select_next_task()
 
         # if we use a 'fair' priority
         # switch the order in which we try to get stuff
-        if [ "${tb_PRIORITY?}" = "fair" ] ; then
+        if [ "${tb_MODE?}" = "fair" ] ; then
             if [ "${tb_BUILD_TYPE?}" = "tb" ] ; then
                 tb_NEXT_PRIORITY="gerrit"
             elif [ "${tb_BUILD_TYPE?}" = "gerrit" ] ; then
@@ -1452,6 +1454,10 @@ setup_profile_defaults()
         tb_MODE="${TB_DEFAULT_MODE:-tb}"
     fi
 
+    if [ -z "${tb_DUAL_PRIORITY}" ] ; then
+        tb_DUAL_PRIORITY="${TB_DUAL_PRIORITY:-fair}"
+    fi
+
     if [ -z "${tb_BRANCHES}" ] ; then
         tb_BRANCHES="${TB_BRANCHES}"
         if [ -z "${tb_BRANCHES}" ] ; then
@@ -1490,9 +1496,14 @@ local rc
             if [ -z "$tb_GERRIT_PLATFORM" ] ; then
                 die "tb_GERRIT_PLATFORM is required for mode involving gerrit"
             fi
-            if [ -z "TB_DUAL_PRIORITY" ] ; then
-                TB_DUAL_PRIORITY="fair"
-            fi
+            case "${tb_DUAL_PRIORITY?}" in
+                fair|gerrit|tb)
+                    ;;
+                *)
+                    log_msgs "TB_DUAL_PRIORITY:${tb_DUAL_PRIORITY?} is not a valid value, defaulting to 'fair'"
+                    tb_DUAL_PRIORITY="fair"
+                    ;;
+            esac
             ;;
         gerrit)
             if [ -z "$tb_GERRIT_PLATFORM" ] ; then
@@ -1514,9 +1525,11 @@ local rc
             fi
             ;;
         *)
+            die "Invalid mode $tb_MODE"
             ;;
     esac
 
+
     if [ -z "${tb_SEND_MAIL}" ] ; then
         tb_SEND_MAIL="${TB_SEND_MAIL}"
     fi
@@ -1536,7 +1549,7 @@ local rc
         none)
             ;;
         *)
-            die "Invalid -m argument:${tb_SEND_MAIL}"
+            die "Invalid -m/TB_SEND_MAIL argument:${tb_SEND_MAIL}"
             ;;
     esac
 


More information about the Libreoffice-commits mailing list