Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions scripts/reviewer_bot_core/reconcile_replay_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@
from dataclasses import dataclass


@dataclass(frozen=True)
class ObserverNoopDecision:
source_event_key: str
reason: str


@dataclass(frozen=True)
class CommentReplayDecision:
record_source_freshness: bool
Expand All @@ -38,10 +32,6 @@ class ReviewReplayDecision:
clear_gap: bool


def decide_observer_noop(*, source_event_key: str, reason: str) -> ObserverNoopDecision:
return ObserverNoopDecision(source_event_key=source_event_key, reason=reason)


def decide_comment_replay(
*,
comment_id: int,
Expand Down
3 changes: 1 addition & 2 deletions scripts/reviewer_bot_lib/overdue.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

from .config import TRANSITION_NOTICE_MARKER_PREFIX

_TRANSITION_NOTICE_FALLBACK_FIRST_LINE = "🔔 **Transition Period Ended**"
_TRANSITION_NOTICE_AUTHORS = {"github-actions[bot]", "guidelines-bot"}


Expand Down Expand Up @@ -133,7 +132,7 @@ def find_existing_transition_notice(bot, issue_number: int, transition_warning_s
continue
lines = body.splitlines()
first_line = lines[0].strip() if lines else ""
if first_line == marker or first_line == _TRANSITION_NOTICE_FALLBACK_FIRST_LINE:
if first_line == marker:
if first_match is None or created_dt < first_match[0]:
first_match = (created_dt, created_at)
if len(response) < 100:
Expand Down
45 changes: 2 additions & 43 deletions scripts/reviewer_bot_lib/reconcile.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@
DeferredCommentPayload,
DeferredCommentReplayContext,
DeferredReviewPayload,
ObserverNoopPayload,
_LegacyDeferredIssueCommentPayloadV2,
_LegacyDeferredReviewCommentPayloadV2,
build_deferred_comment_replay_context,
build_deferred_review_replay_context,
parse_deferred_context_payload,
Expand Down Expand Up @@ -68,9 +65,7 @@

DeferredArtifactIdentity = _reconcile_payloads.DeferredArtifactIdentity
DeferredReviewReplayContext = _reconcile_payloads.DeferredReviewReplayContext
_artifact_expected_name = _reconcile_payloads.artifact_expected_name
_artifact_expected_payload_name = _reconcile_payloads.artifact_expected_payload_name
ParsedWorkflowRunPayload = DeferredReviewPayload | DeferredCommentPayload | ObserverNoopPayload | _LegacyDeferredIssueCommentPayloadV2 | _LegacyDeferredReviewCommentPayloadV2
ParsedWorkflowRunPayload = DeferredReviewPayload | DeferredCommentPayload


@dataclass(frozen=True)
Expand Down Expand Up @@ -268,15 +263,7 @@ def _reconcile_deferred_comment(
pr_number = context.pr_number
_read_live_pr_replay_context(bot, pr_number)
source_freshness_eligible = context.source_freshness_eligible
source_classified = (
_classify_deferred_comment_payload(context.payload)
if isinstance(context.payload, DeferredCommentPayload)
else {
"comment_class": context.payload.comment_class,
"has_non_command_text": context.payload.has_non_command_text,
"command_count": 1,
}
)
source_classified = _classify_deferred_comment_payload(context.payload)

def replay_request(comment_context: LiveCommentReplayContext | None = None, *, comment_body: str = "") -> CommentEventRequest:
return build_replay_comment_event_request(
Expand Down Expand Up @@ -405,28 +392,6 @@ def record_artifact_invalid(problem: InvalidEventInput) -> bool:
return changed or reconciled_changed or gap_cleared_changed


def _handle_observer_noop_workflow_run(
bot: ReconcileWorkflowRuntimeContext,
state: dict,
review_data: dict,
parsed_payload: ObserverNoopPayload,
) -> bool:
del state, review_data
_reconcile_payloads.validate_triggering_run_identity(bot, parsed_payload.raw_payload)
decision = reconcile_replay_policy.decide_observer_noop(
source_event_key=parsed_payload.identity.source_event_key,
reason=parsed_payload.reason,
)
_log(
bot,
"info",
f"Observer workflow produced explicit no-op payload for {decision.source_event_key}: {decision.reason}",
source_event_key=decision.source_event_key,
reason=decision.reason,
)
return False


def _handle_issue_comment_workflow_run(
bot: ReconcileWorkflowRuntimeContext,
state: dict,
Expand Down Expand Up @@ -550,12 +515,6 @@ def _handle_review_dismissed_workflow_run(


def _workflow_run_handler_for_payload(parsed_payload: ParsedWorkflowRunPayload):
if isinstance(parsed_payload, ObserverNoopPayload):
return _handle_observer_noop_workflow_run
if isinstance(parsed_payload, _LegacyDeferredIssueCommentPayloadV2):
return _handle_issue_comment_workflow_run
if isinstance(parsed_payload, _LegacyDeferredReviewCommentPayloadV2):
return _handle_review_comment_workflow_run
entry = _WORKFLOW_RUN_HANDLER_MATRIX.get(
(
parsed_payload.identity.source_event_name,
Expand Down
Loading
Loading