Skip to content

Commit 45b7b4a

Browse files
committed
Treat PR builder setup more like regular builder setup
1 parent 793eff0 commit 45b7b4a

3 files changed

Lines changed: 46 additions & 91 deletions

File tree

master/custom/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
# The Git branch is called "main", but we give it a different name in buildbot.
33
# See git_branches in master/master.cfg.
44
MAIN_BRANCH_NAME = "3.x"
5+
PR_BRANCH_PLACEHOLDER = "PR"
56
JUNIT_FILENAME = "test-results.xml"

master/custom/factories.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
from buildbot.plugins import util
1111

12-
from . import (MAIN_BRANCH_VERSION, MAIN_BRANCH_NAME,
12+
from . import (MAIN_BRANCH_VERSION, MAIN_BRANCH_NAME, PR_BRANCH_PLACEHOLDER,
1313
JUNIT_FILENAME)
1414
from .steps import (
1515
Test,
@@ -151,7 +151,7 @@ def setup(self, parallel_processes, branch, test_with_PTY=False, **kwargs):
151151
env=self.test_environ,
152152
**oot_kwargs
153153
))
154-
if branch not in ("3",) and not has_option("-R", self.testFlags):
154+
if branch not in {PR_BRANCH_PLACEHOLDER} and not has_option("-R", self.testFlags):
155155
filename = JUNIT_FILENAME
156156
if self.build_out_of_tree:
157157
filename = os.path.join(out_of_tree_dir, filename)
@@ -206,7 +206,7 @@ class UnixInstalledBuild(BaseBuild):
206206
def setup(self, parallel_processes, branch, test_with_PTY=False, **kwargs):
207207
if branch == MAIN_BRANCH_NAME:
208208
branch = MAIN_BRANCH_VERSION
209-
elif branch == "custom":
209+
elif branch == PR_BRANCH_PLACEHOLDER:
210210
branch = "3"
211211
installed_python = f"./target/bin/python{branch}"
212212
self.addStep(
@@ -643,7 +643,7 @@ def setup(self, parallel_processes, branch, **kwargs):
643643
command=test_command,
644644
timeout=step_timeout(self.test_timeout),
645645
))
646-
if branch not in ("3",) and not has_option("-R", self.testFlags):
646+
if branch not in {PR_BRANCH_PLACEHOLDER} and not has_option("-R", self.testFlags):
647647
self.addStep(UploadTestResults(branch))
648648
self.addStep(Clean(command=clean_command))
649649

@@ -859,7 +859,7 @@ def setup(self, parallel_processes, branch, test_with_PTY=False, **kwargs):
859859
env=self.test_environ,
860860
workdir=oot_host_path,
861861
))
862-
if branch not in ("3",) and not has_option("-R", self.testFlags):
862+
if branch not in {PR_BRANCH_PLACEHOLDER} and not has_option("-R", self.testFlags):
863863
filename = os.path.join(oot_host_path, JUNIT_FILENAME)
864864
self.addStep(UploadTestResults(branch, filename=filename))
865865
self.addStep(
@@ -998,7 +998,7 @@ def setup(self, parallel_processes, branch, test_with_PTY=False, **kwargs):
998998
workdir=host_path,
999999
)
10001000
)
1001-
if branch not in ("3",) and not has_option("-R", self.testFlags):
1001+
if branch not in {PR_BRANCH_PLACEHOLDER} and not has_option("-R", self.testFlags):
10021002
filename = os.path.join(host_path, JUNIT_FILENAME)
10031003
self.addStep(UploadTestResults(branch, filename=filename))
10041004

master/master.cfg

Lines changed: 39 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ for k in list(sys.modules):
3131
if k.split(".")[0] in ["custom"]:
3232
sys.modules.pop(k)
3333

34-
from custom import MAIN_BRANCH_NAME # noqa: E402
34+
from custom import MAIN_BRANCH_NAME, PR_BRANCH_PLACEHOLDER # noqa: E402
3535
from custom.auth import set_up_authorization # noqa: E402
3636
from custom.email_formatter import MESSAGE_FORMATTER # noqa: E402
3737
from custom.pr_reporter import GitHubPullRequestReporter # noqa: E402
@@ -41,7 +41,7 @@ from custom.pr_testing import ( # noqa: E402
4141
should_pr_be_tested,
4242
)
4343
from custom.settings import Settings # noqa: E402
44-
from custom.steps import Git, GitHub # noqa: E402
44+
from custom.steps import GitHub # noqa: E402
4545
from custom.workers import get_workers # noqa: E402
4646
from custom.schedulers import GitHubPrScheduler # noqa: E402
4747
from custom.release_dashboard import get_release_status_app # noqa: E402
@@ -136,9 +136,10 @@ git_branches = [
136136
(git_url, "3.12", "3.12"),
137137
(git_url, "3.11", "3.11"),
138138
(git_url, "3.10", "3.10"),
139+
(git_url, PR_BRANCH_PLACEHOLDER, "HEAD"),
139140
]
140141

141-
# common Git() and GitHub() keyword arguments
142+
# common Git/GitHub step keyword arguments
142143
GIT_KWDS = {
143144
"timeout": 3600,
144145
# "git clean -fdx": remove all files which are not tracked by Git,
@@ -233,6 +234,7 @@ mail_status_builders = []
233234

234235
for git_url, branchname, git_branch in git_branches:
235236
buildernames = []
237+
stablebuildernames = []
236238
refleakbuildernames = []
237239
for name, worker, buildfactory, stability, tier in BUILDERS:
238240
if any(
@@ -248,7 +250,7 @@ for git_url, branchname, git_branch in git_branches:
248250
continue
249251

250252
buildername = name + " " + branchname
251-
source = Git(repourl=git_url, branch=git_branch, **GIT_KWDS)
253+
source = GitHub(repourl=git_url, branch=git_branch, **GIT_KWDS)
252254
f = buildfactory(
253255
source,
254256
parallel_processes=worker.parallel_processes,
@@ -283,9 +285,7 @@ for git_url, branchname, git_branch in git_branches:
283285
# (all these lists are the same now, but we might need to
284286
# diverge gain later.)
285287
if stability == STABLE:
286-
mail_status_builders.append(buildername)
287-
github_status_builders.append(buildername)
288-
release_status_builders.append(buildername)
288+
stablebuildernames.append(buildername)
289289

290290
builder = util.BuilderConfig(
291291
name=buildername,
@@ -309,90 +309,44 @@ for git_url, branchname, git_branch in git_branches:
309309

310310
c["builders"].append(builder)
311311

312-
c["schedulers"].append(
313-
schedulers.SingleBranchScheduler(
314-
name=branchname,
315-
change_filter=util.ChangeFilter(branch=git_branch),
316-
treeStableTimer=30, # seconds
317-
builderNames=buildernames,
318-
fileIsImportant=is_important_change,
312+
if branchname == PR_BRANCH_PLACEHOLDER:
313+
all_pull_request_builders = buildernames
314+
c["schedulers"].append(
315+
GitHubPrScheduler(
316+
name="pull-request-scheduler",
317+
change_filter=util.ChangeFilter(filter_fn=should_pr_be_tested),
318+
treeStableTimer=30, # seconds
319+
builderNames=buildernames,
320+
stable_builder_names=set(stablebuildernames),
321+
)
319322
)
320-
)
321-
if refleakbuildernames:
323+
else:
324+
mail_status_builders.extend(stablebuildernames)
325+
github_status_builders.extend(stablebuildernames)
326+
release_status_builders.extend(stablebuildernames)
322327
c["schedulers"].append(
323328
schedulers.SingleBranchScheduler(
324-
name=branchname + "-refleak",
329+
name=branchname,
325330
change_filter=util.ChangeFilter(branch=git_branch),
326-
# Wait this many seconds for no commits before starting a build
327-
# NB: During extremely busy times, this can cause the builders
328-
# to never actually fire. The current expectation is that it
329-
# won't ever actually be that busy, but we need to keep an eye
330-
# on that.
331-
treeStableTimer=1 * 60 * 60, # h * m * s
332-
builderNames=refleakbuildernames,
331+
treeStableTimer=30, # seconds
332+
builderNames=buildernames,
333+
fileIsImportant=is_important_change,
333334
)
334335
)
335-
336-
337-
# Set up Pull Request builders
338-
339-
stable_pull_request_builders = []
340-
all_pull_request_builders = []
341-
342-
for name, worker, buildfactory, stability, tier in BUILDERS:
343-
buildername = f"{name} PR"
344-
345-
source = GitHub(repourl=git_url, **GIT_KWDS)
346-
347-
f = buildfactory(
348-
source,
349-
parallel_processes=worker.parallel_processes,
350-
# Use the same downstream branch names as the "custom"
351-
# builder (check what the factories are doing with this
352-
# parameter for more info).
353-
branch="3",
354-
**worker.extra_factory_args,
355-
)
356-
357-
tags = ["PullRequest", stability, *getattr(f, "tags", [])]
358-
if tier:
359-
tags.append(tier)
360-
361-
# Don't use the WASI buildbot meant for 3.11 and 3.12 on PRs;
362-
# it's tier 3 only and getting it to work on PRs against `main`
363-
# is too much work.
364-
if "wasi" in tags and "nondebug" in tags:
365-
continue
366-
367-
all_pull_request_builders.append(buildername)
368-
if stability == STABLE:
369-
stable_pull_request_builders.append(buildername)
370-
371-
builder = util.BuilderConfig(
372-
name=buildername,
373-
workernames=[worker.name],
374-
builddir="%s.%s%s" % ("pull_request", worker.name, getattr(f, "buildersuffix", "")),
375-
factory=f,
376-
tags=tags,
377-
locks=[cpulock.access("counting")],
378-
)
379-
380-
# This worker runs pyperformance at 12am. If a build is scheduled between
381-
# 10pm and 2am, it will be delayed at 2am.
382-
if worker.name == "diegorusso-aarch64-bigmem":
383-
builder.canStartBuild = no_builds_between("22:00", "2:00")
384-
385-
c["builders"].append(builder)
386-
387-
c["schedulers"].append(
388-
GitHubPrScheduler(
389-
name="pull-request-scheduler",
390-
change_filter=util.ChangeFilter(filter_fn=should_pr_be_tested),
391-
treeStableTimer=30, # seconds
392-
builderNames=all_pull_request_builders,
393-
stable_builder_names=set(stable_pull_request_builders),
394-
)
395-
)
336+
if refleakbuildernames:
337+
c["schedulers"].append(
338+
schedulers.SingleBranchScheduler(
339+
name=branchname + "-refleak",
340+
change_filter=util.ChangeFilter(branch=git_branch),
341+
# Wait this many seconds for no commits before starting a build
342+
# NB: During extremely busy times, this can cause the builders
343+
# to never actually fire. The current expectation is that it
344+
# won't ever actually be that busy, but we need to keep an eye
345+
# on that.
346+
treeStableTimer=1 * 60 * 60, # h * m * s
347+
builderNames=refleakbuildernames,
348+
)
349+
)
396350

397351

398352
# Set up aditional schedulers

0 commit comments

Comments
 (0)