Skip to content

Commit e5f57d3

Browse files
encukouzware
andcommitted
Consolidate PR and regular worker setup
This is a straightforward merging of the two loops, leaving room for follow-ups. One exception: skipping logic now uses the "wasm" tag for all builders; previously PR builders used "wasi". These tags currently always appear together. Co-Authored-By: Zachary Ware <zach@python.org>
1 parent dc865d1 commit e5f57d3

2 files changed

Lines changed: 73 additions & 89 deletions

File tree

master/custom/branches.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ def __lt__(self, other):
116116

117117

118118
BRANCHES = list(generate_branches())
119-
PR_BRANCH = BRANCHES[-1]
120119

121120
# Verify that we've defined these in sort order
122121
assert BRANCHES == sorted(BRANCHES)

master/master.cfg

Lines changed: 73 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ from custom.builders import ( # noqa: E402
5050
STABLE,
5151
ONLY_MAIN_BRANCH,
5252
)
53-
from custom.branches import BRANCHES, PR_BRANCH
53+
from custom.branches import BRANCHES
5454

5555

5656
def set_up_sentry():
@@ -186,32 +186,40 @@ def is_important_change(change):
186186
return any(is_important_file(filename) for filename in change.files)
187187

188188

189+
# Builders
190+
189191
github_status_builders = []
190192
release_status_builders = []
191193
mail_status_builders = []
192194

193-
# Regular builders
195+
stable_pull_request_builders = []
196+
all_pull_request_builders = []
194197

195198
for branch in BRANCHES:
196-
if not branch.git_branch:
197-
continue
198199
buildernames = []
199200
refleakbuildernames = []
201+
stable_builder_names = []
200202
for name, worker, buildfactory, stability, tier in BUILDERS:
201203
if any(
202204
pattern in name for pattern in ONLY_MAIN_BRANCH
203-
) and not branch.is_main:
205+
) and not branch.is_main and not branch.is_pr:
204206
# Workers known to be broken on older branches: let's focus on
205207
# supporting these platforms in the main branch.
206208
continue
207209

208-
if worker.not_branches and branch.name in worker.not_branches:
209-
continue
210-
if worker.branches and branch.name not in worker.branches:
211-
continue
210+
if not branch.is_pr:
211+
if worker.not_branches and branch.name in worker.not_branches:
212+
continue
213+
if worker.branches and branch.name not in worker.branches:
214+
continue
212215

213216
buildername = name + " " + branch.name
214-
source = Git(repourl=GIT_URL, branch=branch.git_branch, **GIT_KWDS)
217+
218+
if branch.is_pr:
219+
source = GitHub(repourl=GIT_URL, **GIT_KWDS)
220+
else:
221+
source = Git(repourl=GIT_URL, branch=branch.git_branch, **GIT_KWDS)
222+
215223
f = buildfactory(
216224
source,
217225
branch=branch,
@@ -225,6 +233,12 @@ for branch in BRANCHES:
225233
if "wasm" in tags:
226234
if branch.wasm_tier is None:
227235
continue
236+
elif branch.is_pr:
237+
# Don't use the WASI buildbot meant for 3.11 and 3.12 on PRs;
238+
# it's tier 3 only and getting it to work on PRs against `main`
239+
# is too much work.
240+
if "nondebug" in tags:
241+
continue
228242
elif "nondebug" in tags and branch.wasm_tier == 3:
229243
continue
230244
elif "nondebug" not in tags and branch.wasm_tier == 2:
@@ -237,13 +251,17 @@ for branch in BRANCHES:
237251
refleakbuildernames.append(buildername)
238252
else:
239253
buildernames.append(buildername)
240-
# disable notifications for unstable builders
241-
# (all these lists are the same now, but we might need to
242-
# diverge gain later.)
254+
243255
if stability == STABLE:
244-
mail_status_builders.append(buildername)
245-
github_status_builders.append(buildername)
246-
release_status_builders.append(buildername)
256+
stable_builder_names.append(buildername)
257+
258+
# disable notifications for unstable & PR builders
259+
# (all these lists are the same now, but we might need to
260+
# diverge gain later.)
261+
if not branch.is_pr:
262+
mail_status_builders.append(buildername)
263+
github_status_builders.append(buildername)
264+
release_status_builders.append(buildername)
247265

248266
builder = util.BuilderConfig(
249267
name=buildername,
@@ -259,87 +277,54 @@ for branch in BRANCHES:
259277

260278
c["builders"].append(builder)
261279

262-
c["schedulers"].append(
263-
schedulers.SingleBranchScheduler(
264-
name=branch.name,
265-
change_filter=util.ChangeFilter(branch=branch.git_branch),
266-
treeStableTimer=30, # seconds
267-
builderNames=buildernames,
268-
fileIsImportant=is_important_change,
280+
if branch.is_pr:
281+
all_pull_request_builders = refleakbuildernames + buildernames
282+
stable_pull_request_builders = stable_builder_names
283+
c["schedulers"].append(
284+
GitHubPrScheduler(
285+
name="pull-request-scheduler",
286+
change_filter=util.ChangeFilter(filter_fn=should_pr_be_tested),
287+
treeStableTimer=30, # seconds
288+
builderNames=all_pull_request_builders,
289+
stable_builder_names=set(stable_builder_names),
290+
)
269291
)
270-
)
271-
if refleakbuildernames:
292+
else:
272293
c["schedulers"].append(
273294
schedulers.SingleBranchScheduler(
274-
name=branch.name + "-refleak",
295+
name=branch.name,
275296
change_filter=util.ChangeFilter(branch=branch.git_branch),
276-
# Wait this many seconds for no commits before starting a build
277-
# NB: During extremely busy times, this can cause the builders
278-
# to never actually fire. The current expectation is that it
279-
# won't ever actually be that busy, but we need to keep an eye
280-
# on that.
281-
treeStableTimer=1 * 60 * 60, # h * m * s
282-
builderNames=refleakbuildernames,
297+
treeStableTimer=30, # seconds
298+
builderNames=buildernames,
283299
fileIsImportant=is_important_change,
284300
)
285301
)
302+
if refleakbuildernames:
303+
c["schedulers"].append(
304+
schedulers.SingleBranchScheduler(
305+
name=branch.name + "-refleak",
306+
change_filter=util.ChangeFilter(branch=branch.git_branch),
307+
# Wait this many seconds for no commits before starting a build
308+
# NB: During extremely busy times, this can cause the builders
309+
# to never actually fire. The current expectation is that it
310+
# won't ever actually be that busy, but we need to keep an eye
311+
# on that.
312+
treeStableTimer=1 * 60 * 60, # h * m * s
313+
builderNames=refleakbuildernames,
314+
fileIsImportant=is_important_change,
315+
)
316+
)
286317

318+
# Make sure all names are unique
319+
scheduler_names = [s.name for s in c["schedulers"]]
320+
assert len(scheduler_names) == len(set(scheduler_names))
287321

288-
# Set up Pull Request builders
289-
290-
stable_pull_request_builders = []
291-
all_pull_request_builders = []
292-
293-
for name, worker, buildfactory, stability, tier in BUILDERS:
294-
branch = PR_BRANCH
295-
assert PR_BRANCH.is_pr
296-
297-
buildername = f"{name} PR"
298-
source = GitHub(repourl=GIT_URL, **GIT_KWDS)
299-
300-
f = buildfactory(
301-
source,
302-
branch=branch,
303-
worker=worker,
304-
)
305-
306-
tags = [branch.builder_tag, stability, *f.tags]
307-
if tier:
308-
tags.append(tier)
309-
310-
# Don't use the WASI buildbot meant for 3.11 and 3.12 on PRs;
311-
# it's tier 3 only and getting it to work on PRs against `main`
312-
# is too much work.
313-
if "wasi" in tags and "nondebug" in tags:
314-
continue
315-
316-
all_pull_request_builders.append(buildername)
317-
if stability == STABLE:
318-
stable_pull_request_builders.append(buildername)
319-
320-
builder = util.BuilderConfig(
321-
name=buildername,
322-
workernames=[worker.name],
323-
builddir=f"{branch.builddir_name}.{worker.name}{f.buildersuffix}",
324-
factory=f,
325-
tags=tags,
326-
locks=[cpulock.access("counting")],
327-
)
328-
329-
if worker.downtime:
330-
builder.canStartBuild = worker.downtime
331-
332-
c["builders"].append(builder)
333-
334-
c["schedulers"].append(
335-
GitHubPrScheduler(
336-
name="pull-request-scheduler",
337-
change_filter=util.ChangeFilter(filter_fn=should_pr_be_tested),
338-
treeStableTimer=30, # seconds
339-
builderNames=all_pull_request_builders,
340-
stable_builder_names=set(stable_pull_request_builders),
341-
)
342-
)
322+
# Make sure the lists got filled up
323+
assert github_status_builders
324+
assert release_status_builders
325+
assert mail_status_builders
326+
assert stable_pull_request_builders
327+
assert all_pull_request_builders
343328

344329

345330
# Set up aditional schedulers

0 commit comments

Comments
 (0)