Using a build step instead of steps.SetProperties

This commit is contained in:
Sergio Durigan Junior 2017-09-05 10:02:24 -04:00
parent 2dc344d038
commit 005f813519

View file

@ -783,6 +783,21 @@ command must not make BuildBot halt on failure."""
self.flunkOnFailure = False self.flunkOnFailure = False
self.flunkOnWarnings = False self.flunkOnWarnings = False
class ComputeTryBuildCount (steps.BuildStep):
def run (self):
istry = props.getProperty ('scheduler').startswith ('try')
if not istry:
count = 0
else:
con = sqlite3.connect (db_file)
c = con.cursor ()
c.execute ('SELECT COUNT(*) FROM logs WHERE commitid = "%s" AND branch = "%s" AND trysched = 1' % (sourcestamp.revision, branch))
count = c.fetchone ()[0]
con.close ()
self.setproperty ('try_count', count, 'ComputeTryBuildCount')
def scheduler_is_racy (step): def scheduler_is_racy (step):
return step.getProperty ('scheduler').startswith ('racy') return step.getProperty ('scheduler').startswith ('racy')
@ -808,20 +823,7 @@ def scheduler_is_not_racy_do (step):
def scheduler_is_not_racy_try_do (step): def scheduler_is_not_racy_try_do (step):
return scheduler_is_not_racy (step) and scheduler_is_not_try (step) return scheduler_is_not_racy (step) and scheduler_is_not_try (step)
@util.renderer
def compute_try_build_count (props):
istry = props.getProperty ('scheduler').startswith ('try')
if not istry:
return { "try_count" : "0" }
con = sqlite3.connect (db_file)
c = con.cursor ()
c.execute ('SELECT COUNT(*) FROM logs WHERE commitid = "%s" AND branch = "%s" AND trysched = 1' % (sourcestamp.revision, branch))
count = c.fetchone ()[0]
con.close ()
return { "try_count" : count }
####################### #######################
#### Build Factory #### #### Build Factory ####
@ -927,8 +929,7 @@ The parameters of the class are:
self.addStep (CloneOrUpdateGDBRepo ()) self.addStep (CloneOrUpdateGDBRepo ())
# Set the count of the try build # Set the count of the try build
self.addStep (steps.SetProperties (properties = compute_try_build_count), self.addStep (ComputeTryBuildCount (hideStepIf = scheduler_is_not_try))
hideStepIf = scheduler_is_not_try)
if self.run_testsuite: if self.run_testsuite:
self.addStep (CopyOldGDBSumFile (doStepIf = scheduler_is_not_racy_try_do, self.addStep (CopyOldGDBSumFile (doStepIf = scheduler_is_not_racy_try_do,