Title: [287857] trunk/Tools
Revision
287857
Author
[email protected]
Date
2022-01-10 14:18:11 -0800 (Mon, 10 Jan 2022)

Log Message

[EWS] Always invoke CleanGitRepo before CheckOutSource
https://bugs.webkit.org/show_bug.cgi?id=234882
<rdar://problem/87145396>

Reviewed by Aakash Jain.

* Tools/CISupport/ews-build/factories.py:
(Factory.__init__): Add CleanGitRepo step.
(StyleFactory.__init__): Ditto.
(WatchListFactory.__init__): Ditto.
(CommitQueueFactory.__init__): Specify default branch as 'master.'
* Tools/CISupport/ews-build/factories_unittest.py:
(TestExpectedBuildSteps):
* Tools/CISupport/ews-build/steps.py:
(CleanGitRepo.__init__): Accept default_branch and remote.
(CleanGitRepo.run): Construct commands with awareness of branch and remote,
check to see if a basename is specified.
* Tools/CISupport/ews-build/steps_unittest.py:

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

Modified Paths

Diff

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


--- trunk/Tools/CISupport/ews-build/factories.py	2022-01-10 21:57:16 UTC (rev 287856)
+++ trunk/Tools/CISupport/ews-build/factories.py	2022-01-10 22:18:11 UTC (rev 287857)
@@ -48,6 +48,7 @@
             self.addStep(FindModifiedLayoutTests())
         self.addStep(ValidatePatch())
         self.addStep(PrintConfiguration())
+        self.addStep(CleanGitRepo())
         self.addStep(CheckOutSource())
         # CheckOutSource step pulls the latest revision, since we use alwaysUseLatest=True. Without alwaysUseLatest Buildbot will
         # automatically apply the patch to the repo, and that doesn't handle ChangeLogs well. See https://webkit.org/b/193138
@@ -64,6 +65,7 @@
         self.addStep(ConfigureBuild(platform=platform, configuration=configuration, architectures=architectures, buildOnly=False, triggers=triggers, remotes=remotes, additionalArguments=additionalArguments))
         self.addStep(ValidatePatch())
         self.addStep(PrintConfiguration())
+        self.addStep(CleanGitRepo())
         self.addStep(CheckOutSource())
         self.addStep(FetchBranches())
         self.addStep(ShowIdentifier())
@@ -78,6 +80,7 @@
         self.addStep(ConfigureBuild(platform=platform, configuration=configuration, architectures=architectures, buildOnly=False, triggers=triggers, remotes=remotes, additionalArguments=additionalArguments))
         self.addStep(ValidatePatch())
         self.addStep(PrintConfiguration())
+        self.addStep(CleanGitRepo())
         self.addStep(CheckOutSource())
         self.addStep(FetchBranches())
         self.addStep(ShowIdentifier())
@@ -285,7 +288,7 @@
         self.addStep(ValidatePatch(verifycqplus=True))
         self.addStep(ValidateCommiterAndReviewer())
         self.addStep(PrintConfiguration())
-        self.addStep(CleanGitRepo())
+        self.addStep(CleanGitRepo(default_branch='master'))
         self.addStep(CheckOutSource(repourl='https://git.webkit.org/git/WebKit-https'))
         self.addStep(FetchBranches())
         self.addStep(ShowIdentifier())

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


--- trunk/Tools/CISupport/ews-build/factories_unittest.py	2022-01-10 21:57:16 UTC (rev 287856)
+++ trunk/Tools/CISupport/ews-build/factories_unittest.py	2022-01-10 22:18:11 UTC (rev 287857)
@@ -33,6 +33,7 @@
             'configure-build',
             'validate-patch',
             'configuration',
+            'clean-up-git-repo',
             'clean-and-update-working-directory',
             'fetch-branch-references',
             'show-identifier',
@@ -44,6 +45,7 @@
             'configure-build',
             'validate-patch',
             'configuration',
+            'clean-up-git-repo',
             'clean-and-update-working-directory',
             'fetch-branch-references',
             'show-identifier',
@@ -55,6 +57,7 @@
             'configure-build',
             'validate-patch',
             'configuration',
+            'clean-up-git-repo',
             'clean-and-update-working-directory',
             'checkout-specific-revision',
             'fetch-branch-references',
@@ -69,6 +72,7 @@
             'configure-build',
             'validate-patch',
             'configuration',
+            'clean-up-git-repo',
             'clean-and-update-working-directory',
             'checkout-specific-revision',
             'fetch-branch-references',
@@ -87,6 +91,7 @@
             'configure-build',
             'validate-patch',
             'configuration',
+            'clean-up-git-repo',
             'clean-and-update-working-directory',
             'checkout-specific-revision',
             'fetch-branch-references',
@@ -99,6 +104,7 @@
             'configure-build',
             'validate-patch',
             'configuration',
+            'clean-up-git-repo',
             'clean-and-update-working-directory',
             'checkout-specific-revision',
             'fetch-branch-references',
@@ -111,6 +117,7 @@
             'configure-build',
             'validate-patch',
             'configuration',
+            'clean-up-git-repo',
             'clean-and-update-working-directory',
             'checkout-specific-revision',
             'fetch-branch-references',
@@ -131,6 +138,7 @@
             'check-patch-relevance',
             'validate-patch',
             'configuration',
+            'clean-up-git-repo',
             'clean-and-update-working-directory',
             'checkout-specific-revision',
             'fetch-branch-references',
@@ -143,6 +151,7 @@
             'configure-build',
             'validate-patch',
             'configuration',
+            'clean-up-git-repo',
             'clean-and-update-working-directory',
             'checkout-specific-revision',
             'fetch-branch-references',
@@ -162,6 +171,7 @@
             'configure-build',
             'validate-patch',
             'configuration',
+            'clean-up-git-repo',
             'clean-and-update-working-directory',
             'checkout-specific-revision',
             'fetch-branch-references',
@@ -175,6 +185,7 @@
             'check-patch-relevance',
             'validate-patch',
             'configuration',
+            'clean-up-git-repo',
             'clean-and-update-working-directory',
             'checkout-specific-revision',
             'fetch-branch-references',
@@ -194,6 +205,7 @@
             'configure-build',
             'validate-patch',
             'configuration',
+            'clean-up-git-repo',
             'clean-and-update-working-directory',
             'checkout-specific-revision',
             'fetch-branch-references',
@@ -214,6 +226,7 @@
             'find-modified-layout-tests',
             'validate-patch',
             'configuration',
+            'clean-up-git-repo',
             'clean-and-update-working-directory',
             'checkout-specific-revision',
             'fetch-branch-references',
@@ -231,6 +244,7 @@
             'configure-build',
             'validate-patch',
             'configuration',
+            'clean-up-git-repo',
             'clean-and-update-working-directory',
             'checkout-specific-revision',
             'fetch-branch-references',
@@ -244,6 +258,7 @@
             'check-patch-relevance',
             'validate-patch',
             'configuration',
+            'clean-up-git-repo',
             'clean-and-update-working-directory',
             'checkout-specific-revision',
             'fetch-branch-references',
@@ -263,6 +278,7 @@
             'configure-build',
             'validate-patch',
             'configuration',
+            'clean-up-git-repo',
             'clean-and-update-working-directory',
             'checkout-specific-revision',
             'fetch-branch-references',
@@ -275,6 +291,7 @@
             'configure-build',
             'validate-patch',
             'configuration',
+            'clean-up-git-repo',
             'clean-and-update-working-directory',
             'checkout-specific-revision',
             'fetch-branch-references',
@@ -287,6 +304,7 @@
             'configure-build',
             'validate-patch',
             'configuration',
+            'clean-up-git-repo',
             'clean-and-update-working-directory',
             'checkout-specific-revision',
             'fetch-branch-references',
@@ -299,6 +317,7 @@
             'configure-build',
             'validate-patch',
             'configuration',
+            'clean-up-git-repo',
             'clean-and-update-working-directory',
             'checkout-specific-revision',
             'fetch-branch-references',
@@ -312,6 +331,7 @@
             'check-patch-relevance',
             'validate-patch',
             'configuration',
+            'clean-up-git-repo',
             'clean-and-update-working-directory',
             'checkout-specific-revision',
             'fetch-branch-references',
@@ -327,6 +347,7 @@
             'configure-build',
             'validate-patch',
             'configuration',
+            'clean-up-git-repo',
             'clean-and-update-working-directory',
             'checkout-specific-revision',
             'fetch-branch-references',
@@ -339,6 +360,7 @@
             'configure-build',
             'validate-patch',
             'configuration',
+            'clean-up-git-repo',
             'clean-and-update-working-directory',
             'checkout-specific-revision',
             'fetch-branch-references',
@@ -353,6 +375,7 @@
             'check-patch-relevance',
             'validate-patch',
             'configuration',
+            'clean-up-git-repo',
             'clean-and-update-working-directory',
             'checkout-specific-revision',
             'fetch-branch-references',
@@ -367,6 +390,7 @@
             'check-patch-relevance',
             'validate-patch',
             'configuration',
+            'clean-up-git-repo',
             'clean-and-update-working-directory',
             'checkout-specific-revision',
             'fetch-branch-references',
@@ -380,6 +404,7 @@
             'check-patch-relevance',
             'validate-patch',
             'configuration',
+            'clean-up-git-repo',
             'clean-and-update-working-directory',
             'checkout-specific-revision',
             'fetch-branch-references',
@@ -395,6 +420,7 @@
             'check-patch-relevance',
             'validate-patch',
             'configuration',
+            'clean-up-git-repo',
             'clean-and-update-working-directory',
             'checkout-specific-revision',
             'fetch-branch-references',
@@ -408,6 +434,7 @@
             'check-patch-relevance',
             'validate-patch',
             'configuration',
+            'clean-up-git-repo',
             'clean-and-update-working-directory',
             'checkout-specific-revision',
             'fetch-branch-references',
@@ -423,6 +450,7 @@
             'check-patch-relevance',
             'validate-patch',
             'configuration',
+            'clean-up-git-repo',
             'clean-and-update-working-directory',
             'checkout-specific-revision',
             'fetch-branch-references',
@@ -436,6 +464,7 @@
             'check-patch-relevance',
             'validate-patch',
             'configuration',
+            'clean-up-git-repo',
             'clean-and-update-working-directory',
             'checkout-specific-revision',
             'fetch-branch-references',
@@ -448,6 +477,7 @@
             'check-patch-relevance',
             'validate-patch',
             'configuration',
+            'clean-up-git-repo',
             'clean-and-update-working-directory',
             'checkout-specific-revision',
             'fetch-branch-references',
@@ -461,6 +491,7 @@
             'configure-build',
             'validate-patch',
             'configuration',
+            'clean-up-git-repo',
             'clean-and-update-working-directory',
             'checkout-specific-revision',
             'fetch-branch-references',
@@ -472,6 +503,7 @@
             'configure-build',
             'validate-patch',
             'configuration',
+            'clean-up-git-repo',
             'clean-and-update-working-directory',
             'checkout-specific-revision',
             'fetch-branch-references',
@@ -486,6 +518,7 @@
             'configure-build',
             'validate-patch',
             'configuration',
+            'clean-up-git-repo',
             'clean-and-update-working-directory',
             'checkout-specific-revision',
             'fetch-branch-references',
@@ -500,6 +533,7 @@
             'configure-build',
             'validate-patch',
             'configuration',
+            'clean-up-git-repo',
             'clean-and-update-working-directory',
             'checkout-specific-revision',
             'fetch-branch-references',
@@ -516,6 +550,7 @@
             'check-patch-relevance',
             'validate-patch',
             'configuration',
+            'clean-up-git-repo',
             'clean-and-update-working-directory',
             'checkout-specific-revision',
             'fetch-branch-references',

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


--- trunk/Tools/CISupport/ews-build/steps.py	2022-01-10 21:57:16 UTC (rev 287856)
+++ trunk/Tools/CISupport/ews-build/steps.py	2022-01-10 22:18:11 UTC (rev 287857)
@@ -3574,17 +3574,22 @@
     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', '-d'],  # 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/master', '-f'],
-                    ['git', 'branch', '-D', 'master'],
-                    ['git', 'checkout', 'origin/master', '-b', 'master']]
 
+    def __init__(self, default_branch='main', remote='origin', **kwargs):
+        super(CleanGitRepo, self).__init__(timeout=5 * 60, **kwargs)
+        self.default_branch = default_branch
+        self.git_remote = remote
+
     def run(self):
+        branch = self.getProperty('basename', self.default_branch)
         self.commands = []
-        for command in self.command_list:
+        for command in [
+            ['git', 'clean', '-f', '-d'],  # Remove any left-over layout test results, added files, etc.
+            ['git', 'fetch', self.git_remote],  # Avoid updating the working copy to a stale revision.
+            ['git', 'checkout', '{}/{}'.format(self.git_remote, branch), '-f'],  # Checkout branch from specific remote
+            ['git', 'branch', '-D', '{}'.format(branch)],  # Delete any local cache of the specified branch
+            ['git', 'checkout', '{}/{}'.format(self.git_remote, branch), '-b', '{}'.format(branch)],  # Checkout local instance of branch from remote
+        ]:
             self.commands.append(util.ShellArg(command=command, logname='stdio'))
         return super(CleanGitRepo, self).run()
 

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


--- trunk/Tools/CISupport/ews-build/steps_unittest.py	2022-01-10 21:57:16 UTC (rev 287856)
+++ trunk/Tools/CISupport/ews-build/steps_unittest.py	2022-01-10 22:18:11 UTC (rev 287857)
@@ -4330,18 +4330,37 @@
 
     def test_success(self):
         self.setupStep(CleanGitRepo())
+        self.setProperty('buildername', 'Style-EWS')
+
+        self.expectRemoteCommands(
+            ExpectShell(command=['git', 'clean', '-f', '-d'], workdir='wkdir', timeout=300, logEnviron=False) + 0
+            + ExpectShell.log('stdio', stdout=''),
+            ExpectShell(command=['git', 'fetch', 'origin'], workdir='wkdir', timeout=300, logEnviron=False) + 0
+            + ExpectShell.log('stdio', stdout=''),
+            ExpectShell(command=['git', 'checkout', 'origin/main', '-f'], workdir='wkdir', timeout=300, logEnviron=False) + 0
+            + ExpectShell.log('stdio', stdout='You are in detached HEAD state.'),
+            ExpectShell(command=['git', 'branch', '-D', 'main'], workdir='wkdir', timeout=300, logEnviron=False) + 0
+            + ExpectShell.log('stdio', stdout='Deleted branch main (was 57015967fef9).'),
+            ExpectShell(command=['git', 'checkout', 'origin/main', '-b', 'main'], workdir='wkdir', timeout=300, 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_success_master(self):
+        self.setupStep(CleanGitRepo(default_branch='master'))
         self.setProperty('buildername', 'Commit-Queue')
 
         self.expectRemoteCommands(
-            ExpectShell(command=['git', 'clean', '-f', '-d'], workdir='wkdir', timeout=1200, logEnviron=False) + 0
+            ExpectShell(command=['git', 'clean', '-f', '-d'], workdir='wkdir', timeout=300, logEnviron=False) + 0
             + ExpectShell.log('stdio', stdout=''),
-            ExpectShell(command=['git', 'fetch', 'origin'], workdir='wkdir', timeout=1200, logEnviron=False) + 0
+            ExpectShell(command=['git', 'fetch', 'origin'], workdir='wkdir', timeout=300, logEnviron=False) + 0
             + ExpectShell.log('stdio', stdout=''),
-            ExpectShell(command=['git', 'checkout', 'origin/master', '-f'], workdir='wkdir', timeout=1200, logEnviron=False) + 0
+            ExpectShell(command=['git', 'checkout', 'origin/master', '-f'], workdir='wkdir', timeout=300, logEnviron=False) + 0
             + ExpectShell.log('stdio', stdout='You are in detached HEAD state.'),
-            ExpectShell(command=['git', 'branch', '-D', 'master'], workdir='wkdir', timeout=1200, logEnviron=False) + 0
+            ExpectShell(command=['git', 'branch', '-D', 'master'], workdir='wkdir', timeout=300, logEnviron=False) + 0
             + ExpectShell.log('stdio', stdout='Deleted branch master (was 57015967fef9).'),
-            ExpectShell(command=['git', 'checkout', 'origin/master', '-b', 'master'], workdir='wkdir', timeout=1200, logEnviron=False) + 0
+            ExpectShell(command=['git', 'checkout', 'origin/master', '-b', 'master'], workdir='wkdir', timeout=300, logEnviron=False) + 0
             + ExpectShell.log('stdio', stdout="Switched to a new branch 'master'"),
         )
         self.expectOutcome(result=SUCCESS, state_string='Cleaned up git repository')
@@ -4352,21 +4371,40 @@
         self.setProperty('buildername', 'Commit-Queue')
 
         self.expectRemoteCommands(
-            ExpectShell(command=['git', 'clean', '-f', '-d'], workdir='wkdir', timeout=1200, logEnviron=False) + 0
+            ExpectShell(command=['git', 'clean', '-f', '-d'], workdir='wkdir', timeout=300, logEnviron=False) + 0
             + ExpectShell.log('stdio', stdout=''),
-            ExpectShell(command=['git', 'fetch', 'origin'], workdir='wkdir', timeout=1200, logEnviron=False) + 128
+            ExpectShell(command=['git', 'fetch', 'origin'], workdir='wkdir', timeout=300, 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/master', '-f'], workdir='wkdir', timeout=1200, logEnviron=False) + 0
+            ExpectShell(command=['git', 'checkout', 'origin/main', '-f'], workdir='wkdir', timeout=300, logEnviron=False) + 0
             + ExpectShell.log('stdio', stdout='You are in detached HEAD state.'),
-            ExpectShell(command=['git', 'branch', '-D', 'master'], workdir='wkdir', timeout=1200, logEnviron=False) + 0
-            + ExpectShell.log('stdio', stdout='Deleted branch master (was 57015967fef9).'),
-            ExpectShell(command=['git', 'checkout', 'origin/master', '-b', 'master'], workdir='wkdir', timeout=1200, logEnviron=False) + 0
-            + ExpectShell.log('stdio', stdout="Switched to a new branch 'master'"),
+            ExpectShell(command=['git', 'branch', '-D', 'main'], workdir='wkdir', timeout=300, logEnviron=False) + 0
+            + ExpectShell.log('stdio', stdout='Deleted branch main (was 57015967fef9).'),
+            ExpectShell(command=['git', 'checkout', 'origin/main', '-b', 'main'], workdir='wkdir', timeout=300, 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()
 
+    def test_branch(self):
+        self.setupStep(CleanGitRepo())
+        self.setProperty('buildername', 'Commit-Queue')
+        self.setProperty('basename', 'safari-612-branch')
 
+        self.expectRemoteCommands(
+            ExpectShell(command=['git', 'clean', '-f', '-d'], workdir='wkdir', timeout=300, logEnviron=False) + 0
+            + ExpectShell.log('stdio', stdout=''),
+            ExpectShell(command=['git', 'fetch', 'origin'], workdir='wkdir', timeout=300, logEnviron=False) + 0
+            + ExpectShell.log('stdio', stdout=''),
+            ExpectShell(command=['git', 'checkout', 'origin/safari-612-branch', '-f'], workdir='wkdir', timeout=300, logEnviron=False) + 0
+            + ExpectShell.log('stdio', stdout='You are in detached HEAD state.'),
+            ExpectShell(command=['git', 'branch', '-D', 'safari-612-branch'], workdir='wkdir', timeout=300, logEnviron=False) + 0
+            + ExpectShell.log('stdio', stdout='Deleted branch safari-612-branch (was 57015967fef9).'),
+            ExpectShell(command=['git', 'checkout', 'origin/safari-612-branch', '-b', 'safari-612-branch'], workdir='wkdir', timeout=300, logEnviron=False) + 0
+            + ExpectShell.log('stdio', stdout="Switched to a new branch 'safari-612-branch'"),
+        )
+        self.expectOutcome(result=SUCCESS, state_string='Cleaned up git repository')
+        return self.runStep()
+
 class TestFindModifiedChangeLogs(BuildStepMixinAdditions, unittest.TestCase):
     def setUp(self):
         self.longMessage = True

Modified: trunk/Tools/ChangeLog (287856 => 287857)


--- trunk/Tools/ChangeLog	2022-01-10 21:57:16 UTC (rev 287856)
+++ trunk/Tools/ChangeLog	2022-01-10 22:18:11 UTC (rev 287857)
@@ -1,3 +1,24 @@
+2022-01-05  Jonathan Bedard  <[email protected]>
+
+        [EWS] Always invoke CleanGitRepo before CheckOutSource
+        https://bugs.webkit.org/show_bug.cgi?id=234882
+        <rdar://problem/87145396>
+
+        Reviewed by Aakash Jain.
+
+        * CISupport/ews-build/factories.py:
+        (Factory.__init__): Add CleanGitRepo step.
+        (StyleFactory.__init__): Ditto.
+        (WatchListFactory.__init__): Ditto.
+        (CommitQueueFactory.__init__): Specify default branch as 'master.'
+        * CISupport/ews-build/factories_unittest.py:
+        (TestExpectedBuildSteps):
+        * CISupport/ews-build/steps.py:
+        (CleanGitRepo.__init__): Accept default_branch and remote.
+        (CleanGitRepo.run): Construct commands with awareness of branch and remote,
+        check to see if a basename is specified.
+        * CISupport/ews-build/steps_unittest.py:
+
 2021-12-17  Jonathan Bedard  <[email protected]>
 
         [git-webkit] Retain old commits in pull-request
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to