feat(preprod): Add snapshot PR comment task and wiring#112360
feat(preprod): Add snapshot PR comment task and wiring#112360runningcode merged 5 commits intomasterfrom
Conversation
Add Celery task that posts/updates GitHub PR comments for snapshot comparisons. Follows the same pattern as build distribution PR comments: locks CommitComparison rows, finds existing comment across PR commits, creates or updates via GitHub API, stores comment_id in extras["pr_comments"]["snapshots"]. Wire the task into all snapshot trigger points: - Comparison completion/failure in snapshots/tasks.py - Upload completion in snapshot endpoint - Approval via API and GitHub check run webhook - Rerun status checks endpoint
e4b7c04 to
b7ff5d8
Compare
Parameterize _find_existing_comment_id and _save_pr_comment_result by comment_type so both build_distribution and snapshots tasks use the same logic instead of maintaining near-identical copies.
|
|
||
| api_error: Exception | None = None | ||
|
|
||
| with transaction.atomic(router.db_for_write(CommitComparison)): |
There was a problem hiding this comment.
we lock here on the commit comparison. this is the same as what we do for build distirbution comments.
| # update_comment instead of creating a duplicate. | ||
| if not comment_id: | ||
| existing = extras.get("pr_comments", {}).get("build_distribution", {}) | ||
| existing = extras.get("pr_comments", {}).get(comment_type, {}) |
There was a problem hiding this comment.
we store the pr comment id in CommitComparison.extras, with keys build_distribution and snapshots for those respective features.
Adds a manual trigger script for testing snapshot PR comments locally, mirroring the existing trigger_pr_comment and trigger_snapshot_status_check scripts.
| @@ -0,0 +1,396 @@ | |||
| #!/usr/bin/env python | |||
There was a problem hiding this comment.
This is the script I used to test this. Similar to the other test scripts in this directory.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 89cd881. Configure here.
Remove single-line wrapper functions _find_existing_comment_id and _save_pr_comment_result, inlining the calls with the hardcoded "build_distribution" argument directly at the call sites. Rename _build_changes_map to build_changes_map and move it (along with its helper _comparison_has_changes) from the status_checks snapshots tasks module to sentry.preprod.snapshots.utils, since it is now shared across multiple production modules.
|
PR reverted: 811e6cc |
…)" This reverts commit 5cd53c6. Co-authored-by: vgrozdanic <26199428+vgrozdanic@users.noreply.github.com>
|
Reverted because it broke the CI, not sure why it wasn't caught during CI tests on this PR 🤔 |
)" This reverts commit 811e6cc.

Add Celery task that posts/updates GitHub PR comments for snapshot comparisons, and wire it into all existing trigger points.
Task (
snapshot_tasks.py): Follows the build distribution PR comment pattern — locks CommitComparison rows to prevent duplicates, finds existing comments across PR commits, creates or updates via GitHub API, stores comment_id inextras["pr_comments"]["snapshots"]. Gated by feature flagorganizations:preprod-snapshot-pr-commentsand project optionsentry:preprod_snapshot_pr_comments_enabled(both already registered).Wiring: Triggered alongside the snapshot status check task at five entry points:
snapshots/tasks.py)preprod_artifact_snapshot.py)preprod_artifact_approve.py)github_check_run.py)preprod_artifact_rerun_status_checks.py)I might have missed something so let me know if this should be added somewhere else!
Here's what this looks like using the test script: link

Depends on #112353.
Refs EME-999