Modified: trunk/Tools/CISupport/ews-build/steps.py (289675 => 289676)
--- trunk/Tools/CISupport/ews-build/steps.py 2022-02-11 23:23:31 UTC (rev 289675)
+++ trunk/Tools/CISupport/ews-build/steps.py 2022-02-11 23:26:54 UTC (rev 289676)
@@ -355,7 +355,11 @@
else:
return {'step': 'Cleaned and updated working directory'}
+ def run(self):
+ self.branch = self.getProperty('github.base.ref', self.branch)
+ return super(CheckOutSource, self).run()
+
class CleanUpGitIndexLock(shell.ShellCommand):
name = 'clean-git-index-lock'
command = ['rm', '-f', '.git/index.lock']
@@ -399,7 +403,7 @@
super(CheckOutSpecificRevision, self).__init__(logEnviron=False, **kwargs)
def doStepIf(self, step):
- return self.getProperty('ews_revision', False)
+ return self.getProperty('ews_revision', False) and not self.getProperty('github.number', False)
def hideStepIf(self, results, step):
return not self.doStepIf(step)
@@ -450,7 +454,7 @@
revision = 'HEAD'
# Note that these properties are delibrately in priority order.
- for property_ in ['ews_revision', 'github.base.sha', 'got_revision']:
+ for property_ in ['ews_revision', 'got_revision']:
candidate = self.getProperty(property_)
if candidate:
revision = candidate
@@ -622,15 +626,23 @@
remote = self.getProperty('github.head.repo.full_name', 'origin').split('/')[0]
project = self.getProperty('github.head.repo.full_name', self.getProperty('project'))
- branch = self.getProperty('github.head.ref', 'main')
+ pr_branch = self.getProperty('github.head.ref', 'main')
+ base_hash = self.getProperty('github.base.sha')
+ rebase_target_hash = self.getProperty('ews_revision') or self.getProperty('got_revision')
- for command in [
+ commands = [
['/bin/sh', '-c', 'git remote add {} {}{}.git & true'.format(remote, GITHUB_URL, project)],
['git', 'remote', 'set-url', remote, '{}{}.git'.format(GITHUB_URL, project)],
['git', 'fetch', remote],
- ['git', 'branch', '-f', branch, 'remotes/{}/{}'.format(remote, branch)],
- ['git', 'checkout', branch],
- ]:
+ ['git', 'branch', '-f', pr_branch, 'remotes/{}/{}'.format(remote, pr_branch)],
+ ['git', 'checkout', pr_branch],
+ ]
+ if rebase_target_hash and base_hash and rebase_target_hash != base_hash:
+ commands += [
+ ['git', 'config', 'merge.changelog.driver', 'perl Tools/Scripts/resolve-ChangeLogs --merge-driver -c %O %A %B'],
+ ['git', 'rebase', '--onto', rebase_target_hash, base_hash, pr_branch],
+ ]
+ for command in commands:
self.commands.append(util.ShellArg(command=command, logname='stdio', haltOnFailure=True))
return super(CheckOutPullRequest, self).run()
@@ -639,7 +651,7 @@
if self.results == SKIPPED:
return {'step': 'No pull request to checkout'}
if self.results != SUCCESS:
- return {'step': 'Failed to checkout branch from PR {}'.format(self.getProperty('github.number'))}
+ return {'step': 'Failed to checkout and rebase branch from PR {}'.format(self.getProperty('github.number'))}
return super(CheckOutPullRequest, self).getResultSummary()
@@ -1482,7 +1494,7 @@
self.commands = []
for command in [
['git', 'clean', '-f', '-d'],
- ['git', 'checkout', self.getProperty('github.base.sha')],
+ ['git', 'checkout', self.getProperty('ews_revision') or self.getProperty('got_revision')],
]:
self.commands.append(util.ShellArg(command=command, logname='stdio'))
return super(RevertPullRequestChanges, self).run()
@@ -1512,7 +1524,7 @@
property_names += ['patch_id', 'bug_id', 'owner']
if pull_request:
property_names += [
- 'github.base.sha', 'github.head.ref', 'github.head.sha',
+ 'github.base.ref', 'github.base.sha', 'github.head.ref', 'github.head.sha',
'github.head.repo.full_name', 'github.number', 'github.title',
'repository', 'project', 'owners',
]
@@ -1521,7 +1533,7 @@
properties_to_pass = {prop: properties.Property(prop) for prop in property_names}
properties_to_pass['retry_count'] = properties.Property('retry_count', default=0)
- if self.include_revision and patch:
+ if self.include_revision:
properties_to_pass['ews_revision'] = properties.Property('got_revision')
return properties_to_pass
@@ -3896,6 +3908,7 @@
branch = self.getProperty('basename', self.default_branch)
self.commands = []
for command in [
+ ['git', 'rebase', '--abort'],
['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
Modified: trunk/Tools/CISupport/ews-build/steps_unittest.py (289675 => 289676)
--- trunk/Tools/CISupport/ews-build/steps_unittest.py 2022-02-11 23:23:31 UTC (rev 289675)
+++ trunk/Tools/CISupport/ews-build/steps_unittest.py 2022-02-11 23:26:54 UTC (rev 289676)
@@ -2924,7 +2924,15 @@
self.expectOutcome(result=SKIPPED, state_string='Checked out required revision (skipped)')
return self.runStep()
+ def test_skip_pr(self):
+ self.setupStep(CheckOutSpecificRevision())
+ self.setProperty('github.number', '1234')
+ self.setProperty('ews_revision', '1a3425cb92dbcbca12a10aa9514f1b77c76dc26')
+ self.expectHidden(True)
+ self.expectOutcome(result=SKIPPED, state_string='Checked out required revision (skipped)')
+ return self.runStep()
+
class TestCleanWorkingDirectory(BuildStepMixinAdditions, unittest.TestCase):
def setUp(self):
self.longMessage = True
@@ -3079,6 +3087,8 @@
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(
@@ -3107,6 +3117,16 @@
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')
@@ -3117,6 +3137,8 @@
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(
@@ -3137,7 +3159,7 @@
command=['git', 'fetch', 'Contributor'],
) + 1,
)
- self.expectOutcome(result=FAILURE, state_string='Failed to checkout branch from PR 1234')
+ self.expectOutcome(result=FAILURE, state_string='Failed to checkout and rebase branch from PR 1234')
return self.runStep()
def test_skipped(self):
@@ -3201,7 +3223,7 @@
def test_success(self):
self.setupStep(RevertPullRequestChanges())
- self.setProperty('github.base.sha', 'b2db8d1da7b74b5ddf075e301370e64d914eef7c')
+ self.setProperty('got_revision', 'b2db8d1da7b74b5ddf075e301370e64d914eef7c')
self.setProperty('github.number', 1234)
self.expectHidden(False)
self.expectRemoteCommands(
@@ -3222,7 +3244,7 @@
def test_failure(self):
self.setupStep(RevertPullRequestChanges())
- self.setProperty('github.base.sha', 'b2db8d1da7b74b5ddf075e301370e64d914eef7c')
+ self.setProperty('ews_revision', 'b2db8d1da7b74b5ddf075e301370e64d914eef7c')
self.setProperty('github.number', 1234)
self.expectHidden(False)
self.expectRemoteCommands(
@@ -4535,6 +4557,8 @@
self.setProperty('buildername', 'Style-EWS')
self.expectRemoteCommands(
+ ExpectShell(command=['git', 'rebase', '--abort'], 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
@@ -4554,6 +4578,8 @@
self.setProperty('buildername', 'Commit-Queue')
self.expectRemoteCommands(
+ ExpectShell(command=['git', 'rebase', '--abort'], 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
@@ -4573,6 +4599,8 @@
self.setProperty('buildername', 'Commit-Queue')
self.expectRemoteCommands(
+ ExpectShell(command=['git', 'rebase', '--abort'], 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) + 128
@@ -4593,6 +4621,8 @@
self.setProperty('basename', 'safari-612-branch')
self.expectRemoteCommands(
+ ExpectShell(command=['git', 'rebase', '--abort'], 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
@@ -5063,7 +5093,7 @@
def test_success_pull_request(self):
self.setupStep(ShowIdentifier())
- self.setProperty('github.base.sha', '51a6aec9f664')
+ self.setProperty('got_revision', '51a6aec9f664')
self.expectRemoteCommands(
ExpectShell(workdir='wkdir',
timeout=300,
@@ -5080,7 +5110,7 @@
def test_prioritized(self):
self.setupStep(ShowIdentifier())
self.setProperty('ews_revision', '51a6aec9f664')
- self.setProperty('github.base.sha', '9f66451a6aec')
+ self.setProperty('got_revision', '9f66451a6aec')
self.expectRemoteCommands(
ExpectShell(workdir='wkdir',
timeout=300,