aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Sulfrian <alexander@sulfrian.net>2012-03-26 04:15:25 +0200
committerAlexander Sulfrian <alexander@sulfrian.net>2012-03-26 04:18:51 +0200
commit06aad8e62fd0b849996e187f1b2f4e88ed1de299 (patch)
tree570052b70454297e6910ed496ca7b788bea8df5e
downloadbuildbot_ext-06aad8e62fd0b849996e187f1b2f4e88ed1de299.tar.gz
buildbot_ext-06aad8e62fd0b849996e187f1b2f4e88ed1de299.tar.xz
buildbot_ext-06aad8e62fd0b849996e187f1b2f4e88ed1de299.zip
initial import
-rw-r--r--CPPUnitTest.py10
-rw-r--r--Doxygen.py8
-rw-r--r--ExLogFile.py107
-rw-r--r--GroupBuildStep.py201
-rw-r--r--GroupBuildStepStatus.py14
-rw-r--r--__init__.py0
6 files changed, 340 insertions, 0 deletions
diff --git a/CPPUnitTest.py b/CPPUnitTest.py
new file mode 100644
index 0000000..4c9d977
--- /dev/null
+++ b/CPPUnitTest.py
@@ -0,0 +1,10 @@
+from buildbot.steps.shell import Test
+
+class CPPUnitTest(Test):
+ def __init__(self, **kwargs):
+ Test.__init__(self, **kwargs) # always upcall!
+
+ def finished(self,result):
+ self.addURL("test-results", "/" + str(self.getProperty("buildername")) + "/" +
+ str(self.getProperty("buildnumber")) + "/tests/test.xml")
+ Test.finished(self, result)
diff --git a/Doxygen.py b/Doxygen.py
new file mode 100644
index 0000000..49090ac
--- /dev/null
+++ b/Doxygen.py
@@ -0,0 +1,8 @@
+from buildbot.steps.shell import ShellCommand
+
+class Doxygen(ShellCommand):
+ name = "doxygen"
+ description = ["generating docs"]
+ descriptionDone = ["generated docs"]
+ command = ["doxygen"]
+
diff --git a/ExLogFile.py b/ExLogFile.py
new file mode 100644
index 0000000..fc1fce2
--- /dev/null
+++ b/ExLogFile.py
@@ -0,0 +1,107 @@
+from zope.interface import implements
+from buildbot.interfaces import IStatusLog, ILogFile, LOG_CHANNEL_STDOUT
+
+class ExLogFile():
+ implements(IStatusLog, ILogFile)
+ log = None
+ realname = None
+
+ @property
+ def finished(self):
+ return self.log.finished
+ @property
+ def length(self):
+ return self.log.length
+ @property
+ def nonHeaderLength(self):
+ return self.log.nonHeaderLength
+ @property
+ def tailLength(self):
+ return self.log.tailLength
+ @property
+ def chunkSize(self):
+ return self.log.chunkSize
+ @property
+ def runLength(self):
+ return self.log.runLength
+ @property
+ def logMaxSize(self):
+ return self.log.logMaxSize
+ @property
+ def logMaxTailSize(self):
+ return self.log.logMaxTailSize
+ @property
+ def maxLengthExceeded(self):
+ return self.log.maxLengthExceeded
+ @property
+ def runEntries(self):
+ return self.log.runEntries
+ @property
+ def entries(self):
+ return self.log.entries
+ @property
+ def BUFFERSIZE(self):
+ return self.log.BUFFERSIZE
+ @property
+ def filename(self):
+ return self.log.filename
+ @property
+ def openfile(self):
+ return self.log.openfile
+ @property
+ def compressMethod(self):
+ return self.log.compressMethod
+
+
+ def __init__(self, log, realname):
+ self.log = log
+ self.realname = realname
+
+ def getName(self):
+ return self.realname
+
+ def getStep(self):
+ return self.log.getStep()
+
+ def isFinished(self):
+ return self.log.isFinished()
+
+ def waitUntilFinished(self):
+ return self.log.waitUntilFinished()
+
+ def subscribe(self, receiver, catchup):
+ return self.log.subscribe(receiver, catchup)
+
+ def unsubscribe(self, receiver):
+ return self.log.unsubscribe(receiver)
+
+ def subscribeConsumer(self, consumer):
+ return self.log.subscribeConsumer(consumer)
+
+ def hasContents(self):
+ return self.log.hasContents()
+
+ def getText(self):
+ return self.log.getText()
+
+ def readlines(self, channel=LOG_CHANNEL_STDOUT):
+ return self.log.readlines(channel)
+
+ def getTextWithHeaders(self):
+ return self.log.getTextWithHeaders()
+
+ def getChunks(self):
+ return self.log.getChunks()
+
+ def addStdout(self,data):
+ return self.log.addStdout(data)
+
+ def addStderr(self,data):
+ return self.log.addStderr(data)
+
+ def addHeader(self,data):
+ return self.log.addHeader(data)
+
+ def finish(self):
+ return self.log.finish()
+
diff --git a/GroupBuildStep.py b/GroupBuildStep.py
new file mode 100644
index 0000000..5f7d168
--- /dev/null
+++ b/GroupBuildStep.py
@@ -0,0 +1,201 @@
+import types
+import GroupBuildStepStatus
+from twisted.internet import defer
+from twisted.python import log
+from buildbot.process.buildstep import LoggingBuildStep
+from buildbot.status.builder import Results
+from buildbot.status.builder import SUCCESS, WARNINGS, FAILURE, SKIPPED, \
+ EXCEPTION, RETRY, worst_status
+
+class GroupBuildStep(LoggingBuildStep):
+ renderables = ['description', 'descriptionDone']
+
+ finished = False
+ results = None
+ stopped = False
+ steps = []
+ buildslave = None
+ workdir = None
+
+ def __init__(self, steps = [], description=None, descriptionDone=None, links=[], **kwargs):
+ LoggingBuildStep.__init__(self, **kwargs)
+ self.addFactoryArguments(steps=steps,
+ description=description,
+ descriptionDone=descriptionDone,
+ links=links)
+ self.factories = [s.getStepFactory() for s in steps]
+ self.description = [description]
+ self.descriptionDone = [descriptionDone]
+ self.links = links
+
+ self.currentStep = None
+ self.terminate = False
+ self.results = [] # list of FAILURE, SUCCESS, WARNINGS, SKIPPED
+ self.result = SUCCESS # overall result, may downgrade after each step
+ self.text = [] # list of text string lists (text2)
+
+ def describe(self, done=False):
+ if done and self.descriptionDone is not None:
+ return self.descriptionDone
+ if self.description is not None:
+ return self.description
+ if currentStep is not None:
+ return currentStep.describe(done)
+ return LoggingBuildStep.describe(self, done)
+
+ def setBuild(self, build):
+ LoggingBuildStep.setBuild(self, build)
+
+ # create build steps like Build does it
+ # this has to be done here to be able to execute this
+ # build step more then once afte a master restart
+ for factory, args in self.factories:
+ args = args.copy()
+ try:
+ self.steps.append(factory(**args))
+ except:
+ log.msg("error while creating step, factory=%s, args=%s"
+ % (factory, args))
+ raise
+
+ for step in self.steps:
+ step.setBuild(build)
+
+ def setBuildSlave(self, buildslave):
+ LoggingBuildStep.setBuildSlave(self, buildslave)
+ for step in self.steps:
+ step.setBuildSlave(buildslave)
+
+ def setDefaultWorkdir(self, workdir):
+ LoggingBuildStep.setDefaultWorkdir(self, workdir)
+ for step in self.steps:
+ step.setDefaultWorkdir(workdir)
+
+ def setBuildSlave(self, buildslave):
+ self.buildslave = buildslave
+ LoggingBuildStep.setBuildSlave(self, buildslave)
+
+ def setDefaultWorkdir(self, workdir):
+ self.workdir = workdir
+ LoggingBuildStep.setDefaultWorkdir(self, workdir)
+
+ def setStepStatus(self, step_status):
+ LoggingBuildStep.setStepStatus(self, step_status)
+ i = 0
+ for step in self.steps:
+ substep_status = GroupBuildStepStatus(step_status, i)
+ substep_status.setName(step.name)
+ step.setBuild(self.build)
+ step.setDefaultWorkdir(self.workdir)
+ step.setBuildSlave(self.buildslave)
+ step.setStepStatus(substep_status)
+ i = i + 1
+
+ def startStep(self, remote):
+ self.remote = remote
+ return LoggingBuildStep.startStep(self, remote)
+
+ def start(self):
+ log.msg("start")
+ self.startNextStep()
+
+ def getNextStep(self):
+ if not self.steps:
+ return None
+ if not self.remote:
+ return None
+ if self.terminate or self.stopped:
+ # Run any remaining alwaysRun steps, and skip over the others
+ while True:
+ s = self.steps.pop(0)
+ if s.alwaysRun:
+ return s
+ if not self.steps:
+ return None
+ else:
+ return self.steps.pop(0)
+
+ def startNextStep(self):
+ try:
+ s = self.getNextStep()
+ except StopIteration:
+ s = None
+ if not s:
+ return self.allStepsDone()
+ self.currentStep = s
+ d = defer.maybeDeferred(s.startStep, self.remote)
+ d.addCallback(self._stepDone, s)
+ d.addErrback(self.failed)
+
+ def _stepDone(self, results, step):
+ self.currentStep = None
+ if self.finished:
+ return # build was interrupted, don't keep building
+ terminate = self.stepDone(results, step) # interpret/merge results
+ if terminate:
+ self.terminate = True
+ return self.startNextStep()
+
+ def stepDone(self, result, step):
+ terminate = False
+ text = None
+ if type(result) == types.TupleType:
+ result, text = result
+ assert type(result) == type(SUCCESS)
+ log.msg(" step '%s' complete: %s" % (step.name, Results[result]))
+ self.results.append(result)
+ if text:
+ self.text.extend(text)
+ if not self.remote:
+ terminate = True
+
+ possible_overall_result = result
+ if result == FAILURE:
+ if not step.flunkOnFailure:
+ possible_overall_result = SUCCESS
+ if step.warnOnFailure:
+ possible_overall_result = WARNINGS
+ if step.flunkOnFailure:
+ possible_overall_result = FAILURE
+ if step.haltOnFailure:
+ terminate = True
+ elif result == WARNINGS:
+ if not step.warnOnWarnings:
+ possible_overall_result = SUCCESS
+ else:
+ possible_overall_result = WARNINGS
+ if step.flunkOnWarnings:
+ possible_overall_result = FAILURE
+ elif result in (EXCEPTION, RETRY):
+ terminate = True
+
+ # if we skipped this step, then don't adjust the build status
+ if result != SKIPPED:
+ self.result = worst_status(self.result, possible_overall_result)
+
+ return terminate
+
+ def allStepsDone(self):
+ for link in self.links:
+ self.addURL(link['title'], self.build.getProperties().render(link['href']))
+
+ return LoggingBuildStep.finished(self, self.result)
+
+ def failed(self, why):
+ LoggingBuildStep.failed(self, why)
+
+ def interrupt(self, reason="<no reason given>"):
+ log.msg(" %s: stopping build: %s" % (self, reason))
+ if self.finished:
+ return
+
+ self.stopped = True
+ if self.currentStep:
+ self.currentStep.interrupt(reason)
+
+ self.result = EXCEPTION
+
+ if self._acquiringLock:
+ lock, access, d = self._acquiringLock
+ lock.stopWaitingUntilAvailable(self, access, d)
+ d.callback(None)
diff --git a/GroupBuildStepStatus.py b/GroupBuildStepStatus.py
new file mode 100644
index 0000000..84df509
--- /dev/null
+++ b/GroupBuildStepStatus.py
@@ -0,0 +1,14 @@
+import ExLogFile
+from buildbot.status.builder import BuildStepStatus
+
+class GroupBuildStepStatus(BuildStepStatus):
+ def __init__(self, step_status, step_number):
+ self.step_status = step_status
+ BuildStepStatus.__init__(self, step_status.getBuild(), step_number)
+
+ def addLog(self, name):
+ log = self.step_status.addLog(self.getName() + '-' + name)
+ log = ExLogFile(log = log, realname = name)
+ self.logs.append(log)
+ return log
+
diff --git a/__init__.py b/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/__init__.py