[buildbot] phase1: switch to separate builders per branch per target

LEDE Commits lede-commits at lists.infradead.org
Mon May 15 08:39:42 PDT 2023


ynezz pushed a commit to buildbot.git, branch master:
https://git.openwrt.org/924e16b31aa7feccde0029d0247cab58734d8970

commit 924e16b31aa7feccde0029d0247cab58734d8970
Author: Thibaut VARÈNE <hacks at slashdirt.org>
AuthorDate: Thu Oct 27 13:09:17 2022 +0200

    phase1: switch to separate builders per branch per target
    
    This will simplify reporting and ensure consistent build statistics.
    It will also simplify prioritizing builders by branch.
    
    This also introduces a single "trigger" scheduler that will handle all
    trigger requests for each branch/target combination, speeding up the
    forcing of builds.
    
    Signed-off-by: Thibaut VARÈNE <hacks at slashdirt.org>
---
 phase1/master.cfg | 57 +++++++++++++++++++++++++++++++++++++++++++------------
 1 file changed, 45 insertions(+), 12 deletions(-)

diff --git a/phase1/master.cfg b/phase1/master.cfg
index 1de168a..ee250e3 100644
--- a/phase1/master.cfg
+++ b/phase1/master.cfg
@@ -370,12 +370,45 @@ class TagChoiceParameter(BaseParameter):
 			raise ValidationError("'%s' does not belong to list of available choices '%s'" % (s, self._choice_list))
 		return s
 
+ at util.renderer
+ at defer.inlineCallbacks
+def builderNames(props):
+	""" since we have per branch and per target builders,
+	address the relevant builder for each new buildrequest
+	based on the request's desired branch and target.
+	"""
+	branch = props.getProperty("branch")
+	target = props.getProperty("target", "")
+
+	if target == "all":
+		target = ""
+
+	# if that didn't work, try sourcestamp to find a branch
+	if not branch:
+		# match builders with target branch
+		ss = props.sourcestamps[0]
+		if ss:
+			branch = ss['branch']
+		else:
+			log.msg("couldn't find builder")
+			return []	# nothing works
+
+	bname = branch + "_" + target
+	builders = []
+
+	for b in (yield props.master.data.get(('builders',))):
+		if not b['name'].startswith(bname):
+			continue
+		builders.append(b['name'])
+
+	return builders
+
 c['schedulers'] = []
 c['schedulers'].append(AnyBranchScheduler(
 	name            = "all",
 	change_filter   = util.ChangeFilter(branch=branchNames),
 	treeStableTimer = 15*60,
-	builderNames    = list(targets)))
+	builderNames    = builderNames))
 
 c['schedulers'].append(ForceScheduler(
 	name         = "force",
@@ -417,6 +450,8 @@ c['schedulers'].append(ForceScheduler(
 	]
 ))
 
+c['schedulers'].append(schedulers.Triggerable(name="trigger", builderNames=builderNames))
+
 ####### BUILDERS
 
 # The 'builders' list defines the Builders, which tell Buildbot how to perform a build:
@@ -559,6 +594,12 @@ for worker in c['workers']:
 c['workers'].append(LocalWorker("__local_force_build", max_builds=1))
 
 force_factory = BuildFactory()
+force_factory.addStep(steps.Trigger(
+	name = "trigger_build",
+	schedulerNames = [ "trigger" ],
+	sourceStamps = [{ "codebase": "", "branch": Property("force_branch"), "revision": Property("force_revision"), "repository": repo_url, "project": "" }],
+	set_properties = { "reason": Property("reason"), "tag": Property("tag"), "target": Property("target") },
+))
 
 c['builders'].append(BuilderConfig(
 	name        = "00_force_build",
@@ -1186,17 +1227,9 @@ for target in targets:
 		hideStepIf = lambda r, s: r==results.FAILURE,
 	))
 
-	c['builders'].append(BuilderConfig(name=target, workernames=workerNames, factory=factory, nextBuild=GetNextBuild))
-
-	c['schedulers'].append(schedulers.Triggerable(name="trigger_%s" % target, builderNames=[ target ]))
-	force_factory.addStep(steps.Trigger(
-		name = "trigger_%s" % target,
-		description = "Triggering %s build" % target,
-		schedulerNames = [ "trigger_%s" % target ],
-		sourceStamps = [{ "codebase": "", "branch": Property("force_branch"), "revision": Property("force_revision"), "repository": repo_url, "project": "" }],
-		set_properties = { "reason": Property("reason"), "tag": Property("tag"), },
-		doStepIf = IsTargetSelected(target),
-	))
+	for brname in branchNames:
+		bldrname = brname + "_" + target
+		c['builders'].append(BuilderConfig(name=bldrname, workernames=workerNames, factory=factory, nextBuild=GetNextBuild))
 
 
 ####### STATUS TARGETS




More information about the lede-commits mailing list