Skip to content

Commit 433277e

Browse files
committed
Refactor schedulers_definition.py
No need to reconstruct the same list over and over, just return a static variable.
1 parent 9809769 commit 433277e

File tree

7 files changed

+68
-115
lines changed

7 files changed

+68
-115
lines changed

master-bintars/master.cfg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ sys.setrecursionlimit(10000)
2121
from common_factories import *
2222
from constants import *
2323
from locks import *
24-
from schedulers_definition import *
24+
from schedulers_definition import SCHEDULERS
2525
from utils import *
2626

2727
FQDN = os.getenv("BUILDMASTER_WG_IP", default="100.64.100.1")
@@ -97,7 +97,7 @@ c["buildbotNetUsageData"] = None
9797
####### SCHEDULERS
9898

9999
# Configure the Schedulers, which decide how to react to incoming changes.
100-
c["schedulers"] = getSchedulers()
100+
c["schedulers"] = SCHEDULERS
101101

102102
####### WORKERS
103103

master-docker-nonstandard-2/master.cfg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ sys.setrecursionlimit(10000)
2020
from common_factories import *
2121
from constants import *
2222
from locks import *
23-
from schedulers_definition import *
23+
from schedulers_definition import SCHEDULERS
2424
from utils import *
2525

2626
FQDN = os.getenv("BUILDMASTER_WG_IP", default="100.64.100.1")
@@ -95,7 +95,7 @@ c["buildbotNetUsageData"] = None
9595
####### SCHEDULERS
9696

9797
# Configure the Schedulers, which decide how to react to incoming changes.
98-
c["schedulers"] = getSchedulers()
98+
c["schedulers"] = SCHEDULERS
9999

100100
####### WORKERS
101101

master-docker-nonstandard/master.cfg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ sys.setrecursionlimit(10000)
2020
from common_factories import *
2121
from constants import *
2222
from locks import *
23-
from schedulers_definition import *
23+
from schedulers_definition import SCHEDULERS
2424
from utils import *
2525

2626
FQDN = os.getenv("BUILDMASTER_WG_IP", default="100.64.100.1")
@@ -95,7 +95,7 @@ c["buildbotNetUsageData"] = None
9595
####### SCHEDULERS
9696

9797
# Configure the Schedulers, which decide how to react to incoming changes.
98-
c["schedulers"] = getSchedulers()
98+
c["schedulers"] = SCHEDULERS
9999

100100
####### WORKERS
101101

master-nonlatent/master.cfg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ sys.setrecursionlimit(10000)
1919
sys.path.insert(0, "/srv/buildbot/master")
2020
from common_factories import *
2121
from locks import *
22-
from schedulers_definition import *
22+
from schedulers_definition import SCHEDULERS
2323
from utils import *
2424

2525
####### VARIABLES
@@ -92,7 +92,7 @@ c["prioritizeBuilders"] = prioritizeBuilders
9292
####### SCHEDULERS
9393

9494
# Configure the Schedulers, which decide how to react to incoming changes.
95-
c["schedulers"] = getSchedulers()
95+
c["schedulers"] = SCHEDULERS
9696

9797
####### WORKERS
9898

master-protected-branches/master.cfg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ sys.path.insert(0, "/srv/buildbot/master")
2121
from constants import *
2222
from utils import *
2323
from locks import *
24-
from schedulers_definition import *
24+
from schedulers_definition import SCHEDULERS
2525
from common_factories import *
2626

2727
# This is the dictionary that the buildmaster pays attention to. We also use
@@ -94,7 +94,7 @@ c["buildbotNetUsageData"] = None
9494
####### SCHEDULERS
9595

9696
# Configure the Schedulers, which decide how to react to incoming changes.
97-
c["schedulers"] = getSchedulers()
97+
c["schedulers"] = SCHEDULERS
9898

9999
####### WORKERS
100100

master.cfg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ sys.path.insert(0, "/srv/buildbot/master")
2121
from common_factories import *
2222
from constants import *
2323
from locks import *
24-
from schedulers_definition import *
24+
from schedulers_definition import SCHEDULERS
2525
from utils import *
2626

2727
with open("master-config.yaml", "r") as f:
@@ -97,7 +97,7 @@ c["buildbotNetUsageData"] = None
9797
####### SCHEDULERS
9898

9999
# Configure the Schedulers, which decide how to react to incoming changes.
100-
c["schedulers"] = getSchedulers()
100+
c["schedulers"] = SCHEDULERS
101101

102102
####### WORKERS
103103

schedulers_definition.py

Lines changed: 56 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from buildbot.interfaces import IProperties
12
from buildbot.plugins import schedulers, util
23
from constants import (
34
builders_autobake,
@@ -12,149 +13,101 @@
1213
)
1314

1415

15-
####### SCHEDULER HELPER FUNCTIONS
16+
############################
17+
# SCHEDULER HELPER FUNCTIONS
18+
############################
1619
@util.renderer
17-
def getBranchBuilderNames(props):
18-
mBranch = props.getProperty("master_branch")
19-
20-
builders = list(
21-
filter(lambda x: x not in github_status_builders, supportedPlatforms[mBranch])
22-
)
23-
24-
return builders
20+
def branchBuilders(props: IProperties) -> list[str]:
21+
master_branch = props.getProperty("master_branch")
22+
builders = supportedPlatforms[master_branch]
23+
return list(filter(lambda x: x not in github_status_builders, builders))
2524

2625

2726
@util.renderer
28-
def getProtectedBuilderNames(props):
29-
mBranch = props.getProperty("master_branch")
30-
31-
builders = list(
32-
filter(lambda x: x in supportedPlatforms[mBranch], github_status_builders)
33-
)
34-
35-
return builders
27+
def protectedBranchBuilders(props: IProperties) -> list[str]:
28+
master_branch = props.getProperty("master_branch")
29+
builders = supportedPlatforms[master_branch]
30+
return list(filter(lambda x: x in builders, github_status_builders))
3631

3732

3833
@util.renderer
39-
def getAutobakeBuilderNames(props):
40-
builderName = props.getProperty("parentbuildername")
34+
def autobakeBuilders(props: IProperties) -> list[str]:
35+
builder_name = props.getProperty("parentbuildername")
4136
for b in builders_autobake:
42-
if builderName in b:
37+
if builder_name in b:
4338
return [b]
4439
return []
4540

4641

4742
@util.renderer
48-
def getBigtestBuilderNames(props):
49-
builderName = str(props.getProperty("parentbuildername"))
50-
43+
def bigtestBuilders(props: IProperties) -> list[str]:
44+
builder_name = props.getProperty("parentbuildername")
5145
for b in builders_big:
52-
if builderName in b:
46+
if builder_name in b:
5347
return [b]
5448
return []
5549

5650

5751
@util.renderer
58-
def getInstallBuilderNames(props):
59-
builderName = str(props.getProperty("parentbuildername"))
60-
52+
def installBuilders(props: IProperties) -> list[str]:
53+
builder_name = props.getProperty("parentbuildername")
6154
for b in builders_install:
62-
if builderName in b:
55+
if builder_name in b:
6356
builders = [b]
64-
if "rhel" in builderName:
57+
if "rhel" in builder_name:
6558
builders.append(b.replace("rhel", "almalinux"))
6659
builders.append(b.replace("rhel", "rockylinux"))
6760
return builders
6861
return []
6962

7063

7164
@util.renderer
72-
def getUpgradeBuilderNames(props):
73-
builderName = str(props.getProperty("parentbuildername"))
74-
75-
builds = []
65+
def upgradeBuilders(props: IProperties) -> list[str]:
66+
builder_name = props.getProperty("parentbuildername")
67+
builders = []
7668
for b in builders_upgrade:
77-
if builderName in b:
78-
if "rhel" in builderName:
79-
builds.append(b.replace("rhel", "almalinux"))
80-
builds.append(b.replace("rhel", "rockylinux"))
81-
builds.append(b)
82-
return builds
69+
if builder_name in b:
70+
if "rhel" in builder_name:
71+
builders.append(b.replace("rhel", "almalinux"))
72+
builders.append(b.replace("rhel", "rockylinux"))
73+
builders.append(b)
74+
return builders
8375

8476

8577
@util.renderer
86-
def getEcoBuilderNames(props):
87-
builderName = str(props.getProperty("parentbuildername"))
88-
89-
builds = []
78+
def ecoBuilders(props: IProperties) -> list[str]:
79+
builder_name = props.getProperty("parentbuildername")
80+
builders = []
9081
for b in builders_eco:
91-
if builderName in b:
92-
builds.append(b)
93-
return builds
82+
if builder_name in b:
83+
builders.append(b)
84+
return builders
9485

9586

9687
@util.renderer
97-
def getDockerLibraryNames(props):
88+
def dockerLibraryBuilders(props: IProperties) -> list[str]:
9889
return builders_dockerlibrary[0]
9990

10091

10192
@util.renderer
102-
def getWordpressNames(props):
93+
def wordpressBuilders(props: IProperties) -> list[str]:
10394
return builders_wordpress[0]
10495

10596

106-
def getSchedulers():
107-
l = []
108-
109-
l.append(
110-
schedulers.Triggerable(
111-
name="s_upstream_all", builderNames=getBranchBuilderNames
112-
)
113-
)
114-
115-
schedulerProtectedBranches = schedulers.Triggerable(
116-
name="s_protected_branches", builderNames=getProtectedBuilderNames
117-
)
118-
l.append(schedulerProtectedBranches)
119-
120-
schedulerPackages = schedulers.Triggerable(
121-
name="s_packages", builderNames=getAutobakeBuilderNames
122-
)
123-
l.append(schedulerPackages)
124-
125-
schedulerBigtests = schedulers.Triggerable(
126-
name="s_bigtest", builderNames=getBigtestBuilderNames
127-
)
128-
l.append(schedulerBigtests)
129-
130-
schedulerInstall = schedulers.Triggerable(
131-
name="s_install", builderNames=getInstallBuilderNames
132-
)
133-
l.append(schedulerInstall)
134-
135-
schedulerUpgrade = schedulers.Triggerable(
136-
name="s_upgrade", builderNames=getUpgradeBuilderNames
137-
)
138-
l.append(schedulerUpgrade)
139-
140-
schedulerEco = schedulers.Triggerable(name="s_eco", builderNames=getEcoBuilderNames)
141-
l.append(schedulerEco)
142-
143-
schedulerDockerlibrary = schedulers.Triggerable(
144-
name="s_dockerlibrary", builderNames=getDockerLibraryNames
145-
)
146-
l.append(schedulerDockerlibrary)
147-
148-
l.append(schedulers.Triggerable(name="s_wordpress", builderNames=getWordpressNames))
149-
150-
l.append(
151-
schedulers.Triggerable(name="s_release_prep", builderNames=["release-prep"])
152-
)
153-
154-
l.append(
155-
schedulers.Triggerable(
156-
name="s_jepsen", builderNames=["amd64-ubuntu-2204-jepsen-mariadb"]
157-
)
158-
)
159-
160-
return l
97+
SCHEDULERS = [
98+
schedulers.Triggerable(name="s_upstream_all", builderNames=branchBuilders),
99+
schedulers.Triggerable(
100+
name="s_protected_branches", builderNames=protectedBranchBuilders
101+
),
102+
schedulers.Triggerable(name="s_packages", builderNames=autobakeBuilders),
103+
schedulers.Triggerable(name="s_bigtest", builderNames=bigtestBuilders),
104+
schedulers.Triggerable(name="s_install", builderNames=installBuilders),
105+
schedulers.Triggerable(name="s_upgrade", builderNames=upgradeBuilders),
106+
schedulers.Triggerable(name="s_eco", builderNames=ecoBuilders),
107+
schedulers.Triggerable(name="s_dockerlibrary", builderNames=dockerLibraryBuilders),
108+
schedulers.Triggerable(name="s_wordpress", builderNames=wordpressBuilders),
109+
schedulers.Triggerable(name="s_release_prep", builderNames=["release-prep"]),
110+
schedulers.Triggerable(
111+
name="s_jepsen", builderNames=["amd64-ubuntu-2204-jepsen-mariadb"]
112+
),
113+
]

0 commit comments

Comments
 (0)