Skip to content

Commit

Permalink
Refactor utils.py
Browse files Browse the repository at this point in the history
1. Introduce typehints
2. Include what you use.
  • Loading branch information
cvicentiu committed Jan 7, 2025
1 parent 9aa4446 commit e596b41
Show file tree
Hide file tree
Showing 10 changed files with 184 additions and 176 deletions.
30 changes: 20 additions & 10 deletions common_factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def addPostTests(factory):
steps.SetPropertyFromCommand(
command="basename mariadb-*-linux-*.tar.gz",
property="mariadb_binary",
doStepIf=savePackage,
doStepIf=lambda step: savePackageIfBranchMatch(step, savedPackageBranches),
)
)
factory.addStep(
Expand All @@ -158,7 +158,7 @@ def addPostTests(factory):
&& sync /packages/%(prop:tarbuildnum)s
"""
),
doStepIf=savePackage,
doStepIf=lambda step: savePackageIfBranchMatch(step, savedPackageBranches),
)
)
factory.addStep(
Expand All @@ -174,7 +174,10 @@ def addPostTests(factory):
"master_branch": Property("master_branch"),
"parentbuildername": Property("buildername"),
},
doStepIf=lambda step: savePackage(step) and hasEco(step),
doStepIf=(
lambda step: savePackageIfBranchMatch(step, savedPackageBranches)
and hasEco(step)
),
)
)
factory.addStep(
Expand Down Expand Up @@ -747,7 +750,10 @@ def getRpmAutobakeFactory(mtrDbPool):
sync /packages/%(prop:tarbuildnum)s
"""
),
doStepIf=lambda step: hasFiles(step) and savePackage(step),
doStepIf=(
lambda step: hasFiles(step)
and savePackageIfBranchMatch(step, savedPackageBranches)
),
descriptionDone=util.Interpolate(
"""
Repository available with: curl %(kw:url)s/%(prop:tarbuildnum)s/%(prop:buildername)s/MariaDB.repo -o /etc/yum.repos.d/MariaDB.repo""",
Expand Down Expand Up @@ -784,9 +790,11 @@ def getRpmAutobakeFactory(mtrDbPool):
"master_branch": Property("master_branch"),
"parentbuildername": Property("buildername"),
},
doStepIf=lambda step: hasInstall(step)
and savePackage(step)
and hasFiles(step),
doStepIf=(
lambda step: hasInstall(step)
and savePackageIfBranchMatch(step, savedPackageBranches)
and hasFiles(step)
),
)
)
f_rpm_autobake.addStep(
Expand All @@ -801,9 +809,11 @@ def getRpmAutobakeFactory(mtrDbPool):
"master_branch": Property("master_branch"),
"parentbuildername": Property("buildername"),
},
doStepIf=lambda step: hasUpgrade(step)
and savePackage(step)
and hasFiles(step),
doStepIf=(
lambda step: hasUpgrade(step)
and savePackageIfBranchMatch(step, savedPackageBranches)
and hasFiles(step)
),
)
)
f_rpm_autobake.addStep(
Expand Down
2 changes: 1 addition & 1 deletion master-bintars/master.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ def getBintarFactory(
+ " && sync /packages/"
+ "%(prop:tarbuildnum)s"
),
doStepIf=savePackage,
doStepIf=lambda step: savePackageIfBranchMatch(step, savedPackageBranches),
)
)

Expand Down
14 changes: 9 additions & 5 deletions master-docker-nonstandard-2/master.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,6 @@ f_big_test.addStep(
command="basename mariadb-*-linux-*.tar.gz", property="mariadb_binary"
)
)
# f_big_test.addStep(steps.ShellCommand(name='save_packages', timeout=7200, haltOnFailure=True, command=util.Interpolate('mkdir -p ' + '/packages/' + '%(prop:tarbuildnum)s' + '/' + '%(prop:buildername)s'+ ' && sha256sum %(prop:mariadb_binary)s >> sha256sums.txt && cp ' + '%(prop:mariadb_binary)s sha256sums.txt' + ' /packages/' + '%(prop:tarbuildnum)s' + '/' + '%(prop:buildername)s' + '/' + ' && sync /packages/' + '%(prop:tarbuildnum)s'), doStepIf=savePackage))
f_big_test.addStep(
steps.ShellCommand(
name="cleanup", command="rm -r * .* 2> /dev/null || true", alwaysRun=True
Expand Down Expand Up @@ -757,7 +756,8 @@ f_without_server.addStep(
+ " && sync /packages/"
+ "%(prop:tarbuildnum)s"
),
doStepIf=savePackage,
doStepIf=lambda step: savePackageIfBranchMatch(step,
savedPackageBranches),
)
)
f_without_server.addStep(
Expand Down Expand Up @@ -1044,7 +1044,8 @@ f_bintar.addStep(
steps.SetPropertyFromCommand(
command="basename mariadb-*-linux-*.tar.gz",
property="mariadb_binary",
doStepIf=savePackage,
doStepIf=lambda step: savePackageIfBranchMatch(step,
savedPackageBranches),
)
)
f_bintar.addStep(
Expand All @@ -1068,7 +1069,8 @@ f_bintar.addStep(
+ " && sync /packages/"
+ "%(prop:tarbuildnum)s"
),
doStepIf=savePackage,
doStepIf=lambda step: savePackageIfBranchMatch(step,
savedPackageBranches),
)
)
f_bintar.addStep(
Expand All @@ -1085,7 +1087,9 @@ f_bintar.addStep(
"master_branch": Property("master_branch"),
"parentbuildername": Property("buildername"),
},
doStepIf=lambda step: savePackage(step) and hasEco(step),
doStepIf=(lambda step: savePackageIfBranchMatch(step,
savedPackageBranches)
and hasEco(step)),
)
)
f_bintar.addStep(
Expand Down
9 changes: 4 additions & 5 deletions master-docker-nonstandard/master.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -997,7 +997,6 @@ f_big_test.addStep(
command="basename mariadb-*-linux-*.tar.gz", property="mariadb_binary"
)
)
# f_big_test.addStep(steps.ShellCommand(name='save_packages', timeout=7200, haltOnFailure=True, command=util.Interpolate('mkdir -p ' + '/packages/' + '%(prop:tarbuildnum)s' + '/' + '%(prop:buildername)s'+ ' && sha256sum %(prop:mariadb_binary)s >> sha256sums.txt && cp ' + '%(prop:mariadb_binary)s sha256sums.txt' + ' /packages/' + '%(prop:tarbuildnum)s' + '/' + '%(prop:buildername)s' + '/' + ' && sync /packages/' + '%(prop:tarbuildnum)s'), doStepIf=savePackage))
f_big_test.addStep(
steps.ShellCommand(
name="cleanup", command="rm -r * .* 2> /dev/null || true", alwaysRun=True
Expand Down Expand Up @@ -1134,7 +1133,7 @@ f_without_server.addStep(
+ " && sync /packages/"
+ "%(prop:tarbuildnum)s"
),
doStepIf=savePackage,
doStepIf=lambda step: savePackageIfBranchMatch(step, savedPackageBranches),
)
)
f_without_server.addStep(
Expand Down Expand Up @@ -1422,7 +1421,7 @@ f_bintar.addStep(
steps.SetPropertyFromCommand(
command="basename mariadb-*-linux-*.tar.gz",
property="mariadb_binary",
doStepIf=savePackage,
doStepIf=lambda step: savePackageIfBranchMatch(step, savedPackageBranches),
)
)
f_bintar.addStep(
Expand All @@ -1446,7 +1445,7 @@ f_bintar.addStep(
+ " && sync /packages/"
+ "%(prop:tarbuildnum)s"
),
doStepIf=savePackage,
doStepIf=lambda step: savePackageIfBranchMatch(step, savedPackageBranches),
)
)
f_bintar.addStep(
Expand All @@ -1463,7 +1462,7 @@ f_bintar.addStep(
"master_branch": Property("master_branch"),
"parentbuildername": Property("buildername"),
},
doStepIf=lambda step: savePackage(step) and hasEco(step),
doStepIf=lambda step: savePackageIfBranchMatch(step, savedPackageBranches) and hasEco(step),
)
)
f_bintar.addStep(
Expand Down
8 changes: 4 additions & 4 deletions master-galera/master.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ def dpkgDeb():
"""
),
],
doStepIf=lambda step: savePackage(step, savedPackageBranches),
doStepIf=lambda step: savePackageIfBranchMatch(step, savedPackageBranches),
)


Expand All @@ -284,7 +284,7 @@ def rpmSave():
"""
),
],
doStepIf=lambda step: savePackage(step, savedPackageBranches),
doStepIf=lambda step: savePackageIfBranchMatch(step, savedPackageBranches),
)


Expand Down Expand Up @@ -366,7 +366,7 @@ EOF
""",
url=os.getenv("ARTIFACTS_URL", default="https://ci.mariadb.org"),
),
doStepIf=lambda step: savePackage(step, savedPackageBranches),
doStepIf=lambda step: savePackageIfBranchMatch(step, savedPackageBranches),
)
)
f_deb_build.addStep(
Expand Down Expand Up @@ -423,7 +423,7 @@ EOF
""",
url=os.getenv("ARTIFACTS_URL", default="https://ci.mariadb.org"),
),
doStepIf=lambda step: savePackage(step, savedPackageBranches),
doStepIf=lambda step: savePackageIfBranchMatch(step, savedPackageBranches),
)
)
f_rpm_build.addStep(
Expand Down
1 change: 1 addition & 0 deletions master-libvirt/master.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ sys.setrecursionlimit(10000)
sys.path.insert(0, "/srv/buildbot/master")

from utils import *
from constants import os_info

# This is the dictionary that the buildmaster pays attention to. We also use
# a shorter alias to save typing.
Expand Down
6 changes: 4 additions & 2 deletions master-nonlatent/master.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,8 @@ f_windows_msi.addStep(
'/'

),
doStepIf=savePackage,
doStepIf=lambda step: savePackageIfBranchMatch(step,
savedPackageBranches),
)
)
f_windows_msi.addStep(
Expand All @@ -557,7 +558,8 @@ f_windows_msi.addStep(
'%(prop:buildername)s'
'/'
),
doStepIf=savePackage,
doStepIf=lambda step: savePackageIfBranchMatch(step,
savedPackageBranches),
)
)
f_windows_msi.addStep(
Expand Down
3 changes: 0 additions & 3 deletions master-protected-branches/master.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -422,9 +422,6 @@ f_tarball.addStep(
doStepIf=lambda step: isStagingBranch(step),
)
)
# f_tarball.addStep(steps.ShellSequence( commands=[
# util.ShellArg(command=util.Interpolate("git checkout " + "%(prop:staging_branch)s"), logfile="rebase"),
# util.ShellArg(command=util.Interpolate("git merge %(prop:branch)s"), logfile="rebase")], workdir="build/server", haltOnFailure="true", doStepIf=ifStagingSucceeding))
f_tarball.addStep(
steps.ShellCommand(
name="cleanup", command="rm -r * .* 2> /dev/null || true", alwaysRun=True
Expand Down
10 changes: 7 additions & 3 deletions master.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ f_deb_autobake.addStep(
"master_branch": Property("master_branch"),
"parentbuildername": Property("buildername"),
},
doStepIf=lambda step: savePackage(step),
doStepIf=lambda step: savePackageIfBranchMatch(step, savedPackageBranches),
)
)
f_deb_autobake.addStep(
Expand All @@ -250,7 +250,9 @@ f_deb_autobake.addStep(
"master_branch": Property("master_branch"),
"parentbuildername": Property("buildername"),
},
doStepIf=lambda step: hasInstall(step) and savePackage(step) and hasFiles(step),
doStepIf=(lambda step: hasInstall(step)
and savePackageIfBranchMatch(step, savedPackageBranches)
and hasFiles(step)),
)
)
f_deb_autobake.addStep(
Expand All @@ -265,7 +267,9 @@ f_deb_autobake.addStep(
"master_branch": Property("master_branch"),
"parentbuildername": Property("buildername"),
},
doStepIf=lambda step: hasUpgrade(step) and savePackage(step) and hasFiles(step),
doStepIf=(lambda step: hasUpgrade(step)
and savePackageIfBranchMatch(step, savedPackageBranches)
and hasFiles(step)),
)
)
f_deb_autobake.addStep(
Expand Down
Loading

0 comments on commit e596b41

Please sign in to comment.