Diff
Modified: trunk/Tools/ChangeLog (287187 => 287188)
--- trunk/Tools/ChangeLog 2021-12-17 16:01:25 UTC (rev 287187)
+++ trunk/Tools/ChangeLog 2021-12-17 16:02:45 UTC (rev 287188)
@@ -1,3 +1,19 @@
+2021-12-16 Jonathan Bedard <[email protected]>
+
+ [reporelaypy] Accept pull-request hooks
+ https://bugs.webkit.org/show_bug.cgi?id=234406
+ <rdar://problem/86598451>
+
+ Reviewed by Dewei Zhu.
+
+ * Scripts/libraries/reporelaypy/reporelaypy/__init__.py: Bump version.
+ * Scripts/libraries/reporelaypy/reporelaypy/hooks.py:
+ (HookProcessor):
+ (HookProcessor.is_valid): Check 'pull_request' hook format.
+ * Scripts/libraries/reporelaypy/reporelaypy/tests/hooks_unittest.py:
+ (HooksUnittest.test_pull_request):
+ * Scripts/libraries/reporelaypy/setup.py: Bump version.
+
2021-12-16 Carlos Alberto Lopez Perez <[email protected]>
[GTK][WPE] Don't ignore stderr when calling flatpak in update-webkitgtk-libs
Modified: trunk/Tools/Scripts/libraries/reporelaypy/reporelaypy/__init__.py (287187 => 287188)
--- trunk/Tools/Scripts/libraries/reporelaypy/reporelaypy/__init__.py 2021-12-17 16:01:25 UTC (rev 287187)
+++ trunk/Tools/Scripts/libraries/reporelaypy/reporelaypy/__init__.py 2021-12-17 16:02:45 UTC (rev 287188)
@@ -44,7 +44,7 @@
"Please install webkitcorepy with `pip install webkitcorepy --extra-index-url <package index URL>`"
)
-version = Version(0, 4, 0)
+version = Version(0, 4, 1)
import webkitflaskpy
Modified: trunk/Tools/Scripts/libraries/reporelaypy/reporelaypy/hooks.py (287187 => 287188)
--- trunk/Tools/Scripts/libraries/reporelaypy/reporelaypy/hooks.py 2021-12-17 16:01:25 UTC (rev 287187)
+++ trunk/Tools/Scripts/libraries/reporelaypy/reporelaypy/hooks.py 2021-12-17 16:02:45 UTC (rev 287188)
@@ -36,13 +36,17 @@
class HookProcessor(object):
INBOUND_KEY = 'inbound-hooks'
WORKER_HOOKS = 'worker-hooks'
- TYPES = ('push',)
+ TYPES = ('pull_request', 'push')
@classmethod
def is_valid(cls, type, data):
if type not in cls.TYPES or not isinstance(data, dict):
return False
- return type == 'push' and data.get('ref')
+ if type == 'push':
+ return bool(data.get('ref'))
+ if type == 'pull_request':
+ return bool(data.get('number')) and data.get('action') in ('edited', 'synchronize')
+ return True
def __init__(self, checkout, database=None, num_workers=1, worker_index=0, callbacks=None):
self.checkout = checkout
Modified: trunk/Tools/Scripts/libraries/reporelaypy/reporelaypy/tests/hooks_unittest.py (287187 => 287188)
--- trunk/Tools/Scripts/libraries/reporelaypy/reporelaypy/tests/hooks_unittest.py 2021-12-17 16:01:25 UTC (rev 287187)
+++ trunk/Tools/Scripts/libraries/reporelaypy/reporelaypy/tests/hooks_unittest.py 2021-12-17 16:02:45 UTC (rev 287188)
@@ -138,3 +138,36 @@
status='Unauthorized Hook',
message='HMAC verification failed failed',
))
+
+ @mock_app
+ def test_pull_request(self, app=None, client=None):
+ with OutputCapture() as captured, mocks.local.Git(self.path) as repo:
+ database = Database()
+ app.register_blueprint(HookReceiver(database=database, debug=True))
+
+ response = client.post(
+ '/hooks', headers={'X-GitHub-Event': 'pull_request'},
+ json=dict(action='', number=58),
+ )
+ self.assertEqual(response.status_code, 202)
+
+ def func(data):
+ print('action: {}'.format(data.get('action')))
+ print('number: {}'.format(data.get('number')))
+
+ processor = HookProcessor(
+ Checkout(path=self.path, url="" sentinal=False),
+ database=database,
+ callbacks=dict(pull_request=func),
+ )
+ processor.process_hooks()
+
+ response = client.get('/hooks')
+ self.assertEqual(response.status_code, 200)
+ self.assertEqual(response.json(), [])
+
+ self.assertEqual('', captured.stderr.getvalue())
+ self.assertEqual(
+ 'action: synchronize\nnumber: 58\n',
+ captured.stdout.getvalue(),
+ )
Modified: trunk/Tools/Scripts/libraries/reporelaypy/setup.py (287187 => 287188)
--- trunk/Tools/Scripts/libraries/reporelaypy/setup.py 2021-12-17 16:01:25 UTC (rev 287187)
+++ trunk/Tools/Scripts/libraries/reporelaypy/setup.py 2021-12-17 16:02:45 UTC (rev 287188)
@@ -30,7 +30,7 @@
setup(
name='reporelaypy',
- version='0.4.0',
+ version='0.4.1',
description='Library for visualizing, processing and storing test results.',
long_description=readme(),
classifiers=[