Modified: trunk/Tools/CISupport/ews-build/factories.py (291626 => 291627)
--- trunk/Tools/CISupport/ews-build/factories.py 2022-03-22 17:19:45 UTC (rev 291626)
+++ trunk/Tools/CISupport/ews-build/factories.py 2022-03-22 17:30:16 UTC (rev 291627)
@@ -33,7 +33,7 @@
RunWebKitPyPython3Tests, RunWebKitTests, RunWebKitTestsRedTree, RunWebKitTestsInStressMode, RunWebKitTestsInStressGuardmallocMode,
SetBuildSummary, ShowIdentifier, TriggerCrashLogSubmission, UpdateWorkingDirectory,
ValidateChange, ValidateChangeLogAndReviewer, ValidateCommitterAndReviewer, WaitForCrashCollection,
- InstallBuiltProduct, VerifyGitHubIntegrity)
+ InstallBuiltProduct, VerifyGitHubIntegrity, ValidateSquashed)
class Factory(factory.BuildFactory):
@@ -330,3 +330,4 @@
self.addStep(VerifyGitHubIntegrity())
self.addStep(UpdateWorkingDirectory())
self.addStep(CheckOutPullRequest())
+ self.addStep(ValidateSquashed())
Modified: trunk/Tools/CISupport/ews-build/factories_unittest.py (291626 => 291627)
--- trunk/Tools/CISupport/ews-build/factories_unittest.py 2022-03-22 17:19:45 UTC (rev 291626)
+++ trunk/Tools/CISupport/ews-build/factories_unittest.py 2022-03-22 17:30:16 UTC (rev 291627)
@@ -637,7 +637,8 @@
'show-identifier',
'verify-github-integrity',
'update-working-directory',
- 'checkout-pull-request'
+ 'checkout-pull-request',
+ 'validate-squashed',
],
}
Modified: trunk/Tools/CISupport/ews-build/steps.py (291626 => 291627)
--- trunk/Tools/CISupport/ews-build/steps.py 2022-03-22 17:19:45 UTC (rev 291626)
+++ trunk/Tools/CISupport/ews-build/steps.py 2022-03-22 17:30:16 UTC (rev 291627)
@@ -4582,3 +4582,44 @@
send_email_to_github_admin(email_subject, email_text)
except Exception as e:
print('Error in sending email for github issue: {}'.format(e))
+
+
+class ValidateSquashed(shell.ShellCommand):
+ name = 'validate-squashed'
+ haltOnFailure = True
+
+ def __init__(self, **kwargs):
+ 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)
+ self.command = ['git', 'log', '--oneline', head_ref, f'^{base_ref}', '--max-count=2']
+
+ self.log_observer = BufferLogObserverClass(wantStderr=True)
+ self.addLogObserver('stdio', self.log_observer)
+
+ return shell.ShellCommand.start(self)
+
+ def getResultSummary(self):
+ if self.results == SKIPPED:
+ return {'step': 'Patches are always squashed'}
+ elif self.results == SUCCESS:
+ return {'step': 'Verified branch is squashed'}
+ return {'step': 'Can only land squashed branches'}
+
+ def evaluateCommand(self, cmd):
+ rc = shell.ShellCommand.evaluateCommand(self, cmd)
+ if rc != SUCCESS:
+ return rc
+
+ log_text = self.log_observer.getStdout()
+ if len(log_text.splitlines()) == 1:
+ return SUCCESS
+ return FAILURE
+
+ def doStepIf(self, step):
+ return self.getProperty('github.number')
+
+ def hideStepIf(self, results, step):
+ return not self.doStepIf(step)
Modified: trunk/Tools/CISupport/ews-build/steps_unittest.py (291626 => 291627)
--- trunk/Tools/CISupport/ews-build/steps_unittest.py 2022-03-22 17:19:45 UTC (rev 291626)
+++ trunk/Tools/CISupport/ews-build/steps_unittest.py 2022-03-22 17:30:16 UTC (rev 291627)
@@ -56,7 +56,7 @@
RunWebKitTestsWithoutChange, RunWebKitTestsRedTree, RunWebKitTestsRepeatFailuresRedTree, RunWebKitTestsRepeatFailuresWithoutChangeRedTree,
RunWebKitTestsWithoutChangeRedTree, AnalyzeLayoutTestsResultsRedTree, TestWithFailureCount, ShowIdentifier,
Trigger, TransferToS3, UnApplyPatch, UpdateWorkingDirectory, UploadBuiltProduct,
- UploadTestResults, ValidateChangeLogAndReviewer, ValidateCommitterAndReviewer, ValidateChange, VerifyGitHubIntegrity)
+ UploadTestResults, ValidateChangeLogAndReviewer, ValidateCommitterAndReviewer, ValidateChange, VerifyGitHubIntegrity, ValidateSquashed)
# Workaround for https://github.com/buildbot/buildbot/issues/4669
from buildbot.test.fake.fakebuild import FakeBuild
@@ -5590,5 +5590,71 @@
return self.runStep()
+class TestValidateSquashed(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(ValidateSquashed())
+ self.setProperty('patch_id', '1234')
+ self.expectOutcome(result=SKIPPED, state_string='Patches are always squashed')
+ return self.runStep()
+
+ def test_success(self):
+ self.setupStep(ValidateSquashed())
+ 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',
+ logEnviron=False,
+ command=['git', 'log', '--oneline', 'eng/pull-request-branch', '^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_failure_multiple_commits(self):
+ self.setupStep(ValidateSquashed())
+ 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',
+ logEnviron=False,
+ command=['git', 'log', '--oneline', 'eng/pull-request-branch', '^main', '--max-count=2'],
+ )
+ + 0
+ + ExpectShell.log('stdio', stdout='''e1eb24603493 (HEAD -> eng/pull-request-branch) Commit Series (3)
+08abb9ddcbb5 Commit Series (2)
+45cf3efe4dfb Commit Series (1)
+'''),
+ )
+ self.expectOutcome(result=FAILURE, state_string='Can only land squashed branches')
+ return self.runStep()
+
+ def test_failure_merged(self):
+ self.setupStep(ValidateSquashed())
+ 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',
+ logEnviron=False,
+ command=['git', 'log', '--oneline', 'eng/pull-request-branch', '^main', '--max-count=2'],
+ )
+ + 0
+ + ExpectShell.log('stdio', stdout=''),
+ )
+ self.expectOutcome(result=FAILURE, state_string='Can only land squashed branches')
+ return self.runStep()
+
+
if __name__ == '__main__':
unittest.main()