[Buildbot-commits] buildbot/buildbot buildset.py, 1.9, 1.10 interfaces.py, 1.65, 1.66 scheduler.py, 1.31, 1.32
Brian Warner
warner at users.sourceforge.net
Thu May 22 22:13:19 UTC 2008
Update of /cvsroot/buildbot/buildbot/buildbot
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv17668/buildbot
Modified Files:
buildset.py interfaces.py scheduler.py
Log Message:
[project @ #124:schedulers-provide-properties.patch]
Make the scheduler classes actually provide properties to the buildsets
they submit. Triggerable schedulers also do a nice job of configurably
propagating properties from the triggering build.
Original author: dustin at v.igoro.us
Date: 2008-04-13 18:42:31+00:00
Index: buildset.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/buildset.py,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- buildset.py 22 May 2008 22:13:06 -0000 1.9
+++ buildset.py 22 May 2008 22:13:17 -0000 1.10
@@ -1,6 +1,6 @@
-
from buildbot.process import base
from buildbot.status import builder
+from buildbot.process.properties import Properties
class BuildSet:
@@ -20,7 +20,9 @@
self.reason = reason
self.custom_props = custom_props
- self.properties = properties
+
+ self.properties = Properties()
+ if properties: self.properties.updateFromProperties(properties)
self.stillHopeful = True
self.status = bss = builder.BuildSetStatus(source, reason,
Index: interfaces.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/interfaces.py,v
retrieving revision 1.65
retrieving revision 1.66
diff -u -d -r1.65 -r1.66
--- interfaces.py 18 Mar 2008 22:25:55 -0000 1.65
+++ interfaces.py 22 May 2008 22:13:17 -0000 1.66
@@ -38,7 +38,12 @@
class IScheduler(Interface):
"""I watch for Changes in the source tree and decide when to trigger
Builds. I create BuildSet objects and submit them to the BuildMaster. I
- am a service, and the BuildMaster is always my parent."""
+ am a service, and the BuildMaster is always my parent.
+
+ @ivar properties: properties to be applied to all builds started by this
+ scheduler
+ @type properties: L<buildbot.process.properties.Properties>
+ """
def addChange(change):
"""A Change has just been dispatched by one of the ChangeSources.
Index: scheduler.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/scheduler.py,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- scheduler.py 22 May 2008 22:13:06 -0000 1.31
+++ scheduler.py 22 May 2008 22:13:17 -0000 1.32
@@ -46,7 +46,7 @@
# TODO: why can't id() return a positive number? %d is ugly.
return "<Scheduler '%s' at %d>" % (self.name, id(self))
- def submit(self, bs):
+ def submitBuildSet(self, bs):
self.parent.submitBuildSet(bs)
def addChange(self, change):
@@ -55,8 +55,8 @@
class BaseUpstreamScheduler(BaseScheduler):
implements(interfaces.IUpstreamScheduler)
- def __init__(self, name):
- BaseScheduler.__init__(self, name)
+ def __init__(self, name, properties={}):
+ BaseScheduler.__init__(self, name, properties)
self.successWatchers = []
def subscribeToSuccessfulBuilds(self, watcher):
@@ -64,10 +64,10 @@
def unsubscribeToSuccessfulBuilds(self, watcher):
self.successWatchers.remove(watcher)
- def submit(self, bs):
+ def submitBuildSet(self, bs):
d = bs.waitUntilFinished()
d.addCallback(self.buildSetFinished)
- self.parent.submitBuildSet(bs)
+ BaseScheduler.submitBuildSet(self, bs)
def buildSetFinished(self, bss):
if not self.running:
@@ -88,10 +88,10 @@
fileIsImportant = None
compare_attrs = ('name', 'treeStableTimer', 'builderNames', 'branch',
- 'fileIsImportant')
+ 'fileIsImportant', 'properties')
def __init__(self, name, branch, treeStableTimer, builderNames,
- fileIsImportant=None):
+ fileIsImportant=None, properties={}):
"""
@param name: the name of this Scheduler
@param branch: The branch name that the Scheduler should pay
@@ -113,9 +113,12 @@
build is triggered by an important change.
The default value of None means that all
Changes are important.
+
+ @param properties: properties to apply to all builds started from this
+ scheduler
"""
- BaseUpstreamScheduler.__init__(self, name)
+ BaseUpstreamScheduler.__init__(self, name, properties)
self.treeStableTimer = treeStableTimer
errmsg = ("The builderNames= argument to Scheduler must be a list "
"of Builder description names (i.e. the 'name' key of the "
@@ -189,8 +192,9 @@
# create a BuildSet, submit it to the BuildMaster
bs = buildset.BuildSet(self.builderNames,
- SourceStamp(changes=changes))
- self.submit(bs)
+ SourceStamp(changes=changes),
+ properties=self.properties)
+ self.submitBuildSet(bs)
def stopService(self):
self.stopTimer()
@@ -206,10 +210,10 @@
fileIsImportant = None
compare_attrs = ('name', 'branches', 'treeStableTimer', 'builderNames',
- 'fileIsImportant')
+ 'fileIsImportant', 'properties')
def __init__(self, name, branches, treeStableTimer, builderNames,
- fileIsImportant=None):
+ fileIsImportant=None, properties={}):
"""
@param name: the name of this Scheduler
@param branches: The branch names that the Scheduler should pay
@@ -234,9 +238,12 @@
build is triggered by an important change.
The default value of None means that all
Changes are important.
+
+ @param properties: properties to apply to all builds started from this
+ scheduler
"""
- BaseUpstreamScheduler.__init__(self, name)
+ BaseUpstreamScheduler.__init__(self, name, properties)
self.treeStableTimer = treeStableTimer
for b in builderNames:
assert isinstance(b, str)
@@ -290,19 +297,16 @@
self.schedulers[branch] = s
s.addChange(change)
- def submitBuildSet(self, bs):
- self.parent.submitBuildSet(bs)
-
class Dependent(BaseUpstreamScheduler):
"""This scheduler runs some set of 'downstream' builds when the
'upstream' scheduler has completed successfully."""
- compare_attrs = ('name', 'upstream', 'builders')
+ compare_attrs = ('name', 'upstream', 'builders', 'properties')
- def __init__(self, name, upstream, builderNames):
+ def __init__(self, name, upstream, builderNames, properties={}):
assert interfaces.IUpstreamScheduler.providedBy(upstream)
- BaseUpstreamScheduler.__init__(self, name)
+ BaseUpstreamScheduler.__init__(self, name, properties)
self.upstream = upstream
self.builderNames = builderNames
@@ -323,8 +327,9 @@
return d
def upstreamBuilt(self, ss):
- bs = buildset.BuildSet(self.builderNames, ss)
- self.submit(bs)
+ bs = buildset.BuildSet(self.builderNames, ss,
+ properties=self.properties)
+ self.submitBuildSet(bs)
@@ -337,11 +342,11 @@
# TODO: consider having this watch another (changed-based) scheduler and
# merely enforce a minimum time between builds.
- compare_attrs = ('name', 'builderNames', 'periodicBuildTimer', 'branch')
+ compare_attrs = ('name', 'builderNames', 'periodicBuildTimer', 'branch', 'properties')
def __init__(self, name, builderNames, periodicBuildTimer,
- branch=None):
- BaseUpstreamScheduler.__init__(self, name)
+ branch=None, properties={}):
+ BaseUpstreamScheduler.__init__(self, name, properties)
self.builderNames = builderNames
self.periodicBuildTimer = periodicBuildTimer
self.branch = branch
@@ -362,8 +367,9 @@
def doPeriodicBuild(self):
bs = buildset.BuildSet(self.builderNames,
SourceStamp(branch=self.branch),
- self.reason)
- self.submit(bs)
+ self.reason,
+ properties=self.properties)
+ self.submitBuildSet(bs)
@@ -407,15 +413,15 @@
compare_attrs = ('name', 'builderNames',
'minute', 'hour', 'dayOfMonth', 'month',
- 'dayOfWeek', 'branch')
+ 'dayOfWeek', 'branch', 'properties')
def __init__(self, name, builderNames, minute=0, hour='*',
dayOfMonth='*', month='*', dayOfWeek='*',
- branch=None):
+ branch=None, properties={}):
# Setting minute=0 really makes this an 'Hourly' scheduler. This
# seemed like a better default than minute='*', which would result in
# a build every 60 seconds.
- BaseUpstreamScheduler.__init__(self, name)
+ BaseUpstreamScheduler.__init__(self, name, properties)
self.builderNames = builderNames
self.minute = minute
self.hour = hour
@@ -520,20 +526,18 @@
# And trigger a build
bs = buildset.BuildSet(self.builderNames,
SourceStamp(branch=self.branch),
- self.reason)
- self.submit(bs)
+ self.reason,
+ properties=self.properties)
+ self.submitBuildSet(bs)
def addChange(self, change):
pass
-class TryBase(service.MultiService, util.ComparableMixin):
- implements(interfaces.IScheduler)
-
- def __init__(self, name, builderNames):
- service.MultiService.__init__(self)
- self.name = name
+class TryBase(BaseScheduler):
+ def __init__(self, name, builderNames, properties={}):
+ BaseScheduler.__init__(self, name, properties)
self.builderNames = builderNames
def listBuilderNames(self):
@@ -564,10 +568,10 @@
self.error = True
class Try_Jobdir(TryBase):
- compare_attrs = ["name", "builderNames", "jobdir"]
+ compare_attrs = ( 'name', 'builderNames', 'jobdir', 'properties' )
- def __init__(self, name, builderNames, jobdir):
- TryBase.__init__(self, name, builderNames)
+ def __init__(self, name, builderNames, jobdir, properties={}):
+ TryBase.__init__(self, name, builderNames, properties)
self.jobdir = jobdir
self.watcher = MaildirService()
self.watcher.setServiceParent(self)
@@ -642,15 +646,16 @@
return
reason = "'try' job"
- bs = buildset.BuildSet(builderNames, ss, reason=reason, bsid=bsid)
- self.parent.submitBuildSet(bs)
+ bs = buildset.BuildSet(builderNames, ss, reason=reason,
+ bsid=bsid, properties=self.properties)
+ self.submitBuildSet(bs)
class Try_Userpass(TryBase):
- compare_attrs = ["name", "builderNames", "port", "userpass"]
+ compare_attrs = ( 'name', 'builderNames', 'port', 'userpass', 'properties' )
implements(portal.IRealm)
- def __init__(self, name, builderNames, port, userpass):
- TryBase.__init__(self, name, builderNames)
+ def __init__(self, name, builderNames, port, userpass, properties={}):
+ TryBase.__init__(self, name, builderNames, properties)
if type(port) is int:
port = "tcp:%d" % port
self.port = port
@@ -675,9 +680,6 @@
p = Try_Userpass_Perspective(self, avatarID)
return (pb.IPerspective, p, lambda: None)
- def submitBuildSet(self, bs):
- return self.parent.submitBuildSet(bs)
-
class Try_Userpass_Perspective(pbutil.NewCredPerspective):
def __init__(self, parent, username):
self.parent = parent
@@ -699,7 +701,8 @@
bs = buildset.BuildSet(builderNames,
ss,
reason=reason,
- custom_props=custom_props)
+ custom_props=custom_props,
+ properties=self.parent.properties)
self.parent.submitBuildSet(bs)
@@ -713,8 +716,10 @@
the builds that I fire have finished.
"""
- def __init__(self, name, builderNames):
- BaseUpstreamScheduler.__init__(self, name)
+ compare_attrs = ('name', 'builderNames', 'properties')
+
+ def __init__(self, name, builderNames, properties={}):
+ BaseUpstreamScheduler.__init__(self, name, properties)
self.builderNames = builderNames
def listBuilderNames(self):
@@ -723,11 +728,18 @@
def getPendingBuildTimes(self):
return []
- def trigger(self, ss, custom_props={}):
+ def trigger(self, ss, custom_props={}, set_props=None):
"""Trigger this scheduler. Returns a deferred that will fire when the
buildset is finished.
"""
- bs = buildset.BuildSet(self.builderNames, ss, custom_props=custom_props)
+
+ # properties for this buildset are composed of our own properties,
+ # potentially overridden by anything from the triggering build
+ props = Properties()
+ props.updateFromProperties(self.properties)
+ if set_props: props.updateFromProperties(set_props)
+
+ bs = buildset.BuildSet(self.builderNames, ss, custom_props=custom_props, properties=props)
d = bs.waitUntilFinished()
- self.submit(bs)
+ self.submitBuildSet(bs)
return d
More information about the Commits
mailing list