Skip to content

Commit 353f2bd

Browse files
JonWBedardaj062
authored andcommitted
[ews-build.webkit.org] Replace shell.ShellCommand with new-style
https://bugs.webkit.org/show_bug.cgi?id=256901 rdar://109463439 Reviewed by Brianna Fan. In an effort to modernize our buildbot code, we should deprecate shell.ShellCommand in favor of shell.ShellCommandNewStyle. * Tools/CISupport/ews-build/steps.py: (CleanUpGitIndexLock): (ShowIdentifier): (RunBindingsTests): (DownloadBuiltProduct): (PushCommitToWebKitRepo): (ValidateRemote): (MapBranchAlias): (AddReviewerToCommitMessage): * Tools/CISupport/ews-build/steps_unittest.py: Originally-landed-as: 272863@main (1079c50). rdar://109463439 Canonical link: https://commits.webkit.org/299250@main
1 parent 0d7a5cb commit 353f2bd

File tree

2 files changed

+70
-77
lines changed

2 files changed

+70
-77
lines changed

Tools/CISupport/ews-build/steps.py

Lines changed: 66 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -810,24 +810,24 @@ def run(self):
810810
defer.returnValue(rc)
811811

812812

813-
class CleanUpGitIndexLock(shell.ShellCommand, ShellMixin):
813+
class CleanUpGitIndexLock(shell.ShellCommandNewStyle, ShellMixin):
814814
name = 'clean-git-index-lock'
815815
command = ['rm', '-f', '.git/index.lock']
816816
descriptionDone = ['Deleted .git/index.lock']
817817

818818
def __init__(self, **kwargs):
819819
super().__init__(timeout=2 * 60, logEnviron=False, **kwargs)
820820

821-
def start(self):
821+
@defer.inlineCallbacks
822+
def run(self):
822823
if self.has_windows_shell():
823824
self.command = ['del', r'.git\index.lock']
824825

825826
self.send_email_for_git_issue()
826-
return shell.ShellCommand.start(self)
827+
rc = yield super().run()
827828

828-
def evaluateCommand(self, cmd):
829829
self.build.buildFinished(['Git issue, retrying build'], RETRY)
830-
return super().evaluateCommand(cmd)
830+
defer.returnValue(rc)
831831

832832
def send_email_for_git_issue(self):
833833
try:
@@ -929,16 +929,17 @@ def hideStepIf(self, results, step):
929929
return results == SUCCESS
930930

931931

932-
class ShowIdentifier(shell.ShellCommand):
932+
class ShowIdentifier(shell.ShellCommandNewStyle):
933933
name = 'show-identifier'
934-
identifier_re = '^Identifier: (.*)$'
934+
identifier_re = r'^Identifier: (.*)$'
935935
flunkOnFailure = False
936936
haltOnFailure = False
937937

938938
def __init__(self, **kwargs):
939939
super().__init__(timeout=5 * 60, logEnviron=False, **kwargs)
940940

941-
def start(self):
941+
@defer.inlineCallbacks
942+
def run(self):
942943
self.log_observer = logobserver.BufferLogObserver()
943944
self.addLogObserver('stdio', self.log_observer)
944945

@@ -950,13 +951,11 @@ def start(self):
950951
revision = candidate
951952
break
952953

953-
self.setCommand(['python3', 'Tools/Scripts/git-webkit', 'find', revision])
954-
return super().start()
954+
self.command = ['python3', 'Tools/Scripts/git-webkit', 'find', revision]
955+
rc = yield super().run()
955956

956-
def evaluateCommand(self, cmd):
957-
rc = super().evaluateCommand(cmd)
958957
if rc != SUCCESS:
959-
return rc
958+
return defer.returnValue(rc)
960959

961960
log_text = self.log_observer.getStdout()
962961
match = re.search(self.identifier_re, log_text, re.MULTILINE)
@@ -975,7 +974,8 @@ def evaluateCommand(self, cmd):
975974
self.descriptionDone = 'Identifier: {}'.format(identifier)
976975
else:
977976
self.descriptionDone = 'Failed to find identifier'
978-
return rc
977+
978+
defer.returnValue(rc)
979979

980980
def getLastBuildStepByName(self, name):
981981
for step in reversed(self.build.executedSteps):
@@ -1059,6 +1059,7 @@ def __init__(self, **kwargs):
10591059
def run(self):
10601060
return super().run()
10611061

1062+
10621063
class UpdateWorkingDirectory(steps.ShellSequence, ShellMixin):
10631064
name = 'update-working-directory'
10641065
description = ['update-working-directory running']
@@ -2994,7 +2995,7 @@ def countFailures(self, returncode):
29942995
return int(match.group('errors'))
29952996

29962997

2997-
class RunBindingsTests(shell.ShellCommand, AddToLogMixin):
2998+
class RunBindingsTests(shell.ShellCommandNewStyle, AddToLogMixin):
29982999
name = 'bindings-tests'
29993000
description = ['bindings-tests running']
30003001
descriptionDone = ['bindings-tests']
@@ -3006,10 +3007,10 @@ class RunBindingsTests(shell.ShellCommand, AddToLogMixin):
30063007
def __init__(self, **kwargs):
30073008
super().__init__(timeout=5 * 60, logEnviron=False, **kwargs)
30083009

3009-
def start(self):
3010+
def run(self):
30103011
self.log_observer = logobserver.BufferLogObserver()
30113012
self.addLogObserver('json', self.log_observer)
3012-
return shell.ShellCommand.start(self)
3013+
return super().run()
30133014

30143015
def getResultSummary(self):
30153016
if self.results == SUCCESS:
@@ -3054,7 +3055,7 @@ def getResultSummary(self):
30543055
return {'step': 'Failed webkitperl tests'}
30553056

30563057
def evaluateCommand(self, cmd):
3057-
rc = shell.ShellCommandNewStyle.evaluateCommand(self, cmd)
3058+
rc = super().evaluateCommand(self, cmd)
30583059
if rc == FAILURE:
30593060
self.build.addStepsAfterCurrentStep([KillOldProcesses(), ReRunWebKitPerlTests()])
30603061
return rc
@@ -5453,7 +5454,7 @@ def getResultSummary(self):
54535454
return super().getResultSummary()
54545455

54555456

5456-
class DownloadBuiltProduct(shell.ShellCommand):
5457+
class DownloadBuiltProduct(shell.ShellCommandNewStyle):
54575458
command = [
54585459
'python3', 'Tools/CISupport/download-built-product',
54595460
WithProperties('--%(configuration)s'),
@@ -5473,19 +5474,17 @@ def getResultSummary(self):
54735474
def __init__(self, **kwargs):
54745475
super().__init__(logEnviron=False, **kwargs)
54755476

5476-
def start(self):
5477+
@defer.inlineCallbacks
5478+
def run(self):
54775479
# Only try to download from S3 on the official deployments <https://webkit.org/b/230006>
5478-
if CURRENT_HOSTNAME in EWS_BUILD_HOSTNAMES + TESTING_ENVIRONMENT_HOSTNAMES:
5479-
return shell.ShellCommand.start(self)
5480-
self.build.addStepsAfterCurrentStep([DownloadBuiltProductFromMaster()])
5481-
self.finished(SKIPPED)
5482-
return defer.succeed(None)
5480+
if CURRENT_HOSTNAME not in (EWS_BUILD_HOSTNAMES + TESTING_ENVIRONMENT_HOSTNAMES):
5481+
self.build.addStepsAfterCurrentStep([DownloadBuiltProductFromMaster()])
5482+
return defer.returnValue(SKIPPED)
54835483

5484-
def evaluateCommand(self, cmd):
5485-
rc = shell.ShellCommand.evaluateCommand(self, cmd)
5484+
rc = yield super().run()
54865485
if rc == FAILURE:
54875486
self.build.addStepsAfterCurrentStep([DownloadBuiltProductFromMaster()])
5488-
return rc
5487+
defer.returnValue(rc)
54895488

54905489

54915490
class DownloadBuiltProductFromMaster(transfer.FileDownload):
@@ -6138,7 +6137,7 @@ def getResultSummary(self):
61386137
return super().getResultSummary()
61396138

61406139

6141-
class PushCommitToWebKitRepo(shell.ShellCommand):
6140+
class PushCommitToWebKitRepo(shell.ShellCommandNewStyle):
61426141
name = 'push-commit-to-webkit-repo'
61436142
descriptionDone = ['Pushed commit to WebKit repository']
61446143
haltOnFailure = False
@@ -6148,21 +6147,21 @@ class PushCommitToWebKitRepo(shell.ShellCommand):
61486147
def __init__(self, **kwargs):
61496148
super().__init__(logEnviron=False, timeout=300, **kwargs)
61506149

6151-
def start(self, BufferLogObserverClass=logobserver.BufferLogObserver):
6150+
@defer.inlineCallbacks
6151+
def run(self, BufferLogObserverClass=logobserver.BufferLogObserver):
61526152
head_ref = self.getProperty('github.base.ref', 'main')
61536153
remote = self.getProperty('remote', '?')
61546154
self.command = ['git', 'push', remote, f'HEAD:{head_ref}']
61556155

61566156
username, access_token = GitHub.credentials(user=GitHub.user_for_queue(self.getProperty('buildername', '')))
6157-
self.workerEnvironment['GIT_USER'] = username
6158-
self.workerEnvironment['GIT_PASSWORD'] = access_token
6157+
self.env['GIT_USER'] = username
6158+
self.env['GIT_PASSWORD'] = access_token
61596159

61606160
self.log_observer = logobserver.BufferLogObserver(wantStderr=True)
61616161
self.addLogObserver('stdio', self.log_observer)
6162-
return super().start()
61636162

6164-
def evaluateCommand(self, cmd):
6165-
rc = shell.ShellCommand.evaluateCommand(self, cmd)
6163+
rc = yield super().run()
6164+
61666165
if rc == SUCCESS:
61676166
log_text = self.log_observer.getStdout() + self.log_observer.getStderr()
61686167
landed_hash = self.hash_from_commit_text(log_text)
@@ -6209,7 +6208,7 @@ def evaluateCommand(self, cmd):
62096208
ValidateChange(addURLs=False, verifycqplus=True),
62106209
PushCommitToWebKitRepo(),
62116210
])
6212-
return rc
6211+
return defer.returnValue(rc)
62136212

62146213
if self.getProperty('github.number', ''):
62156214
self.setProperty('comment_text', 'merge-queue failed to commit PR to repository. To retry, remove any blocking labels and re-apply merge-queue label')
@@ -6219,12 +6218,13 @@ def evaluateCommand(self, cmd):
62196218

62206219
self.setProperty('build_finish_summary', 'Failed to commit to WebKit repository')
62216220
self.build.addStepsAfterCurrentStep([LeaveComment(), SetCommitQueueMinusFlagOnPatch(), BlockPullRequest()])
6222-
return rc
6221+
6222+
defer.returnValue(rc)
62236223

62246224
def getResultSummary(self):
62256225
if self.results != SUCCESS:
62266226
return {'step': 'Failed to push commit to Webkit repository'}
6227-
return shell.ShellCommand.getResultSummary(self)
6227+
return super().getResultSummary()
62286228

62296229
def doStepIf(self, step):
62306230
return CURRENT_HOSTNAME in EWS_BUILD_HOSTNAMES
@@ -6357,7 +6357,7 @@ def run(self):
63576357
defer.returnValue(SUCCESS)
63586358

63596359

6360-
class ValidateRemote(shell.ShellCommand):
6360+
class ValidateRemote(shell.ShellCommandNewStyle):
63616361
name = 'validate-remote'
63626362
haltOnFailure = False
63636363
flunkOnFailure = True
@@ -6366,7 +6366,8 @@ def __init__(self, **kwargs):
63666366
self.summary = ''
63676367
super().__init__(logEnviron=False, **kwargs)
63686368

6369-
def start(self, BufferLogObserverClass=logobserver.BufferLogObserver):
6369+
@defer.inlineCallbacks
6370+
def run(self, BufferLogObserverClass=logobserver.BufferLogObserver):
63706371
base_ref = self.getProperty('github.base.ref', f'{DEFAULT_REMOTE}/{DEFAULT_BRANCH}')
63716372
remote = self.getProperty('remote', DEFAULT_REMOTE)
63726373

@@ -6376,16 +6377,7 @@ def start(self, BufferLogObserverClass=logobserver.BufferLogObserver):
63766377
f'remotes/{DEFAULT_REMOTE}/{base_ref}',
63776378
]
63786379

6379-
return super().start()
6380-
6381-
def getResultSummary(self):
6382-
if self.results in (FAILURE, SUCCESS):
6383-
return {'step': self.summary}
6384-
return super().getResultSummary()
6385-
6386-
def evaluateCommand(self, cmd):
6387-
base_ref = self.getProperty('github.base.ref', f'{DEFAULT_REMOTE}/{DEFAULT_BRANCH}')
6388-
rc = super().evaluateCommand(cmd)
6380+
rc = yield super().run()
63896381

63906382
if rc == SUCCESS:
63916383
self.summary = f"Cannot land on '{base_ref}', it is owned by '{CANONICAL_GITHUB_PROJECT}'"
@@ -6396,13 +6388,18 @@ def evaluateCommand(self, cmd):
63966388
)
63976389
self.setProperty('build_finish_summary', self.summary)
63986390
self.build.addStepsAfterCurrentStep([LeaveComment(), BlockPullRequest()])
6399-
return FAILURE
6391+
return defer.returnValue(FAILURE)
64006392

64016393
if rc == FAILURE:
64026394
self.summary = f"Verified '{CANONICAL_GITHUB_PROJECT}' does not own '{base_ref}'"
6403-
return SUCCESS
6395+
return defer.returnValue(SUCCESS)
64046396

6405-
return rc
6397+
defer.returnValue(rc)
6398+
6399+
def getResultSummary(self):
6400+
if self.results in (FAILURE, SUCCESS):
6401+
return {'step': self.summary}
6402+
return super().getResultSummary()
64066403

64076404
def doStepIf(self, step):
64086405
if not self.getProperty('github.number'):
@@ -6419,7 +6416,7 @@ def hideStepIf(self, results, step):
64196416
# There are cases where we have a branch alias tracking a more traditional static branch.
64206417
# We want contributors to be able to land changes on the branch alias instead of the possibly
64216418
# changing branch.
6422-
class MapBranchAlias(shell.ShellCommand):
6419+
class MapBranchAlias(shell.ShellCommandNewStyle):
64236420
name = 'map-branch-alias'
64246421
haltOnFailure = False
64256422
flunkOnFailure = True
@@ -6430,32 +6427,23 @@ def __init__(self, **kwargs):
64306427
self.summary = ''
64316428
super().__init__(logEnviron=False, timeout=60, **kwargs)
64326429

6433-
def start(self, BufferLogObserverClass=logobserver.BufferLogObserver):
6434-
base_ref = self.getProperty('github.base.ref', DEFAULT_BRANCH)
6430+
@defer.inlineCallbacks
6431+
def run(self, BufferLogObserverClass=logobserver.BufferLogObserver):
6432+
branch = self.getProperty('github.base.ref', DEFAULT_BRANCH)
64356433
remote = self.getProperty('remote', DEFAULT_REMOTE)
64366434

6437-
self.command = ['git', 'branch', '-a', '--contains', f'remotes/{remote}/{base_ref}']
6435+
self.command = ['git', 'branch', '-a', '--contains', f'remotes/{remote}/{branch}']
64386436

64396437
self.log_observer = BufferLogObserverClass(wantStderr=True)
64406438
self.addLogObserver('stdio', self.log_observer)
64416439

6442-
return super().start()
6443-
6444-
def getResultSummary(self):
6445-
if self.results in (FAILURE, SUCCESS):
6446-
return {'step': self.summary}
6447-
return super().getResultSummary()
6448-
6449-
def evaluateCommand(self, cmd):
6450-
remote = self.getProperty('remote', DEFAULT_REMOTE)
6451-
branch = self.getProperty('github.base.ref', DEFAULT_BRANCH)
6452-
rc = super().evaluateCommand(cmd)
6440+
rc = yield super().run()
64536441

64546442
if rc == FAILURE:
64556443
self.summary = f"Failed to query checkout for aliases of '{branch}'"
6456-
return FAILURE
6444+
return defer.returnValue(FAILURE)
64576445
elif rc != SUCCESS:
6458-
return rc
6446+
return defer.returnValue(rc)
64596447

64606448
aliases = set()
64616449
log_text = self.log_observer.getStdout()
@@ -6480,7 +6468,12 @@ def evaluateCommand(self, cmd):
64806468

64816469
self.summary = f"'{branch}' is the prevailing alias"
64826470
self.setProperty('github.base.ref', branch)
6483-
return rc
6471+
defer.returnValue(rc)
6472+
6473+
def getResultSummary(self):
6474+
if self.results in (FAILURE, SUCCESS):
6475+
return {'step': self.summary}
6476+
return super().getResultSummary()
64846477

64856478
def doStepIf(self, step):
64866479
if not self.getProperty('github.number'):
@@ -6604,7 +6597,7 @@ def reviewers(self):
66046597
return 'NOBODY (OOPS!)'
66056598

66066599

6607-
class AddReviewerToCommitMessage(shell.ShellCommand, AddReviewerMixin):
6600+
class AddReviewerToCommitMessage(shell.ShellCommandNewStyle, AddReviewerMixin):
66086601
name = 'add-reviewer-to-commit-message'
66096602
haltOnFailure = True
66106603

@@ -6638,7 +6631,7 @@ def run(self, BufferLogObserverClass=logobserver.BufferLogObserver):
66386631

66396632
commit_environment = yield self.gitCommitEnvironment()
66406633
for key, value in commit_environment.items():
6641-
self.workerEnvironment[key] = value
6634+
self.env[key] = value
66426635

66436636
rc = yield super().run()
66446637
defer.returnValue(rc)

Tools/CISupport/ews-build/steps_unittest.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6980,7 +6980,7 @@ def test_success(self):
69806980
logEnviron=False,
69816981
env=dict(GIT_USER='webkit-commit-queue', GIT_PASSWORD='password'),
69826982
command=['git', 'push', 'origin', 'HEAD:main']) +
6983-
ExpectShell.log('stdio', stdout=' 4c3bac1de151...b94dc426b331 ') +
6983+
ExpectShell.log('stdio', stdout=' 4c3bac1de151...b94dc426b331 \n') +
69846984
0,
69856985
)
69866986
self.expectOutcome(result=SUCCESS, state_string='')
@@ -7521,7 +7521,7 @@ def test_success(self):
75217521
timeout=300,
75227522
logEnviron=False,
75237523
command=['python3', 'Tools/Scripts/git-webkit', 'find', '51a6aec9f664']) +
7524-
ExpectShell.log('stdio', stdout='Identifier: 233175@main') +
7524+
ExpectShell.log('stdio', stdout='Identifier: 233175@main\n') +
75257525
0,
75267526
)
75277527
self.expectOutcome(result=SUCCESS, state_string='Identifier: 233175@main')
@@ -7546,7 +7546,7 @@ def test_success_pull_request(self):
75467546
timeout=300,
75477547
logEnviron=False,
75487548
command=['python3', 'Tools/Scripts/git-webkit', 'find', '51a6aec9f664']) +
7549-
ExpectShell.log('stdio', stdout='Identifier: 233175@main') +
7549+
ExpectShell.log('stdio', stdout='Identifier: 233175@main\n') +
75507550
0,
75517551
)
75527552
self.expectOutcome(result=SUCCESS, state_string='Identifier: 233175@main')
@@ -7567,7 +7567,7 @@ def test_prioritized(self):
75677567
timeout=300,
75687568
logEnviron=False,
75697569
command=['python3', 'Tools/Scripts/git-webkit', 'find', '51a6aec9f664']) +
7570-
ExpectShell.log('stdio', stdout='Identifier: 233175@main') +
7570+
ExpectShell.log('stdio', stdout='Identifier: 233175@main\n') +
75717571
0,
75727572
)
75737573
self.expectOutcome(result=SUCCESS, state_string='Identifier: 233175@main')

0 commit comments

Comments
 (0)