Skip to content

Commit 2ac4ed8

Browse files
cvicentiuRazvanLiviuVarzaru
authored andcommitted
Clean-up common_factories.py
1. Eliminate star imports. Import what you use. 2. Eliminate redundant f-strings without placeholders. 3. Fix wrong escape \ character in Windows-like paths. 4. Eliminate (some) long lines over 80 characters.
1 parent 9116005 commit 2ac4ed8

File tree

1 file changed

+41
-17
lines changed

1 file changed

+41
-17
lines changed

common_factories.py

Lines changed: 41 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,42 @@
1+
import os
2+
import re
3+
14
from twisted.internet import defer
25

3-
from buildbot.plugins import *
6+
from buildbot.plugins import steps, util
47
from buildbot.process import results
58
from buildbot.process.factory import BuildFactory
6-
from buildbot.process.properties import Properties, Property
7-
from buildbot.process.remotecommand import RemoteCommand
8-
from buildbot.steps.mtrlogobserver import MTR, MtrLogObserver
9-
from buildbot.steps.package.rpm.rpmlint import RpmLint
10-
from buildbot.steps.shell import Compile, SetPropertyFromCommand, ShellCommand, Test
11-
from buildbot.steps.source.github import GitHub
12-
from constants import *
13-
from utils import *
9+
from buildbot.process.properties import Property
10+
from buildbot.steps.mtrlogobserver import MTR
11+
12+
# Local
13+
from constants import MTR_ENV, test_type_to_mtr_arg
14+
from utils import (
15+
createVar,
16+
dockerfile,
17+
getArch,
18+
getHTMLLogString,
19+
getSourceTarball,
20+
hasAutobake,
21+
hasBigtest,
22+
hasCompat,
23+
hasDockerLibrary,
24+
hasEco,
25+
hasFailed,
26+
hasFiles,
27+
hasGalera,
28+
hasInstall,
29+
hasRpmLint,
30+
hasS3,
31+
hasUpgrade,
32+
ls2string,
33+
moveMTRLogs,
34+
mtrEnv,
35+
mtrJobsMultiplier,
36+
printEnv,
37+
saveLogs,
38+
savePackage,
39+
)
1440

1541

1642
# TODO for FetchTestData/getLastNFailedBuildsFactory
@@ -80,7 +106,7 @@ def run(self):
80106
def addPostTests(factory):
81107
factory.addStep(saveLogs())
82108

83-
## trigger packages
109+
# trigger packages
84110
factory.addStep(
85111
steps.Trigger(
86112
schedulerNames=["s_packages"],
@@ -96,7 +122,7 @@ def addPostTests(factory):
96122
doStepIf=hasAutobake,
97123
)
98124
)
99-
## trigger bigtest
125+
# trigger bigtest
100126
factory.addStep(
101127
steps.Trigger(
102128
schedulerNames=["s_bigtest"],
@@ -142,7 +168,6 @@ def addPostTests(factory):
142168
waitForFinish=False,
143169
updateSourceStamp=False,
144170
set_properties={
145-
"parentbuildername": Property("buildername"),
146171
"tarbuildnum": Property("tarbuildnum"),
147172
"mariadb_binary": Property("mariadb_binary"),
148173
"mariadb_version": Property("mariadb_version"),
@@ -219,7 +244,8 @@ def getBuildFactoryPreTest(build_type="RelWithDebInfo", additional_args=""):
219244
return f_quick_build
220245

221246

222-
# TODO single function or class object to handle adding tests for different platforms
247+
# TODO single function or class object to handle adding tests for different
248+
# platforms
223249
def addWinTests(
224250
factory: BuildFactory,
225251
mtr_test_type: str,
@@ -229,9 +255,8 @@ def addWinTests(
229255
mtr_suites: list[str],
230256
create_scripts: bool = False,
231257
) -> BuildFactory:
232-
233258
if "default" in mtr_suites:
234-
cmd = f"..\\mysql-test\\collections\\buildbot_suites.bat && cd .."
259+
cmd = "..\\mysql-test\\collections\\buildbot_suites.bat && cd .."
235260
else:
236261
suites = ",".join(mtr_suites)
237262
cmd = (
@@ -274,7 +299,7 @@ def addWinTests(
274299
"dojob",
275300
'"',
276301
util.Interpolate(
277-
f'"C:\Program Files (x86)\Microsoft Visual Studio\\2022\BuildTools\Common7\Tools\VsDevCmd.bat" -arch=%(kw:arch)s && cd mysql-test && {cmd}',
302+
f'"C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\BuildTools\\Common7\\Tools\\VsDevCmd.bat" -arch=%(kw:arch)s && cd mysql-test && {cmd}',
278303
mtr_additional_args=mtr_additional_args,
279304
jobs=util.Property("jobs", default=4),
280305
arch=util.Property("arch", default="x64"),
@@ -595,7 +620,6 @@ def getTests(props):
595620

596621

597622
def getRpmAutobakeFactory(mtrDbPool):
598-
## f_rpm_autobake
599623
f_rpm_autobake = util.BuildFactory()
600624
f_rpm_autobake.addStep(printEnv())
601625
f_rpm_autobake.addStep(

0 commit comments

Comments
 (0)