Title: [292576] trunk/Tools
Revision
292576
Author
[email protected]
Date
2022-04-07 15:59:01 -0700 (Thu, 07 Apr 2022)

Log Message

[Merge-Queue] Add PushCommitToWebKitRepo
https://bugs.webkit.org/show_bug.cgi?id=238959
<rdar://problem/91443987>

Reviewed by Aakash Jain.

* Tools/CISupport/ews-build/factories.py:
(MergeQueueFactory.__init__): Add PushCommitToWebKitRepo, pre-commit validation.
* Tools/CISupport/ews-build/factories_unittest.py:
(TestExpectedBuildSteps): Ditto.
* Tools/CISupport/ews-build/steps.py:
(PushCommitToWebKitRepo.evaluateCommand): Add merge-queue steps.
(PushCommitToWebKitRepo.getResultSummary): Remove identifier computation.
(PushCommitToWebKitRepo.svn_revision_from_commit_text):
(DetermineLandedIdentifier): Move code to determine identifier into a seperate step because
merge-queue has already computed the identifier.
(DetermineLandedIdentifier.__init__):
(DetermineLandedIdentifier.start): Capture log output of command.
(DetermineLandedIdentifier.getResultSummary):
(DetermineLandedIdentifier.evaluateCommand): Attempt to pull identifier from commit message,
otherwise, fall back to commits.webkit.org.
(DetermineLandedIdentifier.url_for_revision_details): Moved from PushCommitToWebKitRepo.
(DetermineLandedIdentifier.url_for_identifier): Ditto.
(DetermineLandedIdentifier.identifier_for_revision): Ditto.
(DetermineLandedIdentifier.comment_text_for_bug): Ditto.
* Tools/CISupport/ews-build/steps_unittest.py:

Canonical link: https://commits.webkit.org/249414@main

Modified Paths

Diff

Modified: trunk/Tools/CISupport/ews-build/factories.py (292575 => 292576)


--- trunk/Tools/CISupport/ews-build/factories.py	2022-04-07 22:56:25 UTC (rev 292575)
+++ trunk/Tools/CISupport/ews-build/factories.py	2022-04-07 22:59:01 UTC (rev 292576)
@@ -28,11 +28,11 @@
                    CheckOutPullRequest, CheckOutSource, CheckOutSpecificRevision, CheckChangeRelevance,
                    CheckPatchStatusOnEWSQueues, CheckStyle, CleanGitRepo, CompileJSC, CompileWebKit, ConfigureBuild, CreateLocalGITCommit,
                    DownloadBuiltProduct, ExtractBuiltProduct, FetchBranches, FindModifiedChangeLogs, FindModifiedLayoutTests, GitSvnFetch,
-                   InstallGtkDependencies, InstallWpeDependencies, KillOldProcesses, PrintConfiguration, PushCommitToWebKitRepo, PushPullRequestBranch,
+                   InstallGtkDependencies, InstallWpeDependencies, KillOldProcesses, PrintConfiguration, PushCommitToWebKitRepo,
                    RunAPITests, RunBindingsTests, RunBuildWebKitOrgUnitTests, RunBuildbotCheckConfigForBuildWebKit, RunBuildbotCheckConfigForEWS,
                    RunEWSUnitTests, RunResultsdbpyTests, RunJavaScriptCoreTests, RunWebKit1Tests, RunWebKitPerlTests, RunWebKitPyPython2Tests,
                    RunWebKitPyPython3Tests, RunWebKitTests, RunWebKitTestsRedTree, RunWebKitTestsInStressMode, RunWebKitTestsInStressGuardmallocMode,
-                   SetBuildSummary, ShowIdentifier, TriggerCrashLogSubmission, UpdatePullRequest, UpdateWorkingDirectory,
+                   SetBuildSummary, ShowIdentifier, TriggerCrashLogSubmission, UpdateWorkingDirectory,
                    ValidateCommitMessage, ValidateChange, ValidateChangeLogAndReviewer, ValidateCommitterAndReviewer, WaitForCrashCollection,
                    InstallBuiltProduct, VerifyGitHubIntegrity, ValidateSquashed)
 
@@ -338,6 +338,7 @@
         self.addStep(AddReviewerToChangeLog())
         self.addStep(ValidateCommitMessage())
         self.addStep(ValidateChangeLogAndReviewer())
+        self.addStep(ValidateChange(verifyMergeQueue=True, verifyNoDraftForMergeQueue=True))
         self.addStep(Canonicalize())
-        self.addStep(PushPullRequestBranch())
-        self.addStep(UpdatePullRequest())
+        self.addStep(PushCommitToWebKitRepo())
+        self.addStep(SetBuildSummary())

Modified: trunk/Tools/CISupport/ews-build/factories_unittest.py (292575 => 292576)


--- trunk/Tools/CISupport/ews-build/factories_unittest.py	2022-04-07 22:56:25 UTC (rev 292575)
+++ trunk/Tools/CISupport/ews-build/factories_unittest.py	2022-04-07 22:59:01 UTC (rev 292576)
@@ -645,9 +645,10 @@
             'add-reviewer-to-changelog',
             'validate-commit-message',
             'validate-changelog-and-reviewer',
+            'validate-change',
             'canonicalize-commit',
-            'push-pull-request-branch',
-            'update-pull-request',
+            'push-commit-to-webkit-repo',
+            'set-build-summary'
         ],
     }
 

Modified: trunk/Tools/CISupport/ews-build/steps.py (292575 => 292576)


--- trunk/Tools/CISupport/ews-build/steps.py	2022-04-07 22:56:25 UTC (rev 292575)
+++ trunk/Tools/CISupport/ews-build/steps.py	2022-04-07 22:59:01 UTC (rev 292576)
@@ -4497,28 +4497,130 @@
     def evaluateCommand(self, cmd):
         rc = shell.ShellCommand.evaluateCommand(self, cmd)
         if rc == SUCCESS:
-            time.sleep(60)  # It takes time for commits.webkit.org to digest commits
             log_text = self.log_observer.getStdout() + self.log_observer.getStderr()
             svn_revision = self.svn_revision_from_commit_text(log_text)
-            identifier = self.identifier_for_revision(svn_revision)
-            self.setProperty('comment_text', self.comment_text_for_bug(svn_revision, identifier))
-            commit_summary = 'Committed {}'.format(identifier)
-            self.descriptionDone = commit_summary
-            self.setProperty('build_summary', commit_summary)
-            self.build.addStepsAfterCurrentStep([LeaveComment(), RemoveFlagsOnPatch(), CloseBug()])
-            self.addURL(identifier, self.url_for_identifier(identifier))
+            if svn_revision:
+                self.setProperty('svn_revision', svn_revision)
+
+            steps_to_add = []
+            if self.getProperty('github.number', ''):
+                steps_to_add += [
+                    Canonicalize(rebase_enabled=False),
+                    PushPullRequestBranch(),
+                    UpdatePullRequest(),
+                    GitSvnFetch(),
+                ]
+            steps_to_add += [
+                DetermineLandedIdentifier(),
+                LeaveComment(),
+                RemoveFlagsOnPatch(), RemoveLabelsFromPullRequest(),
+                CloseBug(), ClosePullRequest(),
+            ]
+            self.build.addStepsAfterCurrentStep(steps_to_add)
+
         else:
             retry_count = int(self.getProperty('retry_count', 0))
             if retry_count < self.MAX_RETRY:
                 self.setProperty('retry_count', retry_count + 1)
-                self.build.addStepsAfterCurrentStep([GitResetHard(), CheckOutSource(repourl='https://git.webkit.org/git/WebKit-https'), ShowIdentifier(), UpdateWorkingDirectory(), ApplyPatch(), CreateLocalGITCommit(), PushCommitToWebKitRepo()])
+                if self.getProperty('github.number', ''):
+                    self.build.addStepsAfterCurrentStep([
+                        CleanGitRepo(),
+                        CheckOutSource(),
+                        GitSvnFetch(),
+                        ShowIdentifier(),
+                        UpdateWorkingDirectory(),
+                        CheckOutPullRequest(),
+                        AddReviewerToCommitMessage(),
+                        AddAuthorToCommitMessage(),
+                        AddReviewerToChangeLog(),
+                        ValidateChange(verifyMergeQueue=True, verifyNoDraftForMergeQueue=True),
+                        Canonicalize(),
+                        PushCommitToWebKitRepo(),
+                    ])
+                else:
+                    self.build.addStepsAfterCurrentStep([
+                        GitResetHard(),
+                        CheckOutSource(repourl='https://git.webkit.org/git/WebKit-https'),
+                        ShowIdentifier(),
+                        UpdateWorkingDirectory(),
+                        ApplyPatch(),
+                        CreateLocalGITCommit(),
+                        PushCommitToWebKitRepo(),
+                    ])
                 return rc
 
-            self.setProperty('comment_text', self.comment_text_for_bug())
+            if self.getProperty('github.number', ''):
+                self.setProperty('comment_text', 'merge-queue failed to commit PR to repository. To retry, remove any blocking labels and re-apply merge-queue label')
+            else:
+                patch_id = self.getProperty('patch_id', '')
+                self.setProperty('comment_text', f'commit-queue failed to commit attachment {patch_id} to WebKit repository. To retry, please set cq+ flag again.')
+
             self.setProperty('build_finish_summary', 'Failed to commit to WebKit repository')
-            self.build.addStepsAfterCurrentStep([LeaveComment(), SetCommitQueueMinusFlagOnPatch()])
+            self.build.addStepsAfterCurrentStep([LeaveComment(), SetCommitQueueMinusFlagOnPatch(), BlockPullRequest()])
         return rc
 
+    def getResultSummary(self):
+        if self.results != SUCCESS:
+            return {'step': 'Failed to push commit to Webkit repository'}
+        return shell.ShellCommand.getResultSummary(self)
+
+    def doStepIf(self, step):
+        return CURRENT_HOSTNAME == EWS_BUILD_HOSTNAME
+
+    def svn_revision_from_commit_text(self, commit_text):
+        match = re.search(self.commit_success_regexp, commit_text, re.MULTILINE)
+        return match.group('svn_revision')
+
+
+class DetermineLandedIdentifier(shell.ShellCommand):
+    name = 'determine-landed-identifier'
+    descriptionDone = ['Determined landed identifier']
+    command = ['git', 'log', '-1', '--no-decorate']
+    CANONICAL_LINK_RE = re.compile(r'\ACanonical link: https://commits\.webkit\.org/(?P<identifier>\d+.?\d*@\S+)\Z')
+    haltOnFailure = False
+
+    def __init__(self, **kwargs):
+        self.identifier = None
+        super(DetermineLandedIdentifier, self).__init__(logEnviron=False, timeout=300, **kwargs)
+
+    def start(self, BufferLogObserverClass=logobserver.BufferLogObserver):
+        self.log_observer = BufferLogObserverClass(wantStderr=True)
+        self.addLogObserver('stdio', self.log_observer)
+        return super(DetermineLandedIdentifier, self).start()
+
+    def getResultSummary(self):
+        if self.results == SUCCESS:
+            return {'step': f'Identifier: {self.identifier}'}
+        if self.results == FAILURE:
+            return {'step': 'Failed to determine identifier'}
+        return super(DetermineLandedIdentifier, self).getResultSummary()
+
+    def evaluateCommand(self, cmd):
+        rc = super(DetermineLandedIdentifier, self).evaluateCommand(cmd)
+
+        loglines = self.log_observer.getStdout().splitlines()
+
+        for line in loglines[4:]:
+            match = self.CANONICAL_LINK_RE.match(line[4:])
+            if match:
+                self.identifier = match.group('identifier')
+                break
+
+        svn_revision = self.getProperty('svn_revision')
+        if not self.identifier:
+            time.sleep(60)  # It takes time for commits.webkit.org to digest commits
+            self.identifier = self.identifier_for_revision(svn_revision)
+            if '@' not in self.identifier:
+                rc = FAILURE
+
+        self.setProperty('comment_text', self.comment_text_for_bug(svn_revision, self.identifier))
+        commit_summary = f'Committed {self.identifier or svn_revision}'
+        self.descriptionDone = commit_summary
+        self.setProperty('build_summary', commit_summary)
+        self.addURL(self.identifier, self.url_for_identifier(self.identifier))
+
+        return rc
+
     def url_for_revision_details(self, revision):
         return '{}r{}/json'.format(COMMITS_INFO_URL, revision)
 
@@ -4538,30 +4640,18 @@
         return 'r{}'.format(revision)
 
     def comment_text_for_bug(self, svn_revision=None, identifier=None):
-        patch_id = self.getProperty('patch_id', '')
-        if not svn_revision:
-            comment = 'commit-queue failed to commit attachment {} to WebKit repository.'.format(patch_id)
-            comment += ' To retry, please set cq+ flag again.'
-            return comment
-
         identifier_str = identifier if identifier and '@' in identifier else '?'
         comment = 'Committed r{} ({}): <{}>'.format(svn_revision, identifier_str, self.url_for_identifier(identifier))
-        comment += '\n\nAll reviewed patches have been landed. Closing bug and clearing flags on attachment {}.'.format(patch_id)
+
+        patch_id = self.getProperty('patch_id', '')
+        if patch_id:
+            comment += f'\n\nAll reviewed patches have been landed. Closing bug and clearing flags on attachment {patch_id}.'
+        pr_number = self.getProperty('github.number', '')
+        if pr_number:
+            comment += f'\n\nReviewed commits have been landed. Closing PR #{pr_number} and removing active labels.'
         return comment
 
-    def svn_revision_from_commit_text(self, commit_text):
-        match = re.search(self.commit_success_regexp, commit_text, re.MULTILINE)
-        return match.group('svn_revision')
 
-    def getResultSummary(self):
-        if self.results != SUCCESS:
-            return {'step': 'Failed to push commit to Webkit repository'}
-        return shell.ShellCommand.getResultSummary(self)
-
-    def doStepIf(self, step):
-        return CURRENT_HOSTNAME == EWS_BUILD_HOSTNAME
-
-
 class CheckPatchStatusOnEWSQueues(buildstep.BuildStep, BugzillaMixin):
     name = 'check-status-on-other-ewses'
     descriptionDone = ['Checked patch status on other queues']

Modified: trunk/Tools/CISupport/ews-build/steps_unittest.py (292575 => 292576)


--- trunk/Tools/CISupport/ews-build/steps_unittest.py	2022-04-07 22:56:25 UTC (rev 292575)
+++ trunk/Tools/CISupport/ews-build/steps_unittest.py	2022-04-07 22:59:01 UTC (rev 292576)
@@ -47,7 +47,7 @@
                    Canonicalize, CheckOutPullRequest, CheckOutSource, CheckOutSpecificRevision, CheckChangeRelevance, CheckPatchStatusOnEWSQueues, CheckStyle,
                    CleanBuild, CleanUpGitIndexLock, CleanGitRepo, CleanWorkingDirectory, ClosePullRequest, CompileJSC, CompileJSCWithoutChange,
                    CompileWebKit, CompileWebKitWithoutChange, ConfigureBuild, ConfigureBuild, Contributors, CreateLocalGITCommit,
-                   DownloadBuiltProduct, DownloadBuiltProductFromMaster, EWS_BUILD_HOSTNAME, ExtractBuiltProduct, ExtractTestResults,
+                   DetermineLandedIdentifier, DownloadBuiltProduct, DownloadBuiltProductFromMaster, EWS_BUILD_HOSTNAME, ExtractBuiltProduct, ExtractTestResults,
                    FetchBranches, FindModifiedChangeLogs, FindModifiedLayoutTests, GitHub, GitResetHard, GitSvnFetch,
                    InstallBuiltProduct, InstallGtkDependencies, InstallWpeDependencies,
                    KillOldProcesses, PrintConfiguration, PushCommitToWebKitRepo, PushPullRequestBranch, ReRunAPITests, ReRunWebKitPerlTests,
@@ -5325,6 +5325,88 @@
     def tearDown(self):
         return self.tearDownBuildStep()
 
+    def test_success(self):
+        self.setupStep(PushCommitToWebKitRepo())
+        self.setProperty('patch_id', '1234')
+        self.expectRemoteCommands(
+            ExpectShell(workdir='wkdir',
+                        timeout=300,
+                        logEnviron=False,
+                        command=['git', 'svn', 'dcommit', '--rmdir']) +
+            ExpectShell.log('stdio', stdout='Committed r256729') +
+            0,
+        )
+        self.expectOutcome(result=SUCCESS, state_string='')
+        with current_hostname(EWS_BUILD_HOSTNAME):
+            rc = self.runStep()
+        self.assertEqual(self.getProperty('svn_revision'), '256729')
+        return rc
+
+    def test_failure_retry(self):
+        self.setupStep(PushCommitToWebKitRepo())
+        self.setProperty('patch_id', '2345')
+        self.expectRemoteCommands(
+            ExpectShell(workdir='wkdir',
+                        timeout=300,
+                        logEnviron=False,
+                        command=['git', 'svn', 'dcommit', '--rmdir']) +
+            ExpectShell.log('stdio', stdout='Unexpected failure') +
+            2,
+        )
+        self.expectOutcome(result=FAILURE, state_string='Failed to push commit to Webkit repository')
+        with current_hostname(EWS_BUILD_HOSTNAME):
+            rc = self.runStep()
+        self.assertEqual(self.getProperty('retry_count'), 1)
+        self.assertEqual(self.getProperty('svn_revision'), None)
+        return rc
+
+    def test_failure_patch(self):
+        self.setupStep(PushCommitToWebKitRepo())
+        self.setProperty('retry_count', PushCommitToWebKitRepo.MAX_RETRY)
+        self.setProperty('patch_id', '2345')
+        self.expectRemoteCommands(
+            ExpectShell(workdir='wkdir',
+                        timeout=300,
+                        logEnviron=False,
+                        command=['git', 'svn', 'dcommit', '--rmdir']) +
+            ExpectShell.log('stdio', stdout='Unexpected failure') +
+            2,
+        )
+        self.expectOutcome(result=FAILURE, state_string='Failed to push commit to Webkit repository')
+        with current_hostname(EWS_BUILD_HOSTNAME):
+            rc = self.runStep()
+        self.assertEqual(self.getProperty('build_finish_summary'), 'Failed to commit to WebKit repository')
+        self.assertEqual(self.getProperty('comment_text'), 'commit-queue failed to commit attachment 2345 to WebKit repository. To retry, please set cq+ flag again.')
+        return rc
+
+    def test_failure_pr(self):
+        self.setupStep(PushCommitToWebKitRepo())
+        self.setProperty('retry_count', PushCommitToWebKitRepo.MAX_RETRY)
+        self.setProperty('github.number', '1234')
+        self.expectRemoteCommands(
+            ExpectShell(workdir='wkdir',
+                        timeout=300,
+                        logEnviron=False,
+                        command=['git', 'svn', 'dcommit', '--rmdir']) +
+            ExpectShell.log('stdio', stdout='Unexpected failure') +
+            2,
+        )
+        self.expectOutcome(result=FAILURE, state_string='Failed to push commit to Webkit repository')
+        with current_hostname(EWS_BUILD_HOSTNAME):
+            rc = self.runStep()
+        self.assertEqual(self.getProperty('build_finish_summary'), 'Failed to commit to WebKit repository')
+        self.assertEqual(self.getProperty('comment_text'), 'merge-queue failed to commit PR to repository. To retry, remove any blocking labels and re-apply merge-queue label')
+        return rc
+
+
+class TestDetermineLandedIdentifier(BuildStepMixinAdditions, unittest.TestCase):
+    def setUp(self):
+        self.longMessage = True
+        return self.setUpBuildStep()
+
+    def tearDown(self):
+        return self.tearDownBuildStep()
+
     def mock_commits_webkit_org(self, identifier=None):
         class Response(object):
             def __init__(self, data="" status_code=200):
@@ -5347,87 +5429,127 @@
     def mock_sleep(cls):
         return patch('time.sleep', lambda _: None)
 
+    def test_success_pr(self):
+        with self.mock_commits_webkit_org(), self.mock_sleep():
+            self.setupStep(DetermineLandedIdentifier())
+            self.setProperty('svn_revision', '256729')
+            self.setProperty('github.number', '1234')
+            self.expectRemoteCommands(
+            ExpectShell(workdir='wkdir',
+                        timeout=300,
+                        logEnviron=False,
+                        command=['git', 'log', '-1', '--no-decorate']) +
+                ExpectShell.log('stdio', stdout=''''commit 220797@main (14dbf1155cf56a1dd4d86a847e61af3c3e5d2ca5, r256729)
+Author: Aakash Jain <[email protected]>
+Date:   Mon Feb 17 15:09:42 2020 +0000
 
-    def test_success(self):
+    [ews] add SetBuildSummary step for Windows EWS
+    https://bugs.webkit.org/show_bug.cgi?id=207556
+    
+    Reviewed by Jonathan Bedard.
+    
+    * BuildSlaveSupport/ews-build/factories.py:
+    (WindowsFactory.__init__):
+    (GTKBuildAndTestFactory.__init__):
+    * BuildSlaveSupport/ews-build/factories_unittest.py:
+    (TestBuildAndTestsFactory.test_windows_factory): Added unit-test.
+    
+    
+    Canonical link: https://commits.webkit.org/220797@main
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@256729 268f45cc-cd09-0410-ab3c-d52691b4dbfc''') +
+                0,
+            )
+            self.expectOutcome(result=SUCCESS, state_string='Identifier: 220797@main')
+            with current_hostname(EWS_BUILD_HOSTNAME):
+                rc = self.runStep()
+
+        self.assertEqual(self.getProperty('comment_text'), 'Committed r256729 (220797@main): <https://commits.webkit.org/220797@main>\n\nReviewed commits have been landed. Closing PR #1234 and removing active labels.')
+        self.assertEqual(self.getProperty('build_summary'), 'Committed 220797@main')
+        return rc
+
+    def test_success_pr_fallback(self):
         with self.mock_commits_webkit_org(identifier='220797@main'), self.mock_sleep():
-            self.setupStep(PushCommitToWebKitRepo())
-            self.setProperty('patch_id', '1234')
+            self.setupStep(DetermineLandedIdentifier())
+            self.setProperty('svn_revision', '256729')
+            self.setProperty('github.number', '1234')
             self.expectRemoteCommands(
-                ExpectShell(workdir='wkdir',
-                            timeout=300,
-                            logEnviron=False,
-                            command=['git', 'svn', 'dcommit', '--rmdir']) +
-                ExpectShell.log('stdio', stdout='Committed r256729') +
+            ExpectShell(workdir='wkdir',
+                        timeout=300,
+                        logEnviron=False,
+                        command=['git', 'log', '-1', '--no-decorate']) +
+                ExpectShell.log('stdio', stdout='') +
                 0,
             )
-            self.expectOutcome(result=SUCCESS, state_string='Committed 220797@main')
+            self.expectOutcome(result=SUCCESS, state_string='Identifier: 220797@main')
             with current_hostname(EWS_BUILD_HOSTNAME):
                 rc = self.runStep()
-            self.assertEqual(self.getProperty('comment_text'), 'Committed r256729 (220797@main): <https://commits.webkit.org/220797@main>\n\nAll reviewed patches have been landed. Closing bug and clearing flags on attachment 1234.')
-            self.assertEqual(self.getProperty('build_finish_summary'), None)
-            self.assertEqual(self.getProperty('build_summary'), 'Committed 220797@main')
-            return rc
 
-    def test_success_no_identifier(self):
+        self.assertEqual(self.getProperty('comment_text'), 'Committed r256729 (220797@main): <https://commits.webkit.org/220797@main>\n\nReviewed commits have been landed. Closing PR #1234 and removing active labels.')
+        self.assertEqual(self.getProperty('build_summary'), 'Committed 220797@main')
+        return rc
+
+    def test_pr_no_identifier(self):
         with self.mock_commits_webkit_org(), self.mock_sleep():
-            self.setupStep(PushCommitToWebKitRepo())
-            self.setProperty('patch_id', '1234')
+            self.setupStep(DetermineLandedIdentifier())
+            self.setProperty('svn_revision', '256729')
+            self.setProperty('github.number', '1234')
             self.expectRemoteCommands(
-                ExpectShell(workdir='wkdir',
-                            timeout=300,
-                            logEnviron=False,
-                            command=['git', 'svn', 'dcommit', '--rmdir']) +
-                ExpectShell.log('stdio', stdout='Committed r256729') +
+            ExpectShell(workdir='wkdir',
+                        timeout=300,
+                        logEnviron=False,
+                        command=['git', 'log', '-1', '--no-decorate']) +
+                ExpectShell.log('stdio', stdout='') +
                 0,
             )
-            self.expectOutcome(result=SUCCESS, state_string='Committed r256729')
+            self.expectOutcome(result=FAILURE, state_string='Failed to determine identifier')
             with current_hostname(EWS_BUILD_HOSTNAME):
                 rc = self.runStep()
-            self.assertEqual(self.getProperty('comment_text'), 'Committed r256729 (?): <https://commits.webkit.org/r256729>\n\nAll reviewed patches have been landed. Closing bug and clearing flags on attachment 1234.')
-            self.assertEqual(self.getProperty('build_finish_summary'), None)
-            self.assertEqual(self.getProperty('build_summary'), 'Committed r256729')
-            return rc
 
-    def test_failure_retry(self):
-        with self.mock_sleep():
-            self.setupStep(PushCommitToWebKitRepo())
-            self.setProperty('patch_id', '2345')
+        self.assertEqual(self.getProperty('comment_text'), 'Committed r256729 (?): <https://commits.webkit.org/r256729>\n\nReviewed commits have been landed. Closing PR #1234 and removing active labels.')
+        self.assertEqual(self.getProperty('build_summary'), 'Committed r256729')
+        return rc
+
+    def test_success_patch(self):
+        with self.mock_commits_webkit_org(identifier='220797@main'), self.mock_sleep():
+            self.setupStep(DetermineLandedIdentifier())
+            self.setProperty('svn_revision', '256729')
+            self.setProperty('patch_id', '1234')
             self.expectRemoteCommands(
-                ExpectShell(workdir='wkdir',
-                            timeout=300,
-                            logEnviron=False,
-                            command=['git', 'svn', 'dcommit', '--rmdir']) +
-                ExpectShell.log('stdio', stdout='Unexpected failure') +
-                2,
+            ExpectShell(workdir='wkdir',
+                        timeout=300,
+                        logEnviron=False,
+                        command=['git', 'log', '-1', '--no-decorate']) +
+                ExpectShell.log('stdio', stdout='') +
+                0,
             )
-            self.expectOutcome(result=FAILURE, state_string='Failed to push commit to Webkit repository')
+            self.expectOutcome(result=SUCCESS, state_string='Identifier: 220797@main')
             with current_hostname(EWS_BUILD_HOSTNAME):
                 rc = self.runStep()
-            self.assertEqual(self.getProperty('retry_count'), 1)
-            self.assertEqual(self.getProperty('build_finish_summary'), None)
-            self.assertEqual(self.getProperty('comment_text'), None)
-            return rc
 
-    def test_failure(self):
-        with self.mock_sleep():
-            self.setupStep(PushCommitToWebKitRepo())
-            self.setProperty('retry_count', PushCommitToWebKitRepo.MAX_RETRY)
-            self.setProperty('patch_id', '2345')
+        self.assertEqual(self.getProperty('comment_text'), 'Committed r256729 (220797@main): <https://commits.webkit.org/220797@main>\n\nAll reviewed patches have been landed. Closing bug and clearing flags on attachment 1234.')
+        self.assertEqual(self.getProperty('build_summary'), 'Committed 220797@main')
+        return rc
+
+    def test_patch_no_identifier(self):
+        with self.mock_commits_webkit_org(), self.mock_sleep():
+            self.setupStep(DetermineLandedIdentifier())
+            self.setProperty('svn_revision', '256729')
+            self.setProperty('patch_id', '1234')
             self.expectRemoteCommands(
-                ExpectShell(workdir='wkdir',
-                            timeout=300,
-                            logEnviron=False,
-                            command=['git', 'svn', 'dcommit', '--rmdir']) +
-                ExpectShell.log('stdio', stdout='Unexpected failure') +
-                2,
+            ExpectShell(workdir='wkdir',
+                        timeout=300,
+                        logEnviron=False,
+                        command=['git', 'log', '-1', '--no-decorate']) +
+                ExpectShell.log('stdio', stdout='') +
+                0,
             )
-            self.expectOutcome(result=FAILURE, state_string='Failed to push commit to Webkit repository')
+            self.expectOutcome(result=FAILURE, state_string='Failed to determine identifier')
             with current_hostname(EWS_BUILD_HOSTNAME):
                 rc = self.runStep()
-            self.assertEqual(self.getProperty('build_finish_summary'), 'Failed to commit to WebKit repository')
-            self.assertEqual(self.getProperty('comment_text'), 'commit-queue failed to commit attachment 2345 to WebKit repository. To retry, please set cq+ flag again.')
-            return rc
 
+        self.assertEqual(self.getProperty('comment_text'), 'Committed r256729 (?): <https://commits.webkit.org/r256729>\n\nAll reviewed patches have been landed. Closing bug and clearing flags on attachment 1234.')
+        self.assertEqual(self.getProperty('build_summary'), 'Committed r256729')
+        return rc
 
 class TestShowIdentifier(BuildStepMixinAdditions, unittest.TestCase):
     def setUp(self):

Modified: trunk/Tools/ChangeLog (292575 => 292576)


--- trunk/Tools/ChangeLog	2022-04-07 22:56:25 UTC (rev 292575)
+++ trunk/Tools/ChangeLog	2022-04-07 22:59:01 UTC (rev 292576)
@@ -1,5 +1,34 @@
 2022-04-07  Jonathan Bedard  <[email protected]>
 
+        [Merge-Queue] Add PushCommitToWebKitRepo
+        https://bugs.webkit.org/show_bug.cgi?id=238959
+        <rdar://problem/91443987>
+
+        Reviewed by Aakash Jain.
+
+        * CISupport/ews-build/factories.py:
+        (MergeQueueFactory.__init__): Add PushCommitToWebKitRepo, pre-commit validation.
+        * CISupport/ews-build/factories_unittest.py:
+        (TestExpectedBuildSteps): Ditto.
+        * CISupport/ews-build/steps.py:
+        (PushCommitToWebKitRepo.evaluateCommand): Add merge-queue steps.
+        (PushCommitToWebKitRepo.getResultSummary): Remove identifier computation.
+        (PushCommitToWebKitRepo.svn_revision_from_commit_text):
+        (DetermineLandedIdentifier): Move code to determine identifier into a seperate step because
+        merge-queue has already computed the identifier.
+        (DetermineLandedIdentifier.__init__):
+        (DetermineLandedIdentifier.start): Capture log output of command.
+        (DetermineLandedIdentifier.getResultSummary):
+        (DetermineLandedIdentifier.evaluateCommand): Attempt to pull identifier from commit message,
+        otherwise, fall back to commits.webkit.org.
+        (DetermineLandedIdentifier.url_for_revision_details): Moved from PushCommitToWebKitRepo.
+        (DetermineLandedIdentifier.url_for_identifier): Ditto.
+        (DetermineLandedIdentifier.identifier_for_revision): Ditto.
+        (DetermineLandedIdentifier.comment_text_for_bug): Ditto.
+        * CISupport/ews-build/steps_unittest.py:
+
+2022-04-07  Jonathan Bedard  <[email protected]>
+
         [Merge-Queue] Canonicalize parent commits
         https://bugs.webkit.org/show_bug.cgi?id=238951
         <rdar://problem/91436607>
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to