@defer.inlineCallbacks
def prioritizeBuilders(master, builders):
"""Returns sorted list of builders by their last timestamp of completed and
- not skipped build.
+ not skipped build, ordered first by branch name.
@returns: list of sorted builders
"""
+ bldrNamePrio = { "__Janitor": 0, "00_force_build": 0 }
+ i = 1
+ for bname in branchNames:
+ bldrNamePrio[bname] = i
+ i += 1
+
def is_building(bldr):
return bool(bldr.building) or bool(bldr.old_building)
def bldr_sort(item):
(complete_at, bldr) = item
- if bldr.name == "00_force_build":
- date = datetime.min
- complete_at = date.replace(tzinfo=tzutc())
- return (complete_at, bldr.name)
+ pos = 99
+ for (name, prio) in bldrNamePrio.items():
+ if bldr.name.startswith(name):
+ pos = prio
+ break
if not complete_at:
date = datetime.min
date = datetime.max
complete_at = date.replace(tzinfo=tzutc())
- return (complete_at, bldr.name)
+ return (pos, complete_at, bldr.name)
results = yield defer.gatherResults([bldr_info(bldr) for bldr in builders])
results.sort(key=bldr_sort)
# order tagged build first
if r.properties.hasProperty("tag"):
return r
- # then order by branch order
- pbranch = r.properties.getProperty("branch")
- for name in branchNames:
- if pbranch == name:
- return r
r = requests[0]
log.msg("GetNextBuild: {:>20} id: {} bsid: {}".format(builder.name, r.id, r.bsid))