Diff
Modified: trunk/Tools/CISupport/ews-build/factories.py (294326 => 294327)
--- trunk/Tools/CISupport/ews-build/factories.py 2022-05-17 17:31:26 UTC (rev 294326)
+++ trunk/Tools/CISupport/ews-build/factories.py 2022-05-17 17:35:22 UTC (rev 294327)
@@ -24,10 +24,10 @@
from buildbot.process import factory
from buildbot.steps import trigger
-from steps import (AddAuthorToCommitMessage, AddReviewerToCommitMessage, ApplyPatch, ApplyWatchList, Canonicalize,
+from steps import (AddAuthorToCommitMessage, AddReviewerToCommitMessage, ApplyPatch, ApplyWatchList, Canonicalize, CommitPatch,
CheckOutPullRequest, CheckOutSource, CheckOutSpecificRevision, CheckChangeRelevance,
CheckPatchStatusOnEWSQueues, CheckStyle, CleanGitRepo, CompileJSC, CompileWebKit, ConfigureBuild, CreateLocalGITCommit,
- DownloadBuiltProduct, ExtractBuiltProduct, FetchBranches, FindModifiedChangeLogs, FindModifiedLayoutTests, GitSvnFetch,
+ DetermineAuthor, DownloadBuiltProduct, ExtractBuiltProduct, FetchBranches, FindModifiedChangeLogs, FindModifiedLayoutTests, GitSvnFetch,
InstallGtkDependencies, InstallWpeDependencies, KillOldProcesses, PrintConfiguration, PushCommitToWebKitRepo,
RunAPITests, RunBindingsTests, RunBuildWebKitOrgUnitTests, RunBuildbotCheckConfigForBuildWebKit, RunBuildbotCheckConfigForEWS,
RunEWSUnitTests, RunResultsdbpyTests, RunJavaScriptCoreTests, RunWebKit1Tests, RunWebKitPerlTests, RunWebKitPyPython2Tests,
@@ -292,15 +292,21 @@
self.addStep(ValidateChange(verifycqplus=True))
self.addStep(ValidateCommitterAndReviewer())
self.addStep(PrintConfiguration())
- self.addStep(CleanGitRepo(default_branch='master'))
- self.addStep(CheckOutSource(repourl='https://git.webkit.org/git/WebKit-https'))
+ self.addStep(CleanGitRepo())
+ self.addStep(CheckOutSource())
+ self.addStep(GitSvnFetch()) # FIXME: Remove when migrating to pure git
self.addStep(FetchBranches())
self.addStep(ShowIdentifier())
self.addStep(VerifyGitHubIntegrity())
self.addStep(UpdateWorkingDirectory())
- self.addStep(ApplyPatch())
- self.addStep(ValidateChangeLogAndReviewer())
- self.addStep(FindModifiedChangeLogs())
+ self.addStep(CommitPatch())
+
+ self.addStep(ValidateSquashed())
+ self.addStep(AddReviewerToCommitMessage())
+ self.addStep(DetermineAuthor())
+ self.addStep(AddAuthorToCommitMessage())
+ self.addStep(ValidateCommitMessage())
+
self.addStep(KillOldProcesses())
self.addStep(CompileWebKit(skipUpload=True))
self.addStep(KillOldProcesses())
@@ -308,11 +314,8 @@
self.addStep(CheckPatchStatusOnEWSQueues())
self.addStep(RunWebKitTests())
self.addStep(ValidateChange(addURLs=False, verifycqplus=True))
- self.addStep(CheckOutSource(repourl='https://git.webkit.org/git/WebKit-https'))
- self.addStep(ShowIdentifier())
- self.addStep(UpdateWorkingDirectory())
- self.addStep(ApplyPatch())
- self.addStep(CreateLocalGITCommit())
+
+ self.addStep(Canonicalize())
self.addStep(PushCommitToWebKitRepo())
self.addStep(SetBuildSummary())
@@ -334,6 +337,7 @@
self.addStep(CheckOutPullRequest())
self.addStep(ValidateSquashed())
self.addStep(AddReviewerToCommitMessage())
+ self.addStep(DetermineAuthor())
self.addStep(AddAuthorToCommitMessage())
self.addStep(ValidateCommitMessage())
Modified: trunk/Tools/CISupport/ews-build/factories_unittest.py (294326 => 294327)
--- trunk/Tools/CISupport/ews-build/factories_unittest.py 2022-05-17 17:31:26 UTC (rev 294326)
+++ trunk/Tools/CISupport/ews-build/factories_unittest.py 2022-05-17 17:35:22 UTC (rev 294327)
@@ -604,13 +604,17 @@
'configuration',
'clean-up-git-repo',
'clean-and-update-working-directory',
+ 'git-svn-fetch',
'fetch-branch-references',
'show-identifier',
'verify-github-integrity',
'update-working-directory',
- 'apply-patch',
- 'validate-changelog-and-reviewer',
- 'find-modified-changelogs',
+ 'commit-patch',
+ 'validate-squashed',
+ 'add-reviewer-to-commit-message',
+ 'determine-author',
+ 'add-author-to-commit-message',
+ 'validate-commit-message',
'kill-old-processes',
'compile-webkit',
'kill-old-processes',
@@ -618,11 +622,7 @@
'check-status-on-other-ewses',
'layout-tests',
'validate-change',
- 'clean-and-update-working-directory',
- 'show-identifier',
- 'update-working-directory',
- 'apply-patch',
- 'create-local-git-commit',
+ 'canonicalize-commit',
'push-commit-to-webkit-repo',
'set-build-summary'
],
@@ -641,6 +641,7 @@
'checkout-pull-request',
'validate-squashed',
'add-reviewer-to-commit-message',
+ 'determine-author',
'add-author-to-commit-message',
'validate-commit-message',
'kill-old-processes',
@@ -666,6 +667,7 @@
'checkout-pull-request',
'validate-squashed',
'add-reviewer-to-commit-message',
+ 'determine-author',
'add-author-to-commit-message',
'validate-commit-message',
'validate-change',
@@ -681,6 +683,7 @@
loadConfig.loadBuilderConfig(self.config, is_test_mode_enabled=True, master_prefix_path=cwd)
def test_all_expected_steps(self):
+ self.maxDiff = None
for builder in self.config['builders']:
buildSteps = []
for step in builder['factory'].steps:
Modified: trunk/Tools/CISupport/ews-build/steps.py (294326 => 294327)
--- trunk/Tools/CISupport/ews-build/steps.py 2022-05-17 17:31:26 UTC (rev 294326)
+++ trunk/Tools/CISupport/ews-build/steps.py 2022-05-17 17:35:22 UTC (rev 294327)
@@ -845,6 +845,63 @@
return rc
+class CommitPatch(steps.ShellSequence, CompositeStepMixin, ShellMixin):
+ name = 'commit-patch'
+ description = ['commit-patch']
+ descriptionDone = ['Created commit from patch']
+ haltOnFailure = True
+ env = dict(FILTER_BRANCH_SQUELCH_WARNING='1')
+ FILTER_BRANCH_PROGRAM = '''import re
+import sys
+
+lines = [l for l in sys.stdin]
+for s in re.split(r' (Need the bug URL \(OOPS!\).)|(\S+:\/\/\S+)', lines[0].rstrip()):
+ if s and s != ' ':
+ print(s)
+for l in lines[1:]:
+ sys.stdout.write(l)
+'''
+
+ def __init__(self, **kwargs):
+ super(CommitPatch, self).__init__(timeout=10 * 60, logEnviron=False, **kwargs)
+
+ def doStepIf(self, step):
+ return self.getProperty('patch_id', False)
+
+ def hideStepIf(self, results, step):
+ return not self.doStepIf(step) or (results == SUCCESS and self.getProperty('sensitive', False))
+
+ def _get_patch(self):
+ sourcestamp = self.build.getSourceStamp(self.getProperty('codebase', ''))
+ if not sourcestamp or not sourcestamp.patch:
+ return None
+ return sourcestamp.patch[1]
+
+ @defer.inlineCallbacks
+ def run(self):
+ self.commands = []
+ patch = self._get_patch()
+
+ commands = []
+ if not patch:
+ commands += [['curl', '-L', 'https://bugs.webkit.org/attachment.cgi?id={}'.format(self.getProperty('patch_id', '')), '-o', '.buildbot-diff']]
+ commands += [
+ ['git', 'am', '.buildbot-diff'],
+ ['git', 'filter-branch', '-f', '--msg-filter', 'python3 -c "{}"'.format(self.FILTER_BRANCH_PROGRAM), 'HEAD...HEAD~1'],
+ ]
+ for command in commands:
+ self.commands.append(util.ShellArg(command=command, logname='stdio', haltOnFailure=True))
+
+ _ = yield self.downloadFileContentToWorker('.buildbot-diff', patch)
+ res = yield super(CommitPatch, self).run()
+ return res
+
+ def getResultSummary(self):
+ if self.results != SUCCESS:
+ return {'step': 'git failed to apply patch to trunk'}
+ return super(CommitPatch, self).getResultSummary()
+
+
class CheckOutPullRequest(steps.ShellSequence, ShellMixin):
name = 'checkout-pull-request'
description = ['checking-out-pull-request']
@@ -4575,12 +4632,17 @@
])
else:
self.build.addStepsAfterCurrentStep([
- GitResetHard(),
- CheckOutSource(repourl='https://git.webkit.org/git/WebKit-https'),
+ ResetGitSvn(),
+ CleanGitRepo(),
+ CheckOutSource(),
+ GitSvnFetch(),
ShowIdentifier(),
UpdateWorkingDirectory(),
- ApplyPatch(),
- CreateLocalGITCommit(),
+ CommitPatch(),
+ AddReviewerToCommitMessage(),
+ AddAuthorToCommitMessage(),
+ ValidateChange(addURLs=False, verifycqplus=True),
+ Canonicalize(),
PushCommitToWebKitRepo(),
])
return rc
@@ -4761,8 +4823,8 @@
super(ValidateSquashed, self).__init__(logEnviron=False, **kwargs)
def start(self, BufferLogObserverClass=logobserver.BufferLogObserver):
- base_ref = self.getProperty('github.base.ref', DEFAULT_BRANCH)
- head_ref = self.getProperty('github.head.ref', DEFAULT_BRANCH)
+ base_ref = self.getProperty('github.base.ref', f'origin/{DEFAULT_BRANCH}')
+ head_ref = self.getProperty('github.head.ref', 'HEAD')
self.command = ['git', 'log', '--oneline', head_ref, f'^{base_ref}', '--max-count=2']
self.log_observer = BufferLogObserverClass(wantStderr=True)
@@ -4787,13 +4849,7 @@
return SUCCESS
return FAILURE
- def doStepIf(self, step):
- return self.getProperty('github.number')
- def hideStepIf(self, results, step):
- return not self.doStepIf(step)
-
-
class AddReviewerMixin(object):
NOBODY_SED = 's/NOBODY (OO*PP*S!*)/{}/g'
@@ -4830,8 +4886,8 @@
super(AddReviewerToCommitMessage, self).__init__(logEnviron=False, timeout=60, **kwargs)
def start(self, BufferLogObserverClass=logobserver.BufferLogObserver):
- base_ref = self.getProperty('github.base.ref', DEFAULT_BRANCH)
- head_ref = self.getProperty('github.head.ref', DEFAULT_BRANCH)
+ base_ref = self.getProperty('github.base.ref', f'origin/{DEFAULT_BRANCH}')
+ head_ref = self.getProperty('github.head.ref', 'HEAD')
gmtoffset = int(time.localtime().tm_gmtoff * 100 / (60 * 60))
date = f'{int(time.time())} {gmtoffset}'
@@ -4855,44 +4911,67 @@
return super(AddReviewerToCommitMessage, self).getResultSummary()
def doStepIf(self, step):
- return self.getProperty('github.number') and self.getProperty('reviewers_full_names')
+ return self.getProperty('reviewers_full_names')
def hideStepIf(self, results, step):
return not self.doStepIf(step)
-class AddAuthorToCommitMessage(shell.ShellCommand, AddReviewerMixin):
- name = 'add-author-to-commit-message'
+class DetermineAuthor(shell.ShellCommand, ShellMixin):
+ name = 'determine-author'
haltOnFailure = True
+ AUTHOR_RE = re.compile(r'Author:\s+(.+ <.+>)')
def __init__(self, **kwargs):
- super(AddAuthorToCommitMessage, self).__init__(logEnviron=False, timeout=60, **kwargs)
+ super(DetermineAuthor, self).__init__(logEnviron=False, timeout=60, **kwargs)
- def author(self):
- contributors, _ = Contributors.load()
- username = self.getProperty('github.head.user.login')
- owners = self.getProperty('owners', [None])
- for candidate in [username, owners[0]]:
- if not candidate:
- continue
+ def start(self, BufferLogObserverClass=logobserver.BufferLogObserver):
+ self.command = self.shell_command("git log -1 | grep '^Author:'")
- name = contributors.get(candidate.lower(), {}).get('name', None)
- email = contributors.get(candidate.lower(), {}).get('email', None)
+ self.log_observer = BufferLogObserverClass(wantStderr=True)
+ self.addLogObserver('stdio', self.log_observer)
- if name and email:
- return name, email
+ return super(DetermineAuthor, self).start()
- return None, None
+ def getResultSummary(self):
+ name = self.getProperty('author')
+ if not name or self.results == FAILURE:
+ return {'step': 'Failed to find author'}
+ elif self.results == SUCCESS:
+ return {'step': f"Author is {name}"}
+ return super(DetermineAuthor, self).getResultSummary()
+ def evaluateCommand(self, cmd):
+ rc = super(DetermineAuthor, self).evaluateCommand(cmd)
+ if rc != SUCCESS:
+ return rc
+
+ log_text = self.log_observer.getStdout()
+ lines = log_text.splitlines()
+ if len(lines) != 1:
+ return FAILURE
+ match = self.AUTHOR_RE.match(lines[0])
+ if match:
+ self.setProperty('author', match.group(1))
+ return SUCCESS
+ return FAILURE
+
+class AddAuthorToCommitMessage(shell.ShellCommand, AddReviewerMixin):
+ name = 'add-author-to-commit-message'
+ haltOnFailure = True
+
+ def __init__(self, **kwargs):
+ super(AddAuthorToCommitMessage, self).__init__(logEnviron=False, timeout=60, **kwargs)
+
def start(self):
- base_ref = self.getProperty('github.base.ref', DEFAULT_BRANCH)
- head_ref = self.getProperty('github.head.ref', DEFAULT_BRANCH)
+ base_ref = self.getProperty('github.base.ref', f'origin/{DEFAULT_BRANCH}')
+ head_ref = self.getProperty('github.head.ref', 'HEAD')
gmtoffset = int(time.localtime().tm_gmtoff * 100 / (60 * 60))
timestamp = f'{int(time.time())} {gmtoffset}'
- name, email = self.author()
- patch_by = f"Patch by {name} <{email}> on {date.today().strftime('%Y-%m-%d')}"
+ author = self.getProperty('author')
+ patch_by = f"Patch by {author} on {date.today().strftime('%Y-%m-%d')}"
self.command = [
'git', 'filter-branch', '-f',
@@ -4910,17 +4989,13 @@
if self.results == FAILURE:
return {'step': 'Failed to add author to commit message'}
elif self.results == SUCCESS:
- name, _ = self.author()
- return {'step': f"Added {name} as author"}
+ author = self.getProperty('author')
+ return {'step': f"Added {author} as author"}
return super(AddAuthorToCommitMessage, self).getResultSummary()
def doStepIf(self, step):
- if not self.getProperty('github.number'):
- return False
+ return self.getProperty('author')
- name, email = self.author()
- return name and email
-
def hideStepIf(self, results, step):
return not self.doStepIf(step)
@@ -4936,6 +5011,7 @@
'Rubber-stamped by',
'Rubber stamped by',
)
+ RE_CHANGELOG = br'^(\+\+\+)\s+(.*ChangeLog.*)'
def __init__(self, **kwargs):
super(ValidateCommitMessage, self).__init__(logEnviron=False, timeout=60, **kwargs)
@@ -4944,12 +5020,19 @@
sourcestamp = self.build.getSourceStamp(self.getProperty('codebase', ''))
if sourcestamp and sourcestamp.changes:
return sourcestamp.changes[0].files
+ if sourcestamp and sourcestamp.patch:
+ files = []
+ for line in sourcestamp.patch[1].splitlines():
+ match = re.search(self.RE_CHANGELOG, line)
+ if match:
+ files.append(match.group(1))
+ return files
return []
@defer.inlineCallbacks
def run(self, BufferLogObserverClass=logobserver.BufferLogObserver):
- base_ref = self.getProperty('github.base.ref', DEFAULT_BRANCH)
- head_ref = self.getProperty('github.head.ref', DEFAULT_BRANCH)
+ base_ref = self.getProperty('github.base.ref', f'origin/{DEFAULT_BRANCH}')
+ head_ref = self.getProperty('github.head.ref', 'HEAD')
self.commands = []
commands = [
@@ -4987,7 +5070,7 @@
if rc == FAILURE:
self.setProperty('comment_text', f"{self.summary}, blocking PR #{self.getProperty('github.number')}")
self.setProperty('build_finish_summary', 'Commit message validation failed')
- self.build.addStepsAfterCurrentStep([LeaveComment(), BlockPullRequest()])
+ self.build.addStepsAfterCurrentStep([LeaveComment(), SetCommitQueueMinusFlagOnPatch(), BlockPullRequest()])
return rc
def getResultSummary(self):
@@ -4995,13 +5078,7 @@
return {'step': self.summary}
return super(ValidateCommitMessage, self).getResultSummary()
- def doStepIf(self, step):
- return self.getProperty('github.number')
- def hideStepIf(self, results, step):
- return not self.doStepIf(step)
-
-
class Canonicalize(steps.ShellSequence, ShellMixin):
name = 'canonicalize-commit'
description = ['canonicalize-commit']
@@ -5016,15 +5093,14 @@
self.commands = []
base_ref = self.getProperty('github.base.ref', DEFAULT_BRANCH)
- head_ref = self.getProperty('github.head.ref', DEFAULT_BRANCH)
+ head_ref = self.getProperty('github.head.ref', None)
commands = []
if self.rebase_enabled:
- commands = [
- ['git', 'pull', 'origin', base_ref, '--rebase'],
- ['git', 'branch', '-f', base_ref, head_ref],
- ['git', 'checkout', base_ref],
- ]
+ commands = [['git', 'pull', 'origin', base_ref, '--rebase']]
+ if head_ref:
+ commands += [['git', 'branch', '-f', base_ref, head_ref]]
+ commands += [['git', 'checkout', base_ref]]
commands.append(['python3', 'Tools/Scripts/git-webkit', 'canonicalize', '-n', '1' if self.rebase_enabled else '3'])
for command in commands:
Modified: trunk/Tools/CISupport/ews-build/steps_unittest.py (294326 => 294327)
--- trunk/Tools/CISupport/ews-build/steps_unittest.py 2022-05-17 17:31:26 UTC (rev 294326)
+++ trunk/Tools/CISupport/ews-build/steps_unittest.py 2022-05-17 17:35:22 UTC (rev 294327)
@@ -45,9 +45,9 @@
from steps import (AddAuthorToCommitMessage, AddReviewerToCommitMessage, AnalyzeAPITestsResults, AnalyzeCompileWebKitResults,
AnalyzeJSCTestsResults, AnalyzeLayoutTestsResults, ApplyPatch, ApplyWatchList, ArchiveBuiltProduct, ArchiveTestResults, BugzillaMixin,
Canonicalize, CheckOutPullRequest, CheckOutSource, CheckOutSpecificRevision, CheckChangeRelevance, CheckPatchStatusOnEWSQueues, CheckStyle,
- CleanBuild, CleanUpGitIndexLock, CleanGitRepo, CleanWorkingDirectory, ClosePullRequest, CompileJSC, CompileJSCWithoutChange,
+ CleanBuild, CleanUpGitIndexLock, CleanGitRepo, CleanWorkingDirectory, ClosePullRequest, CompileJSC, CommitPatch, CompileJSCWithoutChange,
CompileWebKit, CompileWebKitWithoutChange, ConfigureBuild, ConfigureBuild, Contributors, CreateLocalGITCommit,
- DetermineLandedIdentifier, DownloadBuiltProduct, DownloadBuiltProductFromMaster, EWS_BUILD_HOSTNAME, ExtractBuiltProduct, ExtractTestResults,
+ DetermineAuthor, DetermineLandedIdentifier, DownloadBuiltProduct, DownloadBuiltProductFromMaster, EWS_BUILD_HOSTNAME, ExtractBuiltProduct, ExtractTestResults,
FetchBranches, FindModifiedChangeLogs, FindModifiedLayoutTests, GitHub, GitResetHard, GitSvnFetch,
InstallBuiltProduct, InstallGtkDependencies, InstallWpeDependencies,
KillOldProcesses, PrintConfiguration, PushCommitToWebKitRepo, PushPullRequestBranch, ReRunAPITests, ReRunWebKitPerlTests,
@@ -5827,10 +5827,18 @@
def tearDown(self):
return self.tearDownBuildStep()
- def test_skipped_patch(self):
+ def test_patch(self):
self.setupStep(ValidateSquashed())
self.setProperty('patch_id', '1234')
- self.expectOutcome(result=SKIPPED, state_string='finished (skipped)')
+ self.expectRemoteCommands(
+ ExpectShell(workdir='wkdir',
+ logEnviron=False,
+ command=['git', 'log', '--oneline', 'HEAD', '^origin/main', '--max-count=2'],
+ )
+ + 0
+ + ExpectShell.log('stdio', stdout='e1eb24603493 (HEAD -> eng/pull-request-branch) First line of commit\n'),
+ )
+ self.expectOutcome(result=SUCCESS, state_string='Verified branch is squashed')
return self.runStep()
def test_success(self):
@@ -5989,9 +5997,8 @@
def tearDown(self):
return self.tearDownBuildStep()
- def test_skipped_patch(self):
+ def test_skipped_no_author(self):
self.setupStep(AddAuthorToCommitMessage())
- self.setProperty('patch_id', '1234')
self.expectOutcome(result=SKIPPED, state_string='finished (skipped)')
return self.runStep()
@@ -6002,11 +6009,10 @@
time.time = lambda: fixed_time
self.setupStep(AddAuthorToCommitMessage())
- self.setProperty('github.number', '1234')
self.setProperty('github.base.ref', 'main')
self.setProperty('github.head.ref', 'eng/pull-request-branch')
- self.setProperty('github.head.user.login', 'webkit-reviewer')
self.setProperty('owners', ['webkit-commit-queue'])
+ self.setProperty('author', 'WebKit Reviewer <revie...@apple.com>')
self.expectRemoteCommands(
ExpectShell(workdir='wkdir',
logEnviron=False,
@@ -6021,10 +6027,10 @@
+ 0
+ ExpectShell.log('stdio', stdout="Ref 'refs/heads/eng/pull-request-branch' was rewritten\n"),
)
- self.expectOutcome(result=SUCCESS, state_string='Added WebKit Reviewer as author')
+ self.expectOutcome(result=SUCCESS, state_string='Added WebKit Reviewer <revie...@apple.com> as author')
return self.runStep()
- def test_success_fallback(self):
+ def test_success_patch(self):
gmtoffset = int(time.localtime().tm_gmtoff * 100 / (60 * 60))
fixed_time = int(time.time())
timestamp = f'{int(time.time())} {gmtoffset}'
@@ -6031,26 +6037,25 @@
time.time = lambda: fixed_time
self.setupStep(AddAuthorToCommitMessage())
- self.setProperty('github.number', '1234')
- self.setProperty('github.base.ref', 'main')
- self.setProperty('github.head.ref', 'eng/pull-request-branch')
- self.setProperty('github.head.user.login', 'unregistered-author')
- self.setProperty('owners', ['webkit-commit-queue'])
+ self.setProperty('author', 'WebKit Reviewer <revie...@apple.com>')
self.expectRemoteCommands(
ExpectShell(workdir='wkdir',
logEnviron=False,
- env=self.ENV,
- timeout=60,
+ env=dict(
+ GIT_COMMITTER_EMAIL='e...@webkit.org',
+ GIT_COMMITTER_NAME='EWS',
+ FILTER_BRANCH_SQUELCH_WARNING='1',
+ ), timeout=60,
command=[
'git', 'filter-branch', '-f',
'--env-filter', f"GIT_AUTHOR_DATE='{timestamp}';GIT_COMMITTER_DATE='{timestamp}'",
- '--msg-filter', f'sed "1,/^$/ s/^$/\\nPatch by WebKit Committer <commit...@webkit.org> on {date.today().strftime("%Y-%m-%d")}/g"',
- 'eng/pull-request-branch...main',
+ '--msg-filter', f'sed "1,/^$/ s/^$/\\nPatch by WebKit Reviewer <revie...@apple.com> on {date.today().strftime("%Y-%m-%d")}/g"',
+ 'HEAD...origin/main',
])
+ 0
- + ExpectShell.log('stdio', stdout="Ref 'refs/heads/eng/pull-request-branch' was rewritten\n"),
+ + ExpectShell.log('stdio', stdout="Ref 'main' was rewritten\n"),
)
- self.expectOutcome(result=SUCCESS, state_string='Added WebKit Committer as author')
+ self.expectOutcome(result=SUCCESS, state_string='Added WebKit Reviewer <revie...@apple.com> as author')
return self.runStep()
def test_failure(self):
@@ -6060,11 +6065,10 @@
time.time = lambda: fixed_time
self.setupStep(AddAuthorToCommitMessage())
- self.setProperty('github.number', '1234')
self.setProperty('github.base.ref', 'main')
self.setProperty('github.head.ref', 'eng/pull-request-branch')
- self.setProperty('github.head.user.login', 'webkit-commit-queue')
self.setProperty('owners', ['webkit-commit-queue'])
+ self.setProperty('author', 'WebKit Committer <commit...@webkit.org>')
self.expectRemoteCommands(
ExpectShell(workdir='wkdir',
logEnviron=False,
@@ -6082,14 +6086,7 @@
self.expectOutcome(result=FAILURE, state_string='Failed to add author to commit message')
return self.runStep()
- def test_no_owner(self):
- self.setupStep(AddAuthorToCommitMessage())
- self.setProperty('github.number', '1234')
- self.setProperty('github.base.ref', 'main')
- self.expectOutcome(result=SKIPPED, state_string='finished (skipped)')
- return self.runStep()
-
class TestValidateCommitMessage(BuildStepMixinAdditions, unittest.TestCase):
def setUp(self):
self.longMessage = True
@@ -6098,10 +6095,22 @@
def tearDown(self):
return self.tearDownBuildStep()
- def test_skipped_patch(self):
+ def test_patch(self):
self.setupStep(ValidateCommitMessage())
self.setProperty('patch_id', '1234')
- self.expectOutcome(result=SKIPPED, state_string='finished (skipped)')
+ self.expectRemoteCommands(
+ ExpectShell(workdir='wkdir',
+ logEnviron=False,
+ timeout=60,
+ command=['/bin/sh', '-c', "git log HEAD ^origin/main | grep -q 'OO*PP*S!' && echo 'Commit message contains (OOPS!)' || test $? -eq 1"])
+ + 0, ExpectShell(workdir='wkdir',
+ logEnviron=False,
+ timeout=60,
+ command=['/bin/sh', '-c', "git log HEAD ^origin/main | grep -q '\\(Reviewed by\\|Unreviewed\\|Rubber-stamped by\\|Rubber stamped by\\)' || echo 'No reviewer information in commit message'"])
+ + 0
+ + ExpectShell.log('stdio', stdout=''),
+ )
+ self.expectOutcome(result=SUCCESS, state_string='Validated commit message')
return self.runStep()
def test_success(self):
@@ -6616,5 +6625,44 @@
return self.runStep()
+class TestDetermineAuthor(BuildStepMixinAdditions, unittest.TestCase):
+ def setUp(self):
+ self.longMessage = True
+ return self.setUpBuildStep()
+
+ def tearDown(self):
+ return self.tearDownBuildStep()
+
+ def test_success(self):
+ self.setupStep(DetermineAuthor())
+ self.expectRemoteCommands(
+ ExpectShell(workdir='wkdir',
+ logEnviron=False,
+ timeout=60,
+ command=['/bin/sh', '-c', "git log -1 | grep '^Author:'"])
+ + 0
+ + ExpectShell.log('stdio', stdout='Author: WebKit Reviewer <revie...@apple.com>'),
+ )
+ self.expectOutcome(result=SUCCESS, state_string='Author is WebKit Reviewer <revie...@apple.com>')
+ rc = self.runStep()
+ self.assertEqual(self.getProperty('author'), 'WebKit Reviewer <revie...@apple.com>')
+ return rc
+
+ def test_failure(self):
+ self.setupStep(DetermineAuthor())
+ self.expectRemoteCommands(
+ ExpectShell(workdir='wkdir',
+ logEnviron=False,
+ timeout=60,
+ command=['/bin/sh', '-c', "git log -1 | grep '^Author:'"])
+ + 1
+ + ExpectShell.log('stdio', stdout=''),
+ )
+ self.expectOutcome(result=FAILURE, state_string='Failed to find author')
+ rc = self.runStep()
+ self.assertEqual(self.getProperty('author'), None)
+ return rc
+
+
if __name__ == '__main__':
unittest.main()