[ews-build] Add build step to clean up .git/index.lock file
authoraakash_jain@apple.com <aakash_jain@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 11 Jul 2019 21:12:39 +0000 (21:12 +0000)
committeraakash_jain@apple.com <aakash_jain@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 11 Jul 2019 21:12:39 +0000 (21:12 +0000)
https://bugs.webkit.org/show_bug.cgi?id=199722

Reviewed by Jonathan Bedard.

* BuildSlaveSupport/ews-build/steps.py:
(CheckOutSource.getResultSummary): Run CleanUpGitIndexLock step when CheckOutSource fails.
(CleanUpGitIndexLock.__init__): Configure timeout and logEnviron.
(CleanUpGitIndexLock.evaluateCommand): Always RETRY the build after this step is run.
* BuildSlaveSupport/ews-build/steps_unittest.py: Added unit-tests.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@247364 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Tools/BuildSlaveSupport/ews-build/steps.py
Tools/BuildSlaveSupport/ews-build/steps_unittest.py
Tools/ChangeLog

index 7bcc4c5..6a78772 100644 (file)
@@ -102,12 +102,28 @@ class CheckOutSource(git.Git):
                                                 **kwargs)
 
     def getResultSummary(self):
+        if self.results == FAILURE:
+            self.build.addStepsAfterCurrentStep([CleanUpGitIndexLock()])
+
         if self.results != SUCCESS:
             return {u'step': u'Failed to updated working directory'}
         else:
             return {u'step': u'Cleaned and updated working directory'}
 
 
+class CleanUpGitIndexLock(shell.ShellCommand):
+    name = 'clean-git-index-lock'
+    command = ['rm', '-f', '.git/index.lock']
+    descriptionDone = ['Deleted .git/index.lock']
+
+    def __init__(self, **kwargs):
+        super(CleanUpGitIndexLock, self).__init__(timeout=2 * 60, logEnviron=False, **kwargs)
+
+    def evaluateCommand(self, cmd):
+        self.build.buildFinished(['Git issue, retrying build'], RETRY)
+        return super(CleanUpGitIndexLock, self).evaluateCommand(cmd)
+
+
 class CheckOutSpecificRevision(shell.ShellCommand):
     name = 'checkout-specific-revision'
     descriptionDone = ['Checked out required revision']
index fd4620f..658d867 100644 (file)
@@ -35,7 +35,7 @@ from twisted.python import failure, log
 from twisted.trial import unittest
 
 from steps import (AnalyzeAPITestsResults, AnalyzeCompileWebKitResults, ApplyPatch, ArchiveBuiltProduct, ArchiveTestResults,
-                   CheckOutSource, CheckOutSpecificRevision, CheckPatchRelevance, CheckStyle, CleanBuild, CleanWorkingDirectory,
+                   CheckOutSource, CheckOutSpecificRevision, CheckPatchRelevance, CheckStyle, CleanBuild, CleanUpGitIndexLock, CleanWorkingDirectory,
                    CompileJSCOnly, CompileJSCOnlyToT, CompileWebKit, CompileWebKitToT, ConfigureBuild,
                    DownloadBuiltProduct, ExtractBuiltProduct, ExtractTestResults, InstallGtkDependencies, InstallWpeDependencies, KillOldProcesses,
                    PrintConfiguration, ReRunAPITests, ReRunJavaScriptCoreTests, RunAPITests, RunAPITestsWithoutPatch,
@@ -478,6 +478,42 @@ class TestCleanBuild(BuildStepMixinAdditions, unittest.TestCase):
         return self.runStep()
 
 
+class TestCleanUpGitIndexLock(BuildStepMixinAdditions, unittest.TestCase):
+    def setUp(self):
+        self.longMessage = True
+        return self.setUpBuildStep()
+
+    def tearDown(self):
+        return self.tearDownBuildStep()
+
+    def test_success(self):
+        self.setupStep(CleanUpGitIndexLock())
+        self.expectRemoteCommands(
+            ExpectShell(workdir='wkdir',
+                        timeout=120,
+                        logEnviron=False,
+                        command=['rm', '-f', '.git/index.lock'],
+                        )
+            + 0,
+        )
+        self.expectOutcome(result=SUCCESS, state_string='Deleted .git/index.lock')
+        return self.runStep()
+
+    def test_failure(self):
+        self.setupStep(CleanUpGitIndexLock())
+        self.expectRemoteCommands(
+            ExpectShell(workdir='wkdir',
+                        timeout=120,
+                        logEnviron=False,
+                        command=['rm', '-f', '.git/index.lock'],
+                        )
+            + ExpectShell.log('stdio', stdout='Unexpected error.')
+            + 1,
+        )
+        self.expectOutcome(result=FAILURE, state_string='Deleted .git/index.lock (failure)')
+        return self.runStep()
+
+
 class TestInstallGtkDependencies(BuildStepMixinAdditions, unittest.TestCase):
     def setUp(self):
         self.longMessage = True
index d78ab8a..c73c457 100644 (file)
@@ -1,3 +1,16 @@
+2019-07-11  Aakash Jain  <aakash_jain@apple.com>
+
+        [ews-build] Add build step to clean up .git/index.lock file
+        https://bugs.webkit.org/show_bug.cgi?id=199722
+
+        Reviewed by Jonathan Bedard.
+
+        * BuildSlaveSupport/ews-build/steps.py:
+        (CheckOutSource.getResultSummary): Run CleanUpGitIndexLock step when CheckOutSource fails.
+        (CleanUpGitIndexLock.__init__): Configure timeout and logEnviron.
+        (CleanUpGitIndexLock.evaluateCommand): Always RETRY the build after this step is run.
+        * BuildSlaveSupport/ews-build/steps_unittest.py: Added unit-tests.
+
 2019-07-11  Jonathan Bedard  <jbedard@apple.com>
 
         [iOS 13] Enable WebKit build