diff --git a/lib/gdbgitdb.py b/lib/gdbgitdb.py new file mode 100644 index 0000000..5a0e53b --- /dev/null +++ b/lib/gdbgitdb.py @@ -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 diff --git a/lib/sumfiles.py b/lib/sumfiles.py index 916e6e5..173f100 100644 --- a/lib/sumfiles.py +++ b/lib/sumfiles.py @@ -18,6 +18,10 @@ def set_web_base(arg): # So, use mkdir and not makedirs. os.mkdir(gdb_web_base, 0755) +def get_web_base (): + global gdb_web_base + return gdb_web_base + class DejaResults(object): def __init__(self): object.__init__(self) @@ -42,12 +46,15 @@ class DejaResults(object): test_name = nname 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 bdir = os.path.join(gdb_web_base, subdir) if not os.path.isdir(bdir): 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.sort() f = open(fname, 'w') @@ -56,11 +63,11 @@ class DejaResults(object): f.close() 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): self.write_sum_file(sum_dict, os.path.join(builder, branch), - 'baseline') + 'baseline', True) # Read a .sum file. # The builder name is BUILDER. @@ -68,9 +75,12 @@ class DejaResults(object): # revision; to read the baseline file for a branch, use `read_baseline'. # Returns a dictionary holding the .sum contents, or None if the # file did not exist. - def read_sum_file(self, builder, filename): + def _read_sum_file(self, builder, filename, is_baseline): 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): result = {} f = open(fname, 'r') @@ -81,8 +91,11 @@ class DejaResults(object): result = None return result + def read_sum_file (self, builder, filename): + return self._read_sum_file (self, builder, filename, False) + 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 # dictionary. @@ -100,7 +113,7 @@ class DejaResults(object): our_keys = results.keys() our_keys.sort() result = '' - xfails = self.read_sum_file(builder, 'xfail') + xfails = self.read_sum_file(builder, 'xfail', False) if xfails is None: xfails = {} for key in our_keys: diff --git a/master.cfg b/master.cfg index 94bca42..76c8e07 100644 --- a/master.cfg +++ b/master.cfg @@ -18,10 +18,13 @@ from buildbot.steps.shell import Compile from buildbot.steps.shell import Configure from buildbot.steps.shell import ShellCommand from buildbot.steps.shell import SetPropertyFromCommand +from buildbot.steps.transfer import FileUpload from buildbot.steps.source.git import Git +from buildbot.steps.slave import RemoveDirectory from buildbot.changes.filter import ChangeFilter from buildbot.buildslave import BuildSlave from gdbcommand import GdbCatSumfileCommand +from gdbgitdb import SaveGDBResults from sumfiles import DejaResults, set_web_base import os.path @@ -108,11 +111,12 @@ send to the gdb-testers mailing list.""" ss_list = build.getSourceStamps () subj = "Failures on %s" % name text = "" - parser = DejaResults () - text += ("Commit(s) tested:\n") + text += "Builder:\n" + text += "\t%s\n" % build.getSlavename () + text += "Commit(s) tested:\n" for ss in ss_list: - text += ("\t%s\n" % ss.revision) - text += ("\n") + text += "\t%s\n" % ss.revision + text += "\n" for log in build.getLogs (): if log.getName () == 'regressions' and log.hasContents (): text += log.getText () @@ -340,7 +344,9 @@ class BuildAndTestGDBFactory (factory.BuildFactory): def __init__ (self, architecture_triplet = []): 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 # git fetch won't work self.addStep (RandomWaitForClone ()) @@ -373,6 +379,10 @@ class BuildAndTestGDBFactory (factory.BuildFactory): self.addStep (GdbCatSumfileCommand (workdir = WithProperties ('%s/build/gdb/testsuite', 'builddir'), 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 ()) ##################