phase1: do not leak targets between branches
authorPetr Štetiar <ynezz@true.cz>
Sun, 18 Jun 2023 05:26:17 +0000 (07:26 +0200)
committerPetr Štetiar <ynezz@true.cz>
Sat, 22 Jul 2023 09:05:31 +0000 (11:05 +0200)
Robert noticed, that after rename of `ipq807x` target in main branch to
`qualcommax/ipq807x` subtarget, that buildbot is trying to build this
new `qualcommax/ipq807x` subtarget on `openwrt-23.05` branch as well.

Thibaut later explained, that this is by design, his initial idea was to
find exhaustive list of all targets and let the `checkarch` step do the
final triaging.

I find this approach confusing, because if the subtarget is not present
in that branch, we shouldn't have builder for it configured as well.
Furthermore wasting roughly 5 minutes of precious buildworker time to
checkout all feeds and then just find out, that we're not going to use
those seems suboptimal as well.

So lets fix it by using builders for targets as present in respective
branches.

Fixes: #14
Reported-by: Robert Marko <robimarko@gmail.com>
Signed-off-by: Petr Štetiar <ynezz@true.cz>
phase1/master.cfg

index 799a40bf36e54fb23f707ed37645e397503f618c..c4bccead8c8bf726e5e745d1738a547c83d13655 100644 (file)
@@ -288,7 +288,7 @@ c["prioritizeBuilders"] = prioritizeBuilders
 ####### CHANGESOURCES
 
 # find targets
-targets = set()
+targets = dict()
 
 
 def populateTargets():
@@ -323,12 +323,13 @@ def populateTargets():
             cwd=sourcegit,
         )
 
+        targets[branch] = set()
         while True:
             line = findtargets.stdout.readline()
             if not line:
                 break
             ta = line.decode().strip().split(" ")
-            targets.add(ta[0])
+            targets[branch].add(ta[0])
 
         subprocess.call(["rm", "-rf", sourcegit])
 
@@ -521,7 +522,7 @@ c["schedulers"].append(
                 name="target",
                 label="Build target",
                 default="all",
-                choices=["all"] + list(targets),
+                choices=["all"] + [t for b in branchNames for t in targets[b]],
             ),
             TagChoiceParameter(name="tag", label="Build tag", default=""),
         ],
@@ -735,7 +736,7 @@ c["builders"].append(
 
 
 # NB the phase1 build factory assumes workers are single-build only
-for target in targets:
+def prepareFactory(target):
     ts = target.split("/")
 
     factory = BuildFactory()
@@ -1743,13 +1744,17 @@ for target in targets:
         )
     )
 
-    for brname in branchNames:
+    return factory
+
+
+for brname in branchNames:
+    for target in targets[brname]:
         bldrname = brname + "_" + target
         c["builders"].append(
             BuilderConfig(
                 name=bldrname,
                 workernames=workerNames,
-                factory=factory,
+                factory=prepareFactory(target),
                 tags=[
                     brname,
                 ],