Revamping the breakage message

This commit is contained in:
Sergio Durigan Junior 2017-02-21 15:49:44 -05:00
parent 11f0064c90
commit 5d69be9bd2

View file

@ -27,6 +27,7 @@ from urllib import quote
from sumfiles import DejaResults, set_web_base from sumfiles import DejaResults, set_web_base
import os import os
import glob
import urllib import urllib
from json import load from json import load
import re import re
@ -203,8 +204,8 @@ def SendRootMessageGDBTesters (branch, change, rev,
s.sendmail (GDB_MAIL_FROM, [ mailto ], mail.as_string ()) s.sendmail (GDB_MAIL_FROM, [ mailto ], mail.as_string ())
s.quit () s.quit ()
def make_breakage_lockfile_name (builder, branch): def make_breakage_lockfile_name (builder, branch, commit):
return "/tmp/gdb-buildbot-breakage-report-%s-%s" % (branch, builder) return "/tmp/gdb-buildbot-breakage-report-%s-%s-%s" % (commit, branch, builder)
def SendAuthorMessage (name, branch, change, text_prepend): def SendAuthorMessage (name, branch, change, text_prepend):
"""Send a message to the author of the commit if it broke GDB. """Send a message to the author of the commit if it broke GDB.
@ -214,13 +215,19 @@ people. This may happen, for example, if a commit X breaks GDB, but
subsequent commits are made after X, by different people.""" subsequent commits are made after X, by different people."""
global GDB_MAIL_FROM global GDB_MAIL_FROM
lockfile = make_breakage_lockfile_name (name, branch) lockfile = make_breakage_lockfile_name (name, branch, change.revision)
if os.path.exists (lockfile): if os.path.exists (lockfile):
# This means we have already reported this failure for this # This means we have already reported this failure for this
# builder to the author. # builder to the author.
return return
lock = glob.glob ("/tmp/gdb-buildbot-breakage-report-%s-*" % change.revision)
if lock:
send_gdb_patches_msg = False
else:
send_gdb_patches_msg = True
# This file will be cleaned the next time we run # This file will be cleaned the next time we run
# MessageGDBTesters, iff the build breakage has been fixed. # MessageGDBTesters, iff the build breakage has been fixed.
open (lockfile, 'w').close () open (lockfile, 'w').close ()
@ -229,16 +236,19 @@ subsequent commits are made after X, by different people."""
to = change.who.encode ('ascii', 'ignore').decode ('ascii') to = change.who.encode ('ascii', 'ignore').decode ('ascii')
title = change.comments.split ('\n')[0] title = change.comments.split ('\n')[0]
sbj = 'Your commit \'%s\' broke GDB' % title sbj = 'Oh dear. I regret to inform you that commit \'%s\' might be unfortunate' % title
if branch != 'master': if branch != 'master':
sbj += ' [%s]' % branch sbj += ' [%s]' % branch
text = "Hello there,\n\n" text = "My lords, ladies, gentlemen, members of the public.\n\n"
text += "Your commit:\n\n" text += "It is a matter of great regret and sadness to inform you that commit:\n\n"
text += "\t%s\n" % title text += "\t%s\n" % title
text += "\t%s\n\n" % rev text += "\t%s\n\n" % rev
text += "broke GDB. Please fix it, or the GDB gods will get you.\n\n" text += "might have made GDB unwell. Since I am just your Butler BuildBot,\n"
text += "You can find details of the breakage below.\n\n" text += "I kindly ask that a human superior officer double-check this.\n\n"
text += "Please note that if you are reading this message on gdb-patches, there might\n"
text += "be other builders broken.\n\n"
text += "You can find more details about the unfortunate breakage below.\n\n"
text += "Cheers,\n\n" text += "Cheers,\n\n"
text += "Your GDB BuildBot.\n\n" text += "Your GDB BuildBot.\n\n"
text += "+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n\n" text += "+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n\n"
@ -246,8 +256,11 @@ subsequent commits are made after X, by different people."""
mail = MIMEText (text) mail = MIMEText (text)
mail['Subject'] = sbj mail['Subject'] = sbj
mail['From'] = GDB_MAIL_FROM mail['From'] = 'gdb-buildbot@sergiodj.net'
mail['To'] = to + ',gdb-patches@sourceware.org' if send_gdb_patches_msg:
to += ", gdb-patches@sourceware.org"
mail['To'] = to
mail['Reply-To'] = 'gdb-patches@sourceware.org'
s = smtplib.SMTP ('localhost') s = smtplib.SMTP ('localhost')
s.sendmail (GDB_MAIL_FROM, [ to ], mail.as_string ()) s.sendmail (GDB_MAIL_FROM, [ to ], mail.as_string ())
@ -405,7 +418,7 @@ send to the gdb-testers mailing list."""
else: else:
# There is no build breakage anymore! Yay! Now, let's see if # There is no build breakage anymore! Yay! Now, let's see if
# we need to clean up any lock file from previous breaks. # we need to clean up any lock file from previous breaks.
lockfile = make_breakage_lockfile_name (name, branch) lockfile = make_breakage_lockfile_name (cur_change.revision, name, branch)
if os.path.exists (lockfile): if os.path.exists (lockfile):
# We need to clean the lockfile. Garbage-collect it here. # We need to clean the lockfile. Garbage-collect it here.
os.remove (lockfile) os.remove (lockfile)