Title: [293557] trunk
Revision
293557
Author
jbed...@apple.com
Date
2022-04-27 20:03:33 -0700 (Wed, 27 Apr 2022)

Log Message

[git-webkit] Run style checker
https://bugs.webkit.org/show_bug.cgi?id=239730
<rdar://problem/92428565>

Reviewed by Chris Dumez.

* Tools/Scripts/libraries/webkitscmpy/setup.py: Bump version.
* Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py: Ditto.
* Tools/Scripts/libraries/webkitscmpy/webkitscmpy/local/git.py:
(Git): Add webkitscmpy.auto-check option.
* Tools/Scripts/libraries/webkitscmpy/webkitscmpy/program/pull_request.py:
(PullRequest.parser): Add --check/--no-check flag.
(PullRequest.pre_pr_checks): Find and run all pre-PR checks.
(PullRequest.create_pull_request): Run PR checks.
* Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/pull_request_unittest.py:
* Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/revert_unittest.py:
* metadata/git_config_extension: Add style-checker as pre-pr check.

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

Modified Paths

Diff

Modified: trunk/ChangeLog (293556 => 293557)


--- trunk/ChangeLog	2022-04-28 02:46:27 UTC (rev 293556)
+++ trunk/ChangeLog	2022-04-28 03:03:33 UTC (rev 293557)
@@ -1,3 +1,13 @@
+2022-04-27  Jonathan Bedard  <jbed...@apple.com>
+
+        [git-webkit] Run style checker
+        https://bugs.webkit.org/show_bug.cgi?id=239730
+        <rdar://problem/92428565>
+
+        Reviewed by Chris Dumez.
+
+        * metadata/git_config_extension: Add style-checker as pre-pr check.
+
 2022-04-26  Michael Catanzaro  <mcatanz...@redhat.com>
 
         Unreviewed, add my @redhat.com email

Modified: trunk/Tools/ChangeLog (293556 => 293557)


--- trunk/Tools/ChangeLog	2022-04-28 02:46:27 UTC (rev 293556)
+++ trunk/Tools/ChangeLog	2022-04-28 03:03:33 UTC (rev 293557)
@@ -1,5 +1,24 @@
 2022-04-27  Jonathan Bedard  <jbed...@apple.com>
 
+        [git-webkit] Run style checker
+        https://bugs.webkit.org/show_bug.cgi?id=239730
+        <rdar://problem/92428565>
+
+        Reviewed by Chris Dumez.
+
+        * Scripts/libraries/webkitscmpy/setup.py: Bump version.
+        * Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py: Ditto.
+        * Scripts/libraries/webkitscmpy/webkitscmpy/local/git.py:
+        (Git): Add webkitscmpy.auto-check option.
+        * Scripts/libraries/webkitscmpy/webkitscmpy/program/pull_request.py:
+        (PullRequest.parser): Add --check/--no-check flag.
+        (PullRequest.pre_pr_checks): Find and run all pre-PR checks.
+        (PullRequest.create_pull_request): Run PR checks.
+        * Scripts/libraries/webkitscmpy/webkitscmpy/test/pull_request_unittest.py:
+        * Scripts/libraries/webkitscmpy/webkitscmpy/test/revert_unittest.py:
+
+2022-04-27  Jonathan Bedard  <jbed...@apple.com>
+
         [git-webkit] Cleanup PRs on alternate remotes
         https://bugs.webkit.org/show_bug.cgi?id=239814
         <rdar://problem/92410887>

Modified: trunk/Tools/Scripts/libraries/webkitscmpy/setup.py (293556 => 293557)


--- trunk/Tools/Scripts/libraries/webkitscmpy/setup.py	2022-04-28 02:46:27 UTC (rev 293556)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/setup.py	2022-04-28 03:03:33 UTC (rev 293557)
@@ -29,7 +29,7 @@
 
 setup(
     name='webkitscmpy',
-    version='4.11.4',
+    version='4.12.0',
     description='Library designed to interact with git and svn repositories.',
     long_description=readme(),
     classifiers=[

Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py (293556 => 293557)


--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py	2022-04-28 02:46:27 UTC (rev 293556)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py	2022-04-28 03:03:33 UTC (rev 293557)
@@ -46,7 +46,7 @@
         "Please install webkitcorepy with `pip install webkitcorepy --extra-index-url <package index URL>`"
     )
 
-version = Version(4, 11, 4)
+version = Version(4, 12, 0)
 
 AutoInstall.register(Package('fasteners', Version(0, 15, 0)))
 AutoInstall.register(Package('jinja2', Version(2, 11, 3)))

Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/local/git.py (293556 => 293557)


--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/local/git.py	2022-04-28 02:46:27 UTC (rev 293556)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/local/git.py	2022-04-28 03:03:33 UTC (rev 293557)
@@ -308,6 +308,7 @@
         'webkitscmpy.pull-request': ['overwrite', 'append'],
         'webkitscmpy.history': ['when-user-owned', 'disabled', 'always', 'never'],
         'webkitscmpy.update-fork': ['true', 'false'],
+        'webkitscmpy.auto-check': ['true', 'false'],
     }
     CONFIG_LOCATIONS = ['global', 'repository', 'project']
 

Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/program/pull_request.py (293556 => 293557)


--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/program/pull_request.py	2022-04-28 02:46:27 UTC (rev 293556)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/program/pull_request.py	2022-04-28 03:03:33 UTC (rev 293557)
@@ -81,6 +81,12 @@
             '--remote', dest='remote', type=str, default=None,
             help='Make a pull request against a specific remote',
         )
+        parser.add_argument(
+            '--checks', '--no-checks',
+            dest='checks', default=None,
+            help='Explicitly enable or disable automatic pre-flight checks',
+            action=""
+        )
 
     @classmethod
     def create_commit(cls, args, repository, **kwargs):
@@ -173,8 +179,37 @@
         return existing_pr
 
     @classmethod
+    def pre_pr_checks(cls, repository):
+        num_checks = 0
+        log.info('Running pre-PR checks...')
+        for key, path in repository.config().items():
+            if not key.startswith('webkitscmpy.pre-pr.'):
+                continue
+            num_checks += 1
+            name = key.split('.')[-1]
+            log.info('    Running {}...'.format(name))
+            command = run(path.split(' '), cwd=repository.root_path)
+            if command.returncode:
+                if Terminal.choose(
+                    '{} failed, continue uploading pull request?'.format(name),
+                    default='No',
+                ) == 'No':
+                    sys.stderr.write('Pre-PR check {} failed\n'.format(name))
+                    return False
+                else:
+                    log.info('    {} failed, continuing PR upload anyway'.format(name))
+            else:
+                log.info('    Ran {}!'.format(name))
+
+        if num_checks:
+            log.info('All pre-PR checks run!')
+        else:
+            log.info('No pre-PR checks to run')
+        return True
+
+    @classmethod
     def create_pull_request(cls, repository, args, branch_point):
-        # FIXME: We can do better by infering the remote from the branch point, if it's not specified
+        # FIXME: We can do better by inferring the remote from the branch point, if it's not specified
         source_remote = args.remote or 'origin'
         if not repository.config().get('remote.{}.url'.format(source_remote)):
             sys.stderr.write("'{}' is not a remote in this repository\n".format(source_remote))
@@ -191,6 +226,12 @@
         else:
             branch_point = Branch.branch_point(repository)
 
+        if args.checks is None:
+            args.checks = repository.config().get('webkitscmpy.auto-check', 'false') == 'true'
+        if args.checks and not cls.pre_pr_checks(repository):
+            sys.stderr.write('Checks have failed, aborting pull request.\n')
+            return 1
+
         remote_repo = repository.remote(name=source_remote)
         if not remote_repo:
             sys.stderr.write("'{}' doesn't have a recognized remote\n".format(repository.root_path))

Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/pull_request_unittest.py (293556 => 293557)


--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/pull_request_unittest.py	2022-04-28 02:46:27 UTC (rev 293556)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/pull_request_unittest.py	2022-04-28 03:03:33 UTC (rev 293557)
@@ -301,7 +301,9 @@
 Creating commit...
 Rebasing 'eng/pr-branch' on 'main'...
 Rebased 'eng/pr-branch' on 'main!'
-    Found 1 commit...""")
+    Found 1 commit...
+Running pre-PR checks...
+No pre-PR checks to run""")
         self.assertEqual(captured.stdout.getvalue(), "Created the local development branch 'eng/pr-branch'\n")
         self.assertEqual(captured.stderr.getvalue(), "'{}' doesn't have a recognized remote\n".format(self.path))
 
@@ -325,7 +327,9 @@
 Creating commit...
 Rebasing 'eng/pr-branch' on 'main'...
 Rebased 'eng/pr-branch' on 'main!'
-    Found 1 commit...""")
+    Found 1 commit...
+Running pre-PR checks...
+No pre-PR checks to run""")
 
     def test_github(self):
         with OutputCapture(level=logging.INFO) as captured, mocks.remote.GitHub() as remote, mocks.local.Git(
@@ -356,6 +360,8 @@
                 "Rebasing 'eng/pr-branch' on 'main'...",
                 "Rebased 'eng/pr-branch' on 'main!'",
                 "    Found 1 commit...",
+                'Running pre-PR checks...',
+                'No pre-PR checks to run',
                 "Pushing 'eng/pr-branch' to 'fork'...",
                 "Syncing 'main' to remote 'fork'",
                 "Creating pull-request for 'eng/pr-branch'...",
@@ -391,6 +397,8 @@
                 "Rebasing 'eng/pr-branch' on 'main'...",
                 "Rebased 'eng/pr-branch' on 'main!'",
                 "    Found 1 commit...",
+                'Running pre-PR checks...',
+                'No pre-PR checks to run',
                 "Pushing 'eng/pr-branch' to 'fork'...",
                 "Syncing 'main' to remote 'fork'",
                 "Creating pull-request for 'eng/pr-branch'...",
@@ -438,6 +446,8 @@
                 "Rebasing 'eng/pr-branch' on 'main'...",
                 "Rebased 'eng/pr-branch' on 'main!'",
                 "    Found 1 commit...",
+                'Running pre-PR checks...',
+                'No pre-PR checks to run',
                 "Checking PR labels for 'merging-blocked'...",
                 "Removing 'merging-blocked' from PR 1...",
                 "Pushing 'eng/pr-branch' to 'fork'...",
@@ -480,6 +490,8 @@
                 "Rebased 'eng/pr-branch' on 'main!'",
                 '    Found 1 commit...',
                 '    Found 2 commits...',
+                'Running pre-PR checks...',
+                'No pre-PR checks to run',
                 "Checking PR labels for 'merging-blocked'...",
                 "Pushing 'eng/pr-branch' to 'fork'...",
                 "Syncing 'main' to remote 'fork'",
@@ -527,6 +539,8 @@
                 "Rebasing 'eng/pr-branch' on 'main'...",
                 "Rebased 'eng/pr-branch' on 'main!'",
                 "    Found 1 commit...",
+                'Running pre-PR checks...',
+                'No pre-PR checks to run',
                 "Checking PR labels for 'merging-blocked'...",
                 "Pushing 'eng/pr-branch' to 'fork'...",
                 "Syncing 'main' to remote 'fork'",
@@ -586,6 +600,8 @@
                 "Rebasing 'eng/pr-branch' on 'main'...",
                 "Rebased 'eng/pr-branch' on 'main!'",
                 "    Found 1 commit...",
+                'Running pre-PR checks...',
+                'No pre-PR checks to run',
                 "Pushing 'eng/pr-branch' to 'fork'...",
                 "Syncing 'main' to remote 'fork'",
                 "Creating pull-request for 'eng/pr-branch'...",
@@ -645,6 +661,8 @@
                 "Rebasing 'eng/pr-branch' on 'main'...",
                 "Rebased 'eng/pr-branch' on 'main!'",
                 "    Found 1 commit...",
+                'Running pre-PR checks...',
+                'No pre-PR checks to run',
                 "Pushing 'eng/pr-branch' to 'fork'...",
                 "Syncing 'main' to remote 'fork'",
                 "Creating pull-request for 'eng/pr-branch'...",
@@ -683,6 +701,8 @@
                 "Rebasing 'eng/pr-branch' on 'main'...",
                 "Rebased 'eng/pr-branch' on 'main!'",
                 "    Found 1 commit...",
+                'Running pre-PR checks...',
+                'No pre-PR checks to run',
                 "Pushing 'eng/pr-branch' to 'origin'...",
                 "Creating pull-request for 'eng/pr-branch'...",
             ],
@@ -716,6 +736,8 @@
                 "Rebasing 'eng/pr-branch' on 'main'...",
                 "Rebased 'eng/pr-branch' on 'main!'",
                 "    Found 1 commit...",
+                'Running pre-PR checks...',
+                'No pre-PR checks to run',
                 "Pushing 'eng/pr-branch' to 'origin'...",
             ],
         )
@@ -752,6 +774,8 @@
                 "Rebasing 'eng/pr-branch' on 'main'...",
                 "Rebased 'eng/pr-branch' on 'main!'",
                 "    Found 1 commit...",
+                'Running pre-PR checks...',
+                'No pre-PR checks to run',
                 "Pushing 'eng/pr-branch' to 'origin'...",
                 "Updating pull-request for 'eng/pr-branch'...",
             ],
@@ -790,6 +814,8 @@
                 "Rebased 'eng/pr-branch' on 'main!'",
                 '    Found 1 commit...',
                 '    Found 2 commits...',
+                'Running pre-PR checks...',
+                'No pre-PR checks to run',
                 "Pushing 'eng/pr-branch' to 'origin'...",
                 "Updating pull-request for 'eng/pr-branch'...",
             ],
@@ -834,6 +860,8 @@
                 "Rebasing 'eng/pr-branch' on 'main'...",
                 "Rebased 'eng/pr-branch' on 'main!'",
                 "    Found 1 commit...",
+                'Running pre-PR checks...',
+                'No pre-PR checks to run',
                 "Pushing 'eng/pr-branch' to 'origin'...",
                 "Updating pull-request for 'eng/pr-branch'...",
             ],
@@ -878,6 +906,8 @@
                 "Rebasing 'eng/pr-branch' on 'main'...",
                 "Rebased 'eng/pr-branch' on 'main!'",
                 "    Found 1 commit...",
+                'Running pre-PR checks...',
+                'No pre-PR checks to run',
                 "Pushing 'eng/pr-branch' to 'origin'...",
                 "Creating pull-request for 'eng/pr-branch'...",
                 'Checking issue assignee...',
@@ -925,6 +955,8 @@
                 "Rebasing 'eng/pr-branch' on 'main'...",
                 "Rebased 'eng/pr-branch' on 'main!'",
                 "    Found 1 commit...",
+                'Running pre-PR checks...',
+                'No pre-PR checks to run',
                 "Pushing 'eng/pr-branch' to 'origin'...",
                 "Creating pull-request for 'eng/pr-branch'...",
                 'Checking issue assignee...',

Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/revert_unittest.py (293556 => 293557)


--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/revert_unittest.py	2022-04-28 02:46:27 UTC (rev 293556)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/revert_unittest.py	2022-04-28 03:03:33 UTC (rev 293557)
@@ -72,6 +72,8 @@
                 "Rebasing 'eng/pr-branch' on 'main'...",
                 "Rebased 'eng/pr-branch' on 'main!'",
                 "    Found 1 commit...",
+                'Running pre-PR checks...',
+                'No pre-PR checks to run',
                 "Pushing 'eng/pr-branch' to 'fork'...",
                 "Syncing 'main' to remote 'fork'",
                 "Creating pull-request for 'eng/pr-branch'...",
@@ -104,6 +106,7 @@
         self.assertEqual(captured.stderr.getvalue(), 'Please commit your changes or stash them before you revert commit: d8bce26fa65c6fc8f39c17927abb77f69fab82fc')
 
     def test_update(self):
+        self.maxDiff = None
         with OutputCapture(level=logging.INFO) as captured, mocks.remote.GitHub() as remote, mocks.local.Git(
             self.path, remote='https://{}'.format(remote.remote),
             remotes=dict(fork='https://{}/Contributor/WebKit'.format(remote.hosts[0])),
@@ -138,6 +141,8 @@
                 "Rebasing 'eng/pr-branch' on 'main'...",
                 "Rebased 'eng/pr-branch' on 'main!'",
                 "    Found 1 commit...",
+                'Running pre-PR checks...',
+                'No pre-PR checks to run',
                 "Pushing 'eng/pr-branch' to 'fork'...",
                 "Syncing 'main' to remote 'fork'",
                 "Creating 'eng/pr-branch-1' as a reference branch",
@@ -148,6 +153,8 @@
                 "Rebasing 'eng/pr-branch' on 'main'...",
                 "Rebased 'eng/pr-branch' on 'main!'",
                 '    Found 1 commit...',
+                'Running pre-PR checks...',
+                'No pre-PR checks to run',
                 "Checking PR labels for 'merging-blocked'...",
                 "Pushing 'eng/pr-branch' to 'fork'...",
                 "Syncing 'main' to remote 'fork'",

Modified: trunk/metadata/git_config_extension (293556 => 293557)


--- trunk/metadata/git_config_extension	2022-04-28 02:46:27 UTC (rev 293556)
+++ trunk/metadata/git_config_extension	2022-04-28 03:03:33 UTC (rev 293557)
@@ -4,6 +4,9 @@
         pull-request = append
         history = disabled
         update-fork = true
+        auto-check = true
 [webkitscmpy "remotes"]
         origin = g...@github.com:WebKit/WebKit.git
         apple = g...@github.com:apple/WebKit.git
+[webkitscmpy "pre-pr"]
+        style-checker = python3 Tools/Scripts/check-webkit-style
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to