Skip to content

Commit f3c51fa

Browse files
committed
Post auto build succeeded comment when actual merge happens
1 parent 21e4c05 commit f3c51fa

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

src/bors/handlers/workflow.rs

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ use crate::PgDbClient;
77
use crate::bors::CheckSuiteStatus;
88
use crate::bors::RepositoryState;
99
use crate::bors::comment::auto_build_failed_comment;
10-
use crate::bors::comment::auto_build_succeeded_comment;
1110
use crate::bors::comment::{try_build_succeeded_comment, workflow_failed_comment};
1211
use crate::bors::event::{CheckSuiteCompleted, WorkflowCompleted, WorkflowStarted};
1312
use crate::bors::handlers::TRY_BRANCH_NAME;
@@ -205,7 +204,7 @@ async fn try_complete_build(
205204
complete_try_build(repo, pr, build, workflows, has_failure, payload).await?
206205
}
207206
AUTO_BRANCH_NAME => {
208-
complete_auto_build(repo, pr, workflows, has_failure, payload).await?;
207+
complete_auto_build(repo, pr, workflows, has_failure).await?;
209208
}
210209
_ => unreachable!("Branch should only be bors-observed branch"),
211210
}
@@ -248,21 +247,14 @@ async fn complete_auto_build(
248247
pr: PullRequestModel,
249248
workflows: Vec<WorkflowModel>,
250249
has_failure: bool,
251-
payload: CheckSuiteCompleted,
252250
) -> anyhow::Result<()> {
253-
let comment = if !has_failure {
254-
tracing::info!("Auto build succeeded for PR {}", pr.number);
255-
auto_build_succeeded_comment(
256-
&workflows,
257-
pr.approver().unwrap_or("<unknown>"),
258-
&payload.commit_sha,
259-
&pr.base_branch,
260-
)
261-
} else {
251+
if has_failure {
262252
tracing::info!("Auto build failed for PR {}", pr.number);
263-
auto_build_failed_comment(&workflows)
264-
};
265-
repo.client.post_comment(pr.number, comment).await?;
253+
let comment = auto_build_failed_comment(&workflows);
254+
repo.client.post_comment(pr.number, comment).await?;
255+
} else {
256+
tracing::info!("Auto build succeeded for PR {}", pr.number);
257+
}
266258

267259
let (status, conclusion, desc) = if !has_failure {
268260
(

src/bors/merge_queue.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ use crate::{
88
bors::{
99
PullRequestStatus, RepositoryState,
1010
comment::{
11-
auto_build_push_failed_comment, auto_build_started_comment, merge_conflict_comment,
11+
auto_build_push_failed_comment, auto_build_started_comment,
12+
auto_build_succeeded_comment, merge_conflict_comment,
1213
},
1314
handlers::labels::handle_label_trigger,
1415
},
@@ -68,6 +69,15 @@ pub async fn handle_merge_queue(ctx: Arc<BorsContext>) -> anyhow::Result<()> {
6869
match auto_build.status {
6970
// Build successful - point the base branch to the merged commit.
7071
BuildStatus::Success => {
72+
let workflows = ctx.db.get_workflows_for_build(auto_build).await?;
73+
let comment = auto_build_succeeded_comment(
74+
&workflows,
75+
pr.approver().unwrap_or("<unknown>"),
76+
&commit_sha,
77+
&pr.base_branch,
78+
);
79+
repo.client.post_comment(pr.number, comment).await?;
80+
7181
match repo
7282
.client
7383
.set_branch_to_sha(&pr.base_branch, &commit_sha, false)

0 commit comments

Comments
 (0)