Modified: trunk/Tools/CISupport/ews-build/factories.py (292059 => 292060)
--- trunk/Tools/CISupport/ews-build/factories.py 2022-03-29 19:49:08 UTC (rev 292059)
+++ trunk/Tools/CISupport/ews-build/factories.py 2022-03-29 20:06:07 UTC (rev 292060)
@@ -24,8 +24,8 @@
from buildbot.process import factory
from buildbot.steps import trigger
-from steps import (AddReviewerToCommitMessage, AddReviewerToChangeLog, ApplyPatch, ApplyWatchList, CheckOutPullRequest, CheckOutSource,
- CheckOutSpecificRevision, CheckChangeRelevance,
+from steps import (AddReviewerToCommitMessage, AddReviewerToChangeLog, ApplyPatch, ApplyWatchList, Canonicalize, CheckOutPullRequest,
+ CheckOutSource, CheckOutSpecificRevision, CheckChangeRelevance,
CheckPatchStatusOnEWSQueues, CheckStyle, CleanGitRepo, CompileJSC, CompileWebKit, ConfigureBuild, CreateLocalGITCommit,
DownloadBuiltProduct, ExtractBuiltProduct, FetchBranches, FindModifiedChangeLogs, FindModifiedLayoutTests,
InstallGtkDependencies, InstallWpeDependencies, KillOldProcesses, PrintConfiguration, PushCommitToWebKitRepo,
@@ -336,3 +336,4 @@
self.addStep(AddReviewerToChangeLog())
self.addStep(ValidateCommitMessage())
self.addStep(ValidateChangeLogAndReviewer())
+ self.addStep(Canonicalize())
Modified: trunk/Tools/CISupport/ews-build/steps.py (292059 => 292060)
--- trunk/Tools/CISupport/ews-build/steps.py 2022-03-29 19:49:08 UTC (rev 292059)
+++ trunk/Tools/CISupport/ews-build/steps.py 2022-03-29 20:06:07 UTC (rev 292060)
@@ -4785,3 +4785,41 @@
def hideStepIf(self, results, step):
return not self.doStepIf(step)
+
+
+class Canonicalize(steps.ShellSequence, ShellMixin):
+ name = 'canonicalize-commit'
+ description = ['canonicalize-commit']
+ descriptionDone = ['Canonicalize Commit']
+ haltOnFailure = True
+
+ def __init__(self, **kwargs):
+ super(Canonicalize, self).__init__(logEnviron=False, timeout=300, **kwargs)
+
+ def run(self):
+ self.commands = []
+
+ base_ref = self.getProperty('github.base.ref', DEFAULT_BRANCH)
+ head_ref = self.getProperty('github.head.ref', DEFAULT_BRANCH)
+
+ for command in [
+ ['git', 'pull', 'origin', base_ref],
+ ['git', 'branch', '-f', base_ref, head_ref],
+ ['python3', 'Tools/Scripts/git-webkit', 'canonicalize', '-n', '1'],
+ ]:
+ self.commands.append(util.ShellArg(command=command, logname='stdio', haltOnFailure=True))
+
+ return super(Canonicalize, self).run()
+
+ def getResultSummary(self):
+ if self.results == SKIPPED:
+ return {'step': 'Cannot canonicalize patches'}
+ if self.results != SUCCESS:
+ return {'step': 'Failed to canonicalize commit'}
+ return {'step': 'Canonicalized commit'}
+
+ def doStepIf(self, step):
+ return self.getProperty('github.number', False)
+
+ def hideStepIf(self, results, step):
+ return not self.doStepIf(step)
Modified: trunk/Tools/CISupport/ews-build/steps_unittest.py (292059 => 292060)
--- trunk/Tools/CISupport/ews-build/steps_unittest.py 2022-03-29 19:49:08 UTC (rev 292059)
+++ trunk/Tools/CISupport/ews-build/steps_unittest.py 2022-03-29 20:06:07 UTC (rev 292060)
@@ -43,7 +43,7 @@
from steps import (AddReviewerToCommitMessage, AddReviewerToChangeLog, AnalyzeAPITestsResults, AnalyzeCompileWebKitResults, AnalyzeJSCTestsResults,
AnalyzeLayoutTestsResults, ApplyPatch, ApplyWatchList, ArchiveBuiltProduct, ArchiveTestResults, BugzillaMixin,
- CheckOutPullRequest, CheckOutSource, CheckOutSpecificRevision, CheckChangeRelevance, CheckPatchStatusOnEWSQueues, CheckStyle,
+ Canonicalize, CheckOutPullRequest, CheckOutSource, CheckOutSpecificRevision, CheckChangeRelevance, CheckPatchStatusOnEWSQueues, CheckStyle,
CleanBuild, CleanUpGitIndexLock, CleanGitRepo, CleanWorkingDirectory, CompileJSC, CompileJSCWithoutChange,
CompileWebKit, CompileWebKitWithoutChange, ConfigureBuild, ConfigureBuild, Contributors, CreateLocalGITCommit,
DownloadBuiltProduct, DownloadBuiltProductFromMaster, EWS_BUILD_HOSTNAME, ExtractBuiltProduct, ExtractTestResults,
@@ -5955,5 +5955,74 @@
return self.runStep()
+class TestCanonicalize(BuildStepMixinAdditions, unittest.TestCase):
+ def setUp(self):
+ self.longMessage = True
+ return self.setUpBuildStep()
+
+ def tearDown(self):
+ return self.tearDownBuildStep()
+
+ def test_skipped_patch(self):
+ self.setupStep(Canonicalize())
+ self.setProperty('patch_id', '1234')
+ self.expectOutcome(result=SKIPPED, state_string='Cannot canonicalize patches')
+ return self.runStep()
+
+ def test_success(self):
+ self.setupStep(Canonicalize())
+ self.setProperty('github.number', '1234')
+ self.setProperty('github.base.ref', 'main')
+ self.setProperty('github.head.ref', 'eng/pull-request-branch')
+
+ self.expectRemoteCommands(
+ ExpectShell(
+ workdir='wkdir',
+ timeout=300,
+ logEnviron=False,
+ command=['git', 'pull', 'origin', 'main'],
+ ) + 0, ExpectShell(
+ workdir='wkdir',
+ timeout=300,
+ logEnviron=False,
+ command=['git', 'branch', '-f', 'main', 'eng/pull-request-branch'],
+ ) + 0, ExpectShell(
+ workdir='wkdir',
+ timeout=300,
+ logEnviron=False,
+ command=['python3', 'Tools/Scripts/git-webkit', 'canonicalize', '-n', '1'],
+ ) + 0,
+ )
+ self.expectOutcome(result=SUCCESS, state_string='Canonicalized commit')
+ return self.runStep()
+
+ def test_failure(self):
+ self.setupStep(Canonicalize())
+ self.setProperty('github.number', '1234')
+ self.setProperty('github.base.ref', 'main')
+ self.setProperty('github.head.ref', 'eng/pull-request-branch')
+
+ self.expectRemoteCommands(
+ ExpectShell(
+ workdir='wkdir',
+ timeout=300,
+ logEnviron=False,
+ command=['git', 'pull', 'origin', 'main'],
+ ) + 0, ExpectShell(
+ workdir='wkdir',
+ timeout=300,
+ logEnviron=False,
+ command=['git', 'branch', '-f', 'main', 'eng/pull-request-branch'],
+ ) + 0, ExpectShell(
+ workdir='wkdir',
+ timeout=300,
+ logEnviron=False,
+ command=['python3', 'Tools/Scripts/git-webkit', 'canonicalize', '-n', '1'],
+ ) + 1,
+ )
+ self.expectOutcome(result=FAILURE, state_string='Failed to canonicalize commit')
+ return self.runStep()
+
+
if __name__ == '__main__':
unittest.main()