Skip to content

Support WANT_LGTM-only repositories via decoupled webhook routing - #5237

Open
jtmcdole wants to merge 2 commits into
flutter:mainfrom
jtmcdole:want-lgtm-only-repos
Open

jtmcdole wants to merge 2 commits into
flutter:mainfrom
jtmcdole:want-lgtm-only-repos

Conversation

@jtmcdole

@jtmcdole jtmcdole commented Dec 4, 2026 •

Copy link
Copy Markdown
Member

What I'm trying to do: enable WANT_LGTM on repositories that don't have CICD. Cocoon's "supportedRepos" are for cicd / merge queue / luci scheduling. So this hoists it out as a first-class citizen.

--- ai summary follows.

Summary

Allow repositories such as flutter/rfc to enable WANT_LGTM merge blocking without onboarding to .ci.yaml, LUCI, GoB, or PullRequestManager.

The dynamic ciEnabledRepos configuration and useForAllRepos removal were split into a separate PR (#5238) to keep this change focused on webhook routing and retry idempotency. Both PRs are independent and can merge in either order.

This PR is organized into two atomic commits:

  1. want_lgtm: keep reopened check run reconciliation idempotent on retry

    • Only forces check run recreation on pull_request reopened when the stored state is a completed neutral waiver (such as the pre-close waiver), preventing duplicate check runs on Pub/Sub retries.
  2. webhooks: fork CI and WANT_LGTM routing and return 200 OK for unconfigured repos

    • Decouples WANT_LGTM reconciliation from PullRequestManager onto a dedicated lowercased want_lgtm_lock_<owner>_<repo>_<pr> Redis lock key, with a success-gated 7-day want_lgtm_done:<messageId> cache marker on CI paths so CI retries cannot replay stale PR payloads over newer WANT_LGTM state.
    • Forks CI and WANT_LGTM routing in GithubWebhookSubscription across pull_request, pull_request_review, check_run, merge_group, issues, create, and workflow_job so non-CI repositories skip .ci.yaml, LUCI, GoB, and PullRequestState.
    • Returns HTTP 200 OK (with log.warn) instead of HTTP 500 for unconfigured repositories to avoid seven-day Pub/Sub retry storms on per-repo rollback, while preserving Firestore self-healing waivers for open in_progress check runs.
    • Gates GithubWebhook Firestore merge_group archiving on config.supportedRepos so non-CI merge queue events do not enter MergeQueueHooks.

Rollout Notes

  • Keep wantLgtm.enabled: false until this binary rolls out (so no N-1 instance shares pr_lock with want_lgtm_lock).
  • Before adding flutter/rfc to wantLgtm.enabledRepos in app_dart/config.yaml, land Drive Config.supportedRepos from dynamic ciEnabledRepos and remove useForAllRepos #5238, add "flutter/rfc" to APP_DART_GITHUBAPP_INSTALLATIONS, flush via /api/flush-cache?key=APP_DART_GITHUBAPP_INSTALLATIONS, and install the Cocoon GitHub App on flutter/rfc.

Testing

  • dart format --output=none --set-exit-if-changed app_dart/lib/ app_dart/test/ packages/cocoon_integration_test/lib/: 0 diffs.
  • dart analyze --fatal-infos (app_dart, packages/cocoon_integration_test): 0 issues.
  • dart test in app_dart: 1,278/1,278 passed.
  • dart test in packages/cocoon_integration_test: 49/49 passed.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces dynamic configuration for CI-enabled repositories, replacing hardcoded repository lists with a configurable ciEnabledRepos set. It refactors GithubWebhookSubscription to decouple WANT_LGTM reconciliation from CI-enabled repositories, allowing for more flexible repository routing. Additionally, it improves the robustness of the webhook handlers and optimizes lock acquisition for WANT_LGTM reconciliation. The reviewer suggests further optimizations to lock acquisition in _handleWantLgtmPullRequest and _handleCreate to reduce overhead, and recommends adding error handling to _handleCreate to prevent potential 500 errors from malformed payloads.

Only force check run recreation on pull_request reopened when the stored
state is a completed neutral waiver (such as the pre-close waiver), so
Pub/Sub retries of reopened webhooks do not create duplicate check runs.
@jtmcdole jtmcdole changed the title Support WANT_LGTM-only repositories via dynamic ciEnabledRepos and decoupled webhook routing Support WANT_LGTM-only repositories via decoupled webhook routing Dec 4, 2026
@jtmcdole
jtmcdole force-pushed the want-lgtm-only-repos branch 8 times, most recently from 5daee58 to bf492a6 Compare December 4, 2026 22:35
…gured repos

Decouple WANT_LGTM reconciliation from PullRequestManager onto a
dedicated want_lgtm_lock key so non-CI repositories such as flutter/rfc
can run WANT_LGTM without .ci.yaml, LUCI, GoB, or PullRequestState
overhead.

Gate CI-only handlers (issues, create, workflow_job, non-WANT_LGTM
check_run, merge_group GoB/scheduler, and GithubWebhook Firestore
merge_group archiving) on Config.supportedRepos, and return 200 OK with
a warning log instead of HTTP 500 for unconfigured repositories.
@jtmcdole
jtmcdole force-pushed the want-lgtm-only-repos branch from bf492a6 to 79a101a Compare December 4, 2026 22:44
@jtmcdole
jtmcdole marked this pull request as ready for review December 4, 2026 22:46
@jtmcdole jtmcdole added the CICD Run CI/CD label Dec 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant