New gdbgitdb.py file; improve result email; improve the way we save logs and sums

This commit is contained in:
Sergio Durigan Junior 2014-12-22 17:51:13 -05:00
parent 7e5c68d7ce
commit 555c6db4b0
3 changed files with 71 additions and 13 deletions

35
lib/gdbgitdb.py Normal file
View file

@ -0,0 +1,35 @@
# DB-like with git
from buildbot.steps.shell import ShellCommand
from sumfiles import get_web_base
import os.path
import git
class SaveGDBResults (ShellCommand):
name = 'save build results'
description = 'saving build results'
descriptionDone = 'saved build results'
command = ['true']
def __init__ (self, **kwargs):
BuildStep.__init__ (self, **kwargs)
def evaluateCommand (self, cmd):
rev = self.getProperty ('got_revision')
builder = self.getProperty ('buildername')
istry = self.getProperty ('isTryBuilder')
branch = self.getProperty ('branch')
repodir = os.path.join (get_web_base (), builder)
if branch is None:
branch = 'master'
if istry and istry == 'yes':
# Do nothing
return SUCCESS
try:
repo = git.Repo (path = repodir)
except git.InvalidGitRepositoryError:
repo = git.Repo.init (path = repodir)
git.index.add (['gdb.sum', 'gdb.log', '%s/baseline' % branch])
git.index.commit ('Log files for %s' % rev)
git.create_tag (rev)
return SUCCESS

View file

@ -18,6 +18,10 @@ def set_web_base(arg):
# So, use mkdir and not makedirs. # So, use mkdir and not makedirs.
os.mkdir(gdb_web_base, 0755) os.mkdir(gdb_web_base, 0755)
def get_web_base ():
global gdb_web_base
return gdb_web_base
class DejaResults(object): class DejaResults(object):
def __init__(self): def __init__(self):
object.__init__(self) object.__init__(self)
@ -42,12 +46,15 @@ class DejaResults(object):
test_name = nname test_name = nname
out_dict[test_name] = result out_dict[test_name] = result
def _write_sum_file(self, sum_dict, subdir, filename): def _write_sum_file(self, sum_dict, subdir, filename, is_baseline):
global gdb_web_base global gdb_web_base
bdir = os.path.join(gdb_web_base, subdir) bdir = os.path.join(gdb_web_base, subdir)
if not os.path.isdir(bdir): if not os.path.isdir(bdir):
os.makedirs(bdir, 0755) os.makedirs(bdir, 0755)
fname = os.path.join(bdir, filename) if is_baseline:
fname = os.path.join(bdir, filename)
else:
fname = os.path.join(bdir, 'gdb.sum')
keys = sum_dict.keys() keys = sum_dict.keys()
keys.sort() keys.sort()
f = open(fname, 'w') f = open(fname, 'w')
@ -56,11 +63,11 @@ class DejaResults(object):
f.close() f.close()
def write_sum_file(self, sum_dict, builder, filename): def write_sum_file(self, sum_dict, builder, filename):
self._write_sum_file(sum_dict, builder, filename) self._write_sum_file(sum_dict, builder, filename, False)
def write_baseline(self, sum_dict, builder, branch): def write_baseline(self, sum_dict, builder, branch):
self.write_sum_file(sum_dict, os.path.join(builder, branch), self.write_sum_file(sum_dict, os.path.join(builder, branch),
'baseline') 'baseline', True)
# Read a .sum file. # Read a .sum file.
# The builder name is BUILDER. # The builder name is BUILDER.
@ -68,9 +75,12 @@ class DejaResults(object):
# revision; to read the baseline file for a branch, use `read_baseline'. # revision; to read the baseline file for a branch, use `read_baseline'.
# Returns a dictionary holding the .sum contents, or None if the # Returns a dictionary holding the .sum contents, or None if the
# file did not exist. # file did not exist.
def read_sum_file(self, builder, filename): def _read_sum_file(self, builder, filename, is_baseline):
global gdb_web_base global gdb_web_base
fname = os.path.join(gdb_web_base, builder, filename) if is_baseline:
fname = os.path.join(gdb_web_base, builder, filename)
else:
fname = os.path.join(gdb_web_base, builder, 'gdb.sum')
if os.path.exists(fname): if os.path.exists(fname):
result = {} result = {}
f = open(fname, 'r') f = open(fname, 'r')
@ -81,8 +91,11 @@ class DejaResults(object):
result = None result = None
return result return result
def read_sum_file (self, builder, filename):
return self._read_sum_file (self, builder, filename, False)
def read_baseline(self, builder, branch): def read_baseline(self, builder, branch):
return self.read_sum_file(builder, os.path.join(branch, 'baseline')) return self._read_sum_file(builder, os.path.join(branch, 'baseline'), True)
# Parse some text as a .sum file and return the resulting # Parse some text as a .sum file and return the resulting
# dictionary. # dictionary.
@ -100,7 +113,7 @@ class DejaResults(object):
our_keys = results.keys() our_keys = results.keys()
our_keys.sort() our_keys.sort()
result = '' result = ''
xfails = self.read_sum_file(builder, 'xfail') xfails = self.read_sum_file(builder, 'xfail', False)
if xfails is None: if xfails is None:
xfails = {} xfails = {}
for key in our_keys: for key in our_keys:

View file

@ -18,10 +18,13 @@ from buildbot.steps.shell import Compile
from buildbot.steps.shell import Configure from buildbot.steps.shell import Configure
from buildbot.steps.shell import ShellCommand from buildbot.steps.shell import ShellCommand
from buildbot.steps.shell import SetPropertyFromCommand from buildbot.steps.shell import SetPropertyFromCommand
from buildbot.steps.transfer import FileUpload
from buildbot.steps.source.git import Git from buildbot.steps.source.git import Git
from buildbot.steps.slave import RemoveDirectory
from buildbot.changes.filter import ChangeFilter from buildbot.changes.filter import ChangeFilter
from buildbot.buildslave import BuildSlave from buildbot.buildslave import BuildSlave
from gdbcommand import GdbCatSumfileCommand from gdbcommand import GdbCatSumfileCommand
from gdbgitdb import SaveGDBResults
from sumfiles import DejaResults, set_web_base from sumfiles import DejaResults, set_web_base
import os.path import os.path
@ -108,11 +111,12 @@ send to the gdb-testers mailing list."""
ss_list = build.getSourceStamps () ss_list = build.getSourceStamps ()
subj = "Failures on %s" % name subj = "Failures on %s" % name
text = "" text = ""
parser = DejaResults () text += "Builder:\n"
text += ("Commit(s) tested:\n") text += "\t%s\n" % build.getSlavename ()
text += "Commit(s) tested:\n"
for ss in ss_list: for ss in ss_list:
text += ("\t%s\n" % ss.revision) text += "\t%s\n" % ss.revision
text += ("\n") text += "\n"
for log in build.getLogs (): for log in build.getLogs ():
if log.getName () == 'regressions' and log.hasContents (): if log.getName () == 'regressions' and log.hasContents ():
text += log.getText () text += log.getText ()
@ -340,7 +344,9 @@ class BuildAndTestGDBFactory (factory.BuildFactory):
def __init__ (self, architecture_triplet = []): def __init__ (self, architecture_triplet = []):
factory.BuildFactory.__init__ (self) factory.BuildFactory.__init__ (self)
self.addStep (DeleteGDBBuildDir ()) self.addStep (RemoveDirectory (dir = WithProperties ("%s/build",
'builddir'))
# self.addStep (DeleteGDBBuildDir ())
# Unfortunately we need to have this random wait, otherwise # Unfortunately we need to have this random wait, otherwise
# git fetch won't work # git fetch won't work
self.addStep (RandomWaitForClone ()) self.addStep (RandomWaitForClone ())
@ -373,6 +379,10 @@ class BuildAndTestGDBFactory (factory.BuildFactory):
self.addStep (GdbCatSumfileCommand (workdir = WithProperties ('%s/build/gdb/testsuite', self.addStep (GdbCatSumfileCommand (workdir = WithProperties ('%s/build/gdb/testsuite',
'builddir'), 'builddir'),
description = 'analyze test results')) description = 'analyze test results'))
self.addStep (transfer.FileUpload (slavesrc = WithProperties ("%s/build/gdb/testsuite/gdb.log", 'builddir'),
masterdest = gdb_web_base + WithProperties ("/%s/gdb.log", 'buildername'),
hideStepIf = False))
self.addStep (SaveGDBResults ())
################## ##################