Skip to content

Commit 2f4ffa0

Browse files
committed
Migrate Seer handlers for code reviews to SCM listeners
1 parent 1edbdf8 commit 2f4ffa0

File tree

11 files changed

+441
-478
lines changed

11 files changed

+441
-478
lines changed

src/sentry/integrations/github/webhook.py

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,6 @@
5959
from sentry.scm.private.stream_producer import produce_event_to_scm_stream
6060
from sentry.seer.autofix.webhooks import handle_github_pr_webhook_for_autofix
6161
from sentry.seer.code_review.contributor_seats import track_contributor_seat
62-
from sentry.seer.code_review.webhooks.handlers import (
63-
handle_webhook_event as code_review_handle_webhook_event,
64-
)
6562
from sentry.shared_integrations.exceptions import ApiError
6663
from sentry.silo.base import SiloMode
6764
from sentry.users.services.user.service import user_service
@@ -847,10 +844,7 @@ class PullRequestEventWebhook(GitHubWebhook):
847844
"""https://developer.github.com/v3/activity/events/types/#pullrequestevent"""
848845

849846
EVENT_TYPE = IntegrationWebhookEventType.MERGE_REQUEST
850-
WEBHOOK_EVENT_PROCESSORS = (
851-
_handle_pr_webhook_for_autofix_processor,
852-
code_review_handle_webhook_event,
853-
)
847+
WEBHOOK_EVENT_PROCESSORS = (_handle_pr_webhook_for_autofix_processor,)
854848

855849
def _handle(
856850
self,
@@ -976,10 +970,7 @@ class CheckRunEventWebhook(GitHubWebhook):
976970
"""
977971

978972
EVENT_TYPE = IntegrationWebhookEventType.CI_CHECK
979-
WEBHOOK_EVENT_PROCESSORS = (
980-
code_review_handle_webhook_event,
981-
handle_preprod_check_run_event,
982-
)
973+
WEBHOOK_EVENT_PROCESSORS = (handle_preprod_check_run_event,)
983974

984975

985976
class IssueCommentEventWebhook(GitHubWebhook):
@@ -989,7 +980,7 @@ class IssueCommentEventWebhook(GitHubWebhook):
989980
"""
990981

991982
EVENT_TYPE = IntegrationWebhookEventType.ISSUE_COMMENT
992-
WEBHOOK_EVENT_PROCESSORS = (code_review_handle_webhook_event,)
983+
WEBHOOK_EVENT_PROCESSORS = ()
993984

994985

995986
@all_silo_endpoint
@@ -1150,7 +1141,7 @@ def handle(self, request: HttpRequest) -> HttpResponse:
11501141
{
11511142
"event_type_hint": request.headers.get(GITHUB_WEBHOOK_TYPE_HEADER_KEY),
11521143
"event": request.body.decode("utf-8"),
1153-
"extra": {},
1144+
"extra": {"github_delivery_id": github_delivery_id},
11541145
"received_at": int(time.time()),
11551146
"sentry_meta": None,
11561147
"type": IntegrationProviderSlug.GITHUB.value,

src/sentry/scm/stream.py

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# Example:
66
#
77
# from sentry.my_module import check_run_listener, pull_request_listener
8+
import sentry.seer.code_review.webhooks.scm_listeners # noqa: F401 - registers listeners on import
89
from sentry.scm.private.event_stream import scm_event_stream
910
from sentry.scm.types import (
1011
CheckRunEvent,
@@ -14,26 +15,6 @@
1415
SubscriptionEvent,
1516
)
1617

17-
# DEFAULT LISTENERS
18-
#
19-
# TODO: Remove after production testing.
20-
21-
22-
@scm_event_stream.listen_for(event_type="check_run")
23-
def listen_for_check_run(e):
24-
return None
25-
26-
27-
@scm_event_stream.listen_for(event_type="comment")
28-
def listen_for_comment(e):
29-
return None
30-
31-
32-
@scm_event_stream.listen_for(event_type="pull_request")
33-
def listen_for_pull_request(e):
34-
return None
35-
36-
3718
# Do not re-export your listener here.
3819
__all__ = [
3920
"scm_event_stream",
Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +0,0 @@
1-
"""
2-
This module provides a single entry point for the webhook handler to handle webhook events.
3-
"""
4-
5-
from .handlers import handle_webhook_event as code_review_webhook_processor
6-
7-
__all__ = ["code_review_webhook_processor"]

src/sentry/seer/code_review/webhooks/handlers.py

Lines changed: 0 additions & 134 deletions
This file was deleted.

0 commit comments

Comments
 (0)