Title: [275853] trunk/Tools
Revision
275853
Author
[email protected]
Date
2021-04-12 17:48:17 -0700 (Mon, 12 Apr 2021)

Log Message

Make Commit Queue robust by adding few git commands to clean up repository
https://bugs.webkit.org/show_bug.cgi?id=224444

Reviewed by Jonathan Bedard.

* CISupport/ews-build/steps.py:
(CleanGitRepo): Build step to run few commands to cleanup git repository.
(CleanGitRepo.run):
(CleanGitRepo.getResultSummary): Custom failure message.
* CISupport/ews-build/steps_unittest.py: Added unit-tests.
* CISupport/ews-build/factories.py:
(CommitQueueFactory.__init__):
* CISupport/ews-build/factories_unittest.py:
(TestCommitQueueFactory.test_commit_queue_factory): Updated unit-test.

Modified Paths

Diff

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


--- trunk/Tools/CISupport/ews-build/factories.py	2021-04-13 00:47:20 UTC (rev 275852)
+++ trunk/Tools/CISupport/ews-build/factories.py	2021-04-13 00:48:17 UTC (rev 275853)
@@ -25,7 +25,7 @@
 from buildbot.steps import trigger
 
 from steps import (ApplyPatch, ApplyWatchList, CheckOutSource, CheckOutSpecificRevision, CheckPatchRelevance,
-                   CheckPatchStatusOnEWSQueues, CheckStyle, CompileJSC, CompileWebKit, ConfigureBuild, CreateLocalGITCommit,
+                   CheckPatchStatusOnEWSQueues, CheckStyle, CleanGitRepo, CompileJSC, CompileWebKit, ConfigureBuild, CreateLocalGITCommit,
                    DownloadBuiltProduct, ExtractBuiltProduct, FetchBranches, FindModifiedChangeLogs, FindModifiedLayoutTests,
                    InstallGtkDependencies, InstallWpeDependencies, KillOldProcesses, PrintConfiguration, PushCommitToWebKitRepo,
                    RunAPITests, RunBindingsTests, RunBuildWebKitOrgUnitTests, RunBuildbotCheckConfigForBuildWebKit, RunBuildbotCheckConfigForEWS,
@@ -281,6 +281,7 @@
         self.addStep(ValidatePatch(verifycqplus=True))
         self.addStep(ValidateCommiterAndReviewer())
         self.addStep(PrintConfiguration())
+        self.addStep(CleanGitRepo())
         self.addStep(CheckOutSource())
         self.addStep(FetchBranches())
         self.addStep(ShowIdentifier())

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


--- trunk/Tools/CISupport/ews-build/factories_unittest.py	2021-04-13 00:47:20 UTC (rev 275852)
+++ trunk/Tools/CISupport/ews-build/factories_unittest.py	2021-04-13 00:48:17 UTC (rev 275853)
@@ -411,6 +411,7 @@
             _BuildStepFactory(steps.ValidatePatch, verifycqplus=True),
             _BuildStepFactory(steps.ValidateCommiterAndReviewer),
             _BuildStepFactory(steps.PrintConfiguration),
+            _BuildStepFactory(steps.CleanGitRepo),
             _BuildStepFactory(steps.CheckOutSource),
             _BuildStepFactory(steps.FetchBranches),
             _BuildStepFactory(steps.ShowIdentifier),

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


--- trunk/Tools/CISupport/ews-build/steps.py	2021-04-13 00:47:20 UTC (rev 275852)
+++ trunk/Tools/CISupport/ews-build/steps.py	2021-04-13 00:48:17 UTC (rev 275853)
@@ -3128,6 +3128,31 @@
         return {'step': configuration}
 
 
+class CleanGitRepo(steps.ShellSequence):
+    name = 'clean-up-git-repo'
+    haltOnFailure = False
+    flunkOnFailure = False
+    logEnviron = False
+    # This somewhat quirky sequence of steps seems to clear up all the broken
+    # git situations we've gotten ourself into in the past.
+    command_list = [['git', 'clean', '-f'],  # Remove any left-over layout test results, added files, etc.
+                    ['git', 'fetch', 'origin'],  # Avoid updating the working copy to a stale revision.
+                    ['git', 'checkout', 'origin/main', '-f'],
+                    ['git', 'branch', '-D', 'main'],
+                    ['git', 'checkout', 'origin/main', '-b', 'main']]
+
+    def run(self):
+        self.commands = []
+        for command in self.command_list:
+            self.commands.append(util.ShellArg(command=command, logname='stdio'))
+        return super(CleanGitRepo, self).run()
+
+    def getResultSummary(self):
+        if self.results != SUCCESS:
+            return {'step': 'Encountered some issues during cleanup'}
+        return {'step': 'Cleaned up git repository'}
+
+
 class ApplyWatchList(shell.ShellCommand):
     name = 'apply-watch-list'
     description = ['applying watchilist']

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


--- trunk/Tools/CISupport/ews-build/steps_unittest.py	2021-04-13 00:47:20 UTC (rev 275852)
+++ trunk/Tools/CISupport/ews-build/steps_unittest.py	2021-04-13 00:48:17 UTC (rev 275853)
@@ -43,8 +43,8 @@
 from steps import (AnalyzeAPITestsResults, AnalyzeCompileWebKitResults, AnalyzeJSCTestsResults,
                    AnalyzeLayoutTestsResults, ApplyPatch, ApplyWatchList, ArchiveBuiltProduct, ArchiveTestResults,
                    CheckOutSource, CheckOutSpecificRevision, CheckPatchRelevance, CheckPatchStatusOnEWSQueues, CheckStyle,
-                   CleanBuild, CleanUpGitIndexLock, CleanWorkingDirectory, CompileJSC, CompileJSCWithoutPatch, CompileWebKit,
-                   CompileWebKitWithoutPatch, ConfigureBuild, CreateLocalGITCommit,
+                   CleanBuild, CleanUpGitIndexLock, CleanGitRepo, CleanWorkingDirectory, CompileJSC, CompileJSCWithoutPatch,
+                   CompileWebKit, CompileWebKitWithoutPatch, ConfigureBuild, CreateLocalGITCommit,
                    DownloadBuiltProduct, DownloadBuiltProductFromMaster, EWS_BUILD_HOSTNAME, ExtractBuiltProduct, ExtractTestResults,
                    FetchBranches, FindModifiedChangeLogs, FindModifiedLayoutTests, GitResetHard, InstallGtkDependencies, InstallWpeDependencies,
                    KillOldProcesses, PrintConfiguration, PushCommitToWebKitRepo, ReRunAPITests, ReRunJavaScriptCoreTests, ReRunWebKitPerlTests,
@@ -3889,6 +3889,53 @@
         return self.runStep()
 
 
+class TestCleanGitRepo(BuildStepMixinAdditions, unittest.TestCase):
+    def setUp(self):
+        self.longMessage = True
+        return self.setUpBuildStep()
+
+    def tearDown(self):
+        return self.tearDownBuildStep()
+
+    def test_success(self):
+        self.setupStep(CleanGitRepo())
+        self.setProperty('buildername', 'Commit-Queue')
+
+        self.expectRemoteCommands(
+            ExpectShell(command=['git', 'clean', '-f'], workdir='wkdir', timeout=1200, logEnviron=False) + 0
+            + ExpectShell.log('stdio', stdout=''),
+            ExpectShell(command=['git', 'fetch', 'origin'], workdir='wkdir', timeout=1200, logEnviron=False) + 0
+            + ExpectShell.log('stdio', stdout=''),
+            ExpectShell(command=['git', 'checkout', 'origin/main', '-f'], workdir='wkdir', timeout=1200, logEnviron=False) + 0
+            + ExpectShell.log('stdio', stdout='You are in detached HEAD state.'),
+            ExpectShell(command=['git', 'branch', '-D', 'main'], workdir='wkdir', timeout=1200, logEnviron=False) + 0
+            + ExpectShell.log('stdio', stdout='Deleted branch main (was 57015967fef9).'),
+            ExpectShell(command=['git', 'checkout', 'origin/main', '-b', 'main'], workdir='wkdir', timeout=1200, logEnviron=False) + 0
+            + ExpectShell.log('stdio', stdout="Switched to a new branch 'main'"),
+        )
+        self.expectOutcome(result=SUCCESS, state_string='Cleaned up git repository')
+        return self.runStep()
+
+    def test_failure(self):
+        self.setupStep(CleanGitRepo())
+        self.setProperty('buildername', 'Commit-Queue')
+
+        self.expectRemoteCommands(
+            ExpectShell(command=['git', 'clean', '-f'], workdir='wkdir', timeout=1200, logEnviron=False) + 0
+            + ExpectShell.log('stdio', stdout=''),
+            ExpectShell(command=['git', 'fetch', 'origin'], workdir='wkdir', timeout=1200, logEnviron=False) + 128
+            + ExpectShell.log('stdio', stdout='fatal: unable to access https://github.com/WebKit/WebKit.git/: Could not resolve host: github.com'),
+            ExpectShell(command=['git', 'checkout', 'origin/main', '-f'], workdir='wkdir', timeout=1200, logEnviron=False) + 0
+            + ExpectShell.log('stdio', stdout='You are in detached HEAD state.'),
+            ExpectShell(command=['git', 'branch', '-D', 'main'], workdir='wkdir', timeout=1200, logEnviron=False) + 0
+            + ExpectShell.log('stdio', stdout='Deleted branch main (was 57015967fef9).'),
+            ExpectShell(command=['git', 'checkout', 'origin/main', '-b', 'main'], workdir='wkdir', timeout=1200, logEnviron=False) + 0
+            + ExpectShell.log('stdio', stdout="Switched to a new branch 'main'"),
+        )
+        self.expectOutcome(result=FAILURE, state_string='Encountered some issues during cleanup')
+        return self.runStep()
+
+
 class TestFindModifiedChangeLogs(BuildStepMixinAdditions, unittest.TestCase):
     def setUp(self):
         self.longMessage = True

Modified: trunk/Tools/ChangeLog (275852 => 275853)


--- trunk/Tools/ChangeLog	2021-04-13 00:47:20 UTC (rev 275852)
+++ trunk/Tools/ChangeLog	2021-04-13 00:48:17 UTC (rev 275853)
@@ -1,3 +1,20 @@
+2021-04-12  Aakash Jain  <[email protected]>
+
+        Make Commit Queue robust by adding few git commands to clean up repository
+        https://bugs.webkit.org/show_bug.cgi?id=224444
+
+        Reviewed by Jonathan Bedard.
+
+        * CISupport/ews-build/steps.py:
+        (CleanGitRepo): Build step to run few commands to cleanup git repository.
+        (CleanGitRepo.run):
+        (CleanGitRepo.getResultSummary): Custom failure message.
+        * CISupport/ews-build/steps_unittest.py: Added unit-tests.
+        * CISupport/ews-build/factories.py:
+        (CommitQueueFactory.__init__):
+        * CISupport/ews-build/factories_unittest.py:
+        (TestCommitQueueFactory.test_commit_queue_factory): Updated unit-test.
+
 2021-04-11  Commit Queue  <[email protected]>
 
         Unreviewed, reverting r275801.
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to