[PATCH 1/2] mail committers when failed build gets fixed

Lionel Elie Mamane lionel at mamane.lu
Mon Dec 12 20:42:31 PST 2011


---
 bin/tinbuild2             |    4 +-
 bin/tinbuild_internals.sh |  108 +++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 107 insertions(+), 5 deletions(-)

diff --git a/bin/tinbuild2 b/bin/tinbuild2
index f0aca66..be604ab 100755
--- a/bin/tinbuild2
+++ b/bin/tinbuild2
@@ -30,7 +30,7 @@ FORCE_REBUILD=0
 #
 # The build cycle, invoked in this script with do_build, consist
 # of 5 phases that are processed in this order: autogen, clean, make, test, push
-# eeach phase execution try to invoke pre_<phase>, do_<phase> and post_<pahse>
+# each phase execution tries to invoke pre_<phase>, do_<phase> and post_<phase>
 # in this order, if the respective bash function are defined.
 #
 # In order to implement a specific step, pre_build for instance, you need
@@ -369,7 +369,7 @@ while true; do
     if [ "$retval" != "false_negative" ] ; then
         wait_for_commits
     else
-		collect_current_heads
+        collect_current_heads
     fi
     last_checkout_date="$(cat tb_${B}_current-git-timestamp.log)"
     (
diff --git a/bin/tinbuild_internals.sh b/bin/tinbuild_internals.sh
index 0416a09..e1aab01 100644
--- a/bin/tinbuild_internals.sh
+++ b/bin/tinbuild_internals.sh
@@ -97,6 +97,32 @@ get_commits_since_last_good()
     fi
 }
 
+get_commits_since_last_bad()
+{
+    local mode=$1
+    local head=
+    local repo=
+    local sha=
+
+    if [ -f tb_${B}_last-failure-git-heads.txt ] ; then
+	for head in $(cat tb_${B}_last-failure-git-heads.txt) ; do
+	    repo=$(echo ${head} | cut -d : -f 1)
+	    sha=$(echo ${head} | cut -d : -f 2)
+	    (
+		if [ "${repo?}" != "bootstrap" -a "${repo}" != "core" ] ; then
+		    cd clone/${repo?}
+		fi
+                if [ "${mode?}" = "people" ] ; then
+		    git log '--pretty=tformat:%ce' ${sha?}..HEAD
+                else
+                    echo "==== ${repo} ===="
+                    git log '--pretty=tformat:%h  %s' ${sha?}..HEAD | sed 's/^/  /'
+                fi
+	    )
+	done
+    fi
+}
+
 send_mail_msg()
 {
 local to="$1"
@@ -190,7 +216,7 @@ report_error ()
 		    message="box broken" ;;
 		*)
                     if [ -z "$last_success" ] ; then
-			          # we need at least one successful build to
+                      # we need at least one successful build to
                       # be reliable
 			to_mail="${OWNER?}"
 		    else
@@ -233,6 +259,75 @@ EOF
     fi
 }
 
+report_fixed ()
+{
+    local_to_mail=
+    local tinder1=
+    local tinder2=
+    local mail_tail=
+    local success_kind="$1"
+    shift
+    local rough_time="$1"
+    shift
+
+    local previous_success=$(cat tb_${B}_last-success-git-timestamp.txt)
+    local last_failure=$(cat tb_${B}_last-failure-git-timestamp.txt)
+    to_mail=
+    if [ "$SEND_MAIL" = "owner" -o "$SEND_MAIL" = "debug" -o "$SEND_MAIL" = "author" ] ; then
+        to_mail="${OWNER?}"
+    else
+        if [ "$SEND_MAIL" = "all" ] ; then
+	    case "$success_kind" in
+		owner) to_mail="${OWNER?}"
+		    message="box fixed" ;;
+		*)
+                    if [ -z "$previous_success" ] ; then
+                      # we need at least one successful build to
+                      # be reliable
+			to_mail="${OWNER?}"
+		    else
+			to_mail="$(get_committers)"
+		    fi
+		    message="previous success: ${previous_success?}" ;;
+	    esac
+        fi
+    fi
+    if [ -n "$to_mail" ] ; then
+	echo "$*" 1>&2
+	echo "Previous success: ${previous_success}" 1>&2
+	echo "Last failure: ${last_failure}" 1>&2
+	tinder1="`echo \"Full log available at http://tinderbox.libreoffice.org/$TINDER_BRANCH/status.html\"`"
+	tinder2="`echo \"Box name: ${TINDER_NAME?}\"`"
+	if [ "$*" != "" ]; then
+	    mail_tail = $'\nAdditional information:\n\n'"$*"
+	fi
+
+	cat <<EOF | send_mail_msg "$to_mail" "Tinderbox fixed, $message" "" "${OWNER?}" ""
+Hi folks,
+
+The previously reported build failure is fixed. Thanks!
+
+${tinder1}
+
+Tinderbox info:
+
+  ${tinder2}
+  Machine: `uname -a`
+  Configured with: `cat autogen.lastrun`
+
+Commits since last failure:
+
+$(get_commits_since_last_bad commits)
+
+Commits since the previous success:
+
+$(get_commits_since_last_good commits)
+${mail_tail}
+EOF
+    else
+	echo "$*" 1>&2
+    fi
+}
 
 collect_current_heads()
 {
@@ -242,7 +337,7 @@ collect_current_heads()
 
 get_committers()
 {
-    echo "get_commiter: $(get_commits_since_last_good people)" 1>&2
+    echo "get_committers: $(get_commits_since_last_good people)" 1>&2
     get_commits_since_last_good people | sort | uniq | tr '\n' ','
 }
 
@@ -251,6 +346,9 @@ rotate_logs()
     if [ "$retval" = "0" ] ; then
 	cp -f tb_${B}_current-git-heads.log tb_${B}_last-success-git-heads.txt 2>/dev/null
 	cp -f tb_${B}_current-git-timestamp.log tb_${B}_last-success-git-timestamp.txt 2>/dev/null
+    elif [ "$retval" != "false_negative" ]; then
+	cp -f tb_${B}_current-git-heads.log tb_${B}_last-failure-git-heads.txt 2>/dev/null
+	cp -f tb_${B}_current-git-timestamp.log tb_${B}_last-failure-git-timestamp.txt 2>/dev/null
     fi
     for f in tb_${B}*.log ; do
 	mv -f ${f} prev-${f} 2>/dev/null
@@ -323,6 +421,7 @@ do_build()
         report_to_tinderbox "${last_checkout_date?}" "building" "no"
     fi
 
+    previous_build_status="${build_status}"
     build_status="build_failed"
     retval=0
     retry_count=3
@@ -338,8 +437,11 @@ do_build()
             build_status="success"
             if [ -n "${last_checkout_date}" ] ; then
                 report_to_tinderbox "$last_checkout_date" "success" "yes"
+		if [ "${previous_build_status}" = "build_failed" ]; then
+		    report_fixed committer "$last_checkout_date"
+		fi
             else
-                log_msgs "Successfuly primed branch '$TINDER_BRANCH'."
+                log_msgs "Successfully primed branch '$TINDER_BRANCH'."
             fi
         elif [ "$retval" = "false_negative" ] ; then
             report_to_tinderbox "${last_checkout_date?}" "fold" "no"
-- 
1.7.7.3


--wRRV7LY7NUeQGEoC
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment; filename="0002-mail-authors-as-well-as-committers.patch"



More information about the LibreOffice mailing list