Repository navigation
feat(git): Vercel-style sticky PR/MR preview comments on deploys - #96
Merged
Merged
Conversation
Vercel-style: when a deployment for a branch with an open PR moves through created → succeeded/failed, we post or update a single sticky comment that always reflects the latest state. The comment is keyed by a hidden HTML marker so subsequent updates edit-in-place rather than spamming the PR with new comments. - New PrCommenter trait + GitPrCommenter impl that dispatches by provider type (GitHub via REST /repos/.../pulls + issue comments, GitLab via REST /merge_requests + notes). Sticky marker is per-(project, environment) so multiple Temps envs targeting the same PR each get their own comment. - New PrCommentListener: background task that subscribes to Job::DeploymentCreated / DeploymentSucceeded / DeploymentFailed and calls the commenter with the right phase. Self-contained — uses events the deployments crate already emits, so no wiring changes are needed in temps-deployments. - Graceful degradation: missing git connection, no open PR, or forbidden by provider (e.g. existing GitHub Apps without pull_requests:write) all log warn and return Ok. Deployments are never blocked by commenting failures. - 15 unit tests cover GitHub + GitLab create/edit/no-PR/403 paths via mockito. All temps-git tests pass (120/120).
Adds 8 integration tests for PrCommentListener::handle_job covering: - DeploymentCreated with/without branch (Started phase, skip) - DeploymentSucceeded with/without URL (Ready phase, skip) - DeploymentSucceeded with missing deployment row (no-op) - DeploymentFailed with branch (Failed phase) - Unrelated event (ignored) Uses Sea-ORM MockDatabase for the deployment lookups and a RecordingCommenter PrCommenter double to capture and assert the phases the listener produces. Brings temps-git test count to 128 (was 120), all passing. Adds the Unreleased CHANGELOG entry that the GitHub Actions check requires.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When a deployment for a branch with an open PR/MR moves through created → succeeded/failed, post or update a single sticky comment that reflects the latest state. The comment is keyed by a hidden HTML marker so subsequent updates edit in place rather than spam the PR with new comments.
PrCommentertrait +GitPrCommenterimpl that dispatches by provider type (GitHub via REST/repos/.../pulls+ issue comments, GitLab via REST/merge_requests+ notes). Sticky marker is per(project, environment)so multiple Temps envs targeting the same PR each get their own comment.PrCommentListenerbackground task: subscribes toJob::DeploymentCreated/DeploymentSucceeded/DeploymentFailedand calls the commenter with the right phase. Self-contained — uses events the deployments crate already emits, so no wiring changes are needed in temps-deployments.pull_requests:write) all log at warn/debug and returnOk. Deployments are never blocked by commenting failures.What the comment looks like
→ on success the same comment becomes:
→ on failure:
Scope deliberately kept small
Known limitations / follow-ups
Test plan
Related
Companion fix for the branch-delete bug (#1239) lives on a separate branch (`security/0.1.0-hardening`) and isn't bundled here.