Skip to content
Permalink
Browse files
[EWS] Need /bin/sh equivalent on wincairo
https://bugs.webkit.org/show_bug.cgi?id=236608
<rdar://problem/88926062>

Reviewed by Don Olmstead.

* Tools/CISupport/ews-build/steps.py:
(ShellMixin.shell_command): Invoke provided command with
the system shell (either /bin/sh or cmd)
(ShellMixin.shell_exit_0): Trailing shell command ensuring
a 0 exit code regardless of the outcome of previous commands.
(ApplyPatch.start): Invoke command with cmd or /bin/sh/.
(CheckOutPullRequest.run): Ditto.
(CleanGitRepo.run): Ditto.
* Tools/CISupport/ews-build/steps_unittest.py:


Canonical link: https://commits.webkit.org/247276@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@289815 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
JonWBedard committed Feb 15, 2022
1 parent 7b1a6e6 commit 6f120109a731d515b4261f4b6c0894e58a7ef2e0
Show file tree
Hide file tree
Showing 3 changed files with 120 additions and 12 deletions.
@@ -206,6 +206,23 @@ def should_send_email_for_pr(self, pr_number):
return True


class ShellMixin(object):
WINDOWS_SHELL_PLATFORMS = ['wincairo']

def has_windows_shell(self):
return self.getProperty('platform', '*') in self.WINDOWS_SHELL_PLATFORMS

def shell_command(self, command):
if self.has_windows_shell():
return ['cmd', '/c', command]
return ['/bin/sh', '-c', command]

def shell_exit_0(self):
if self.has_windows_shell():
return 'exit 0'
return 'true'


class Contributors(object):
url = 'https://raw.githubusercontent.com/WebKit/WebKit/main/metadata/contributors.json'
contributors = {}
@@ -567,7 +584,7 @@ def evaluateCommand(self, cmd):
return rc


class ApplyPatch(shell.ShellCommand, CompositeStepMixin):
class ApplyPatch(shell.ShellCommand, CompositeStepMixin, ShellMixin):
name = 'apply-patch'
description = ['applying-patch']
descriptionDone = ['Applied patch']
@@ -591,7 +608,7 @@ def start(self):
if not patch:
# Forced build, don't have patch_id raw data on the request, need to fech it.
patch_id = self.getProperty('patch_id', '')
self.command = ['/bin/sh', '-c', 'curl -L "https://bugs.webkit.org/attachment.cgi?id={}" -o .buildbot-diff && {}'.format(patch_id, ' '.join(self.command))]
self.command = self.shell_command('curl -L "https://bugs.webkit.org/attachment.cgi?id={}" -o .buildbot-diff && {}'.format(patch_id, ' '.join(self.command)))
shell.ShellCommand.start(self)
return None

@@ -626,7 +643,7 @@ def evaluateCommand(self, cmd):
return rc


class CheckOutPullRequest(steps.ShellSequence):
class CheckOutPullRequest(steps.ShellSequence, ShellMixin):
name = 'checkout-pull-request'
description = ['checking-out-pull-request']
descriptionDone = ['Checked out pull request']
@@ -651,7 +668,7 @@ def run(self):
rebase_target_hash = self.getProperty('ews_revision') or self.getProperty('got_revision')

commands = [
['/bin/sh', '-c', 'git remote add {} {}{}.git & true'.format(remote, GITHUB_URL, project)],
self.shell_command('git remote add {} {}{}.git || {}'.format(remote, GITHUB_URL, project, self.shell_exit_0())),
['git', 'remote', 'set-url', remote, '{}{}.git'.format(GITHUB_URL, project)],
['git', 'fetch', remote],
['git', 'branch', '-f', pr_branch, 'remotes/{}/{}'.format(remote, pr_branch)],
@@ -3935,7 +3952,7 @@ def getResultSummary(self):


# FIXME: We should be able to remove this step once abandoning patch workflows
class CleanGitRepo(steps.ShellSequence):
class CleanGitRepo(steps.ShellSequence, ShellMixin):
name = 'clean-up-git-repo'
haltOnFailure = False
flunkOnFailure = False
@@ -3950,7 +3967,7 @@ def run(self):
branch = self.getProperty('basename', self.default_branch)
self.commands = []
for command in [
['/bin/sh', '-c', 'git rebase --abort & true'],
self.shell_command('git rebase --abort || {}'.format(self.shell_exit_0())),
['git', 'clean', '-f', '-d'], # Remove any left-over layout test results, added files, etc.
['git', 'fetch', self.git_remote], # Avoid updating the working copy to a stale revision.
['git', 'checkout', '{}/{}'.format(self.git_remote, branch), '-f'], # Checkout branch from specific remote
@@ -3106,7 +3106,58 @@ def test_success(self):
workdir='wkdir',
timeout=600,
logEnviron=False,
command=['/bin/sh', '-c', 'git remote add Contributor https://github.com/Contributor/WebKit.git & true'],
command=['/bin/sh', '-c', 'git remote add Contributor https://github.com/Contributor/WebKit.git || true'],
) + 0, ExpectShell(
workdir='wkdir',
timeout=600,
logEnviron=False,
command=['git', 'remote', 'set-url', 'Contributor', 'https://github.com/Contributor/WebKit.git'],
) + 0, ExpectShell(
workdir='wkdir',
timeout=600,
logEnviron=False,
command=['git', 'fetch', 'Contributor'],
) + 0, ExpectShell(
workdir='wkdir',
timeout=600,
logEnviron=False,
command=['git', 'branch', '-f', 'eng/pull-request-branch', 'remotes/Contributor/eng/pull-request-branch'],
) + 0, ExpectShell(
workdir='wkdir',
timeout=600,
logEnviron=False,
command=['git', 'checkout', 'eng/pull-request-branch'],
) + 0, ExpectShell(
workdir='wkdir',
timeout=600,
logEnviron=False,
command=['git', 'config', 'merge.changelog.driver', 'perl Tools/Scripts/resolve-ChangeLogs --merge-driver -c %O %A %B'],
) + 0, ExpectShell(
workdir='wkdir',
timeout=600,
logEnviron=False,
command=['git', 'rebase', '--onto', '59dab0396721db221c264aad3c0cea37ef0d297b', 'aaebef7312238f3ad1d25e8894916a1aaea45ba1', 'eng/pull-request-branch'],
) + 0,
)
self.expectOutcome(result=SUCCESS, state_string='Checked out pull request')
return self.runStep()

def test_success_wincairo(self):
self.setupStep(CheckOutPullRequest())
self.setProperty('platform', 'wincairo')
self.setProperty('github.number', '1234')
self.setProperty('github.head.repo.full_name', 'Contributor/WebKit')
self.setProperty('github.head.ref', 'eng/pull-request-branch')
self.setProperty('github.base.sha', 'aaebef7312238f3ad1d25e8894916a1aaea45ba1')
self.setProperty('got_revision', '59dab0396721db221c264aad3c0cea37ef0d297b')
self.assertEqual(CheckOutPullRequest.flunkOnFailure, True)
self.assertEqual(CheckOutPullRequest.haltOnFailure, True)
self.expectRemoteCommands(
ExpectShell(
workdir='wkdir',
timeout=600,
logEnviron=False,
command=['cmd', '/c', 'git remote add Contributor https://github.com/Contributor/WebKit.git || exit 0'],
) + 0, ExpectShell(
workdir='wkdir',
timeout=600,
@@ -3156,7 +3207,7 @@ def test_failure(self):
workdir='wkdir',
timeout=600,
logEnviron=False,
command=['/bin/sh', '-c', 'git remote add Contributor https://github.com/Contributor/WebKit.git & true'],
command=['/bin/sh', '-c', 'git remote add Contributor https://github.com/Contributor/WebKit.git || true'],
) + 0, ExpectShell(
workdir='wkdir',
timeout=600,
@@ -4567,7 +4618,29 @@ def test_success(self):
self.setProperty('buildername', 'Style-EWS')

self.expectRemoteCommands(
ExpectShell(command=['/bin/sh', '-c', 'git rebase --abort & true'], workdir='wkdir', timeout=300, logEnviron=False) + 0
ExpectShell(command=['/bin/sh', '-c', 'git rebase --abort || true'], workdir='wkdir', timeout=300, logEnviron=False) + 0
+ ExpectShell.log('stdio', stdout=''),
ExpectShell(command=['git', 'clean', '-f', '-d'], workdir='wkdir', timeout=300, logEnviron=False) + 0
+ ExpectShell.log('stdio', stdout=''),
ExpectShell(command=['git', 'fetch', 'origin'], workdir='wkdir', timeout=300, logEnviron=False) + 0
+ ExpectShell.log('stdio', stdout=''),
ExpectShell(command=['git', 'checkout', 'origin/main', '-f'], workdir='wkdir', timeout=300, logEnviron=False) + 0
+ ExpectShell.log('stdio', stdout='You are in detached HEAD state.'),
ExpectShell(command=['git', 'branch', '-D', 'main'], workdir='wkdir', timeout=300, logEnviron=False) + 0
+ ExpectShell.log('stdio', stdout='Deleted branch main (was 57015967fef9).'),
ExpectShell(command=['git', 'checkout', 'origin/main', '-b', 'main'], workdir='wkdir', timeout=300, logEnviron=False) + 0
+ ExpectShell.log('stdio', stdout="Switched to a new branch 'main'"),
)
self.expectOutcome(result=SUCCESS, state_string='Cleaned up git repository')
return self.runStep()

def test_success_wincairo(self):
self.setupStep(CleanGitRepo())
self.setProperty('buildername', 'WinCairo-EWS')
self.setProperty('platform', 'wincairo')

self.expectRemoteCommands(
ExpectShell(command=['cmd', '/c', 'git rebase --abort || exit 0'], workdir='wkdir', timeout=300, logEnviron=False) + 0
+ ExpectShell.log('stdio', stdout=''),
ExpectShell(command=['git', 'clean', '-f', '-d'], workdir='wkdir', timeout=300, logEnviron=False) + 0
+ ExpectShell.log('stdio', stdout=''),
@@ -4588,7 +4661,7 @@ def test_success_master(self):
self.setProperty('buildername', 'Commit-Queue')

self.expectRemoteCommands(
ExpectShell(command=['/bin/sh', '-c', 'git rebase --abort & true'], workdir='wkdir', timeout=300, logEnviron=False) + 0
ExpectShell(command=['/bin/sh', '-c', 'git rebase --abort || true'], workdir='wkdir', timeout=300, logEnviron=False) + 0
+ ExpectShell.log('stdio', stdout=''),
ExpectShell(command=['git', 'clean', '-f', '-d'], workdir='wkdir', timeout=300, logEnviron=False) + 0
+ ExpectShell.log('stdio', stdout=''),
@@ -4609,7 +4682,7 @@ def test_failure(self):
self.setProperty('buildername', 'Commit-Queue')

self.expectRemoteCommands(
ExpectShell(command=['/bin/sh', '-c', 'git rebase --abort & true'], workdir='wkdir', timeout=300, logEnviron=False) + 0
ExpectShell(command=['/bin/sh', '-c', 'git rebase --abort || true'], workdir='wkdir', timeout=300, logEnviron=False) + 0
+ ExpectShell.log('stdio', stdout=''),
ExpectShell(command=['git', 'clean', '-f', '-d'], workdir='wkdir', timeout=300, logEnviron=False) + 0
+ ExpectShell.log('stdio', stdout=''),
@@ -4631,7 +4704,7 @@ def test_branch(self):
self.setProperty('basename', 'safari-612-branch')

self.expectRemoteCommands(
ExpectShell(command=['/bin/sh', '-c', 'git rebase --abort & true'], workdir='wkdir', timeout=300, logEnviron=False) + 0
ExpectShell(command=['/bin/sh', '-c', 'git rebase --abort || true'], workdir='wkdir', timeout=300, logEnviron=False) + 0
+ ExpectShell.log('stdio', stdout=''),
ExpectShell(command=['git', 'clean', '-f', '-d'], workdir='wkdir', timeout=300, logEnviron=False) + 0
+ ExpectShell.log('stdio', stdout=''),
@@ -1,3 +1,21 @@
2022-02-14 Jonathan Bedard <jbedard@apple.com>

[EWS] Need /bin/sh equivalent on wincairo
https://bugs.webkit.org/show_bug.cgi?id=236608
<rdar://problem/88926062>

Reviewed by Don Olmstead.

* CISupport/ews-build/steps.py:
(ShellMixin.shell_command): Invoke provided command with
the system shell (either /bin/sh or cmd)
(ShellMixin.shell_exit_0): Trailing shell command ensuring
a 0 exit code regardless of the outcome of previous commands.
(ApplyPatch.start): Invoke command with cmd or /bin/sh/.
(CheckOutPullRequest.run): Ditto.
(CleanGitRepo.run): Ditto.
* CISupport/ews-build/steps_unittest.py:

2022-02-15 Angelos Oikonomopoulos <angelos@igalia.com>

[JSC] Speed up getStatusMap and increase robustness

0 comments on commit 6f12010

Please sign in to comment.