Skip to content

Commit fd62aac

Browse files
authored
Merge pull request #434 from mostafa630/add_workflow_links_to_try_build_started_comments
Add workflow links to try build started comments
2 parents 2e35c7b + 4e9f649 commit fd62aac

21 files changed

+418
-155
lines changed

.sqlx/query-94ce8ab6ef6cb76aa62aaf81c9f4b1751318faf2009b411b6cd616f47a82abf0.json renamed to .sqlx/query-070fd5babee0d508900290c872bd9247855b9712d6633c1dc3683751941749b1.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/bors/comment.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,14 @@ pub fn try_build_started_comment(
198198
Comment::new(msg)
199199
}
200200

201+
pub fn append_workflow_links_to_comment(comment_content: &mut String, workflow_links: Vec<String>) {
202+
comment_content.push_str("\n**Workflows**:\n\n");
203+
204+
for link in workflow_links {
205+
comment_content.push_str(&format!("- {link}\n"));
206+
}
207+
}
208+
201209
pub fn merge_conflict_comment(branch: &str) -> Comment {
202210
let message = format!(
203211
r#":lock: Merge conflict

src/bors/handlers/help.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ mod tests {
8787
async fn help_command(pool: sqlx::PgPool) {
8888
run_test(pool, async |tester: &mut BorsTester| {
8989
tester.post_comment("@bors help").await?;
90-
insta::assert_snapshot!(tester.get_comment_text(()).await?, @r"
90+
insta::assert_snapshot!(tester.get_next_comment_text(()).await?, @r"
9191
You can use the following commands:
9292
9393
## PR management

src/bors/handlers/info.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ mod tests {
9393
run_test(pool, async |tester: &mut BorsTester| {
9494
tester.post_comment("@bors info").await?;
9595
insta::assert_snapshot!(
96-
tester.get_comment_text(()).await?,
96+
tester.get_next_comment_text(()).await?,
9797
@r"
9898
## Status of PR `1`
9999
- Not Approved
@@ -113,7 +113,7 @@ mod tests {
113113

114114
tester.post_comment("@bors info").await?;
115115
insta::assert_snapshot!(
116-
tester.get_comment_text(()).await?,
116+
tester.get_next_comment_text(()).await?,
117117
@r"
118118
## Status of PR `1`
119119
- Approved by: `default-user`
@@ -134,7 +134,7 @@ mod tests {
134134

135135
tester.post_comment("@bors info").await?;
136136
insta::assert_snapshot!(
137-
tester.get_comment_text(()).await?,
137+
tester.get_next_comment_text(()).await?,
138138
@r"
139139
## Status of PR `1`
140140
- Not Approved
@@ -155,7 +155,7 @@ mod tests {
155155

156156
tester.post_comment("@bors info").await?;
157157
insta::assert_snapshot!(
158-
tester.get_comment_text(()).await?,
158+
tester.get_next_comment_text(()).await?,
159159
@r"
160160
## Status of PR `1`
161161
- Not Approved
@@ -186,7 +186,7 @@ mod tests {
186186

187187
tester.post_comment("@bors info").await?;
188188
insta::assert_snapshot!(
189-
tester.get_comment_text(()).await?,
189+
tester.get_next_comment_text(()).await?,
190190
@r"
191191
## Status of PR `1`
192192
- Approved by: `default-user`

src/bors/handlers/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ pub async fn handle_bors_repository_event(
108108
repo = payload.repository.to_string(),
109109
id = payload.run_id.into_inner()
110110
);
111-
handle_workflow_started(db, payload)
111+
handle_workflow_started(repo, db, payload)
112112
.instrument(span.clone())
113113
.await?;
114114

@@ -728,7 +728,7 @@ mod tests {
728728
async fn unknown_command(pool: sqlx::PgPool) {
729729
run_test(pool, async |tester: &mut BorsTester| {
730730
tester.post_comment(Comment::from("@bors foo")).await?;
731-
insta::assert_snapshot!(tester.get_comment_text(()).await?, @r#"Unknown command "foo". Run `@bors help` to see available commands."#);
731+
insta::assert_snapshot!(tester.get_next_comment_text(()).await?, @r#"Unknown command "foo". Run `@bors help` to see available commands."#);
732732
Ok(())
733733
})
734734
.await;

src/bors/handlers/ping.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ mod tests {
2222
async fn ping_command(pool: sqlx::PgPool) {
2323
run_test(pool, async |tester: &mut BorsTester| {
2424
tester.post_comment("@bors ping").await?;
25-
assert_eq!(tester.get_comment_text(()).await?, "Pong 🏓!");
25+
assert_eq!(tester.get_next_comment_text(()).await?, "Pong 🏓!");
2626
Ok(())
2727
})
2828
.await;

src/bors/handlers/pr_events.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ mod tests {
350350
.await?;
351351

352352
insta::assert_snapshot!(
353-
tester.get_comment_text(()).await?,
353+
tester.get_next_comment_text(()).await?,
354354
@r"
355355
:warning: The base branch changed to `beta`, and the
356356
PR will need to be re-approved.
@@ -400,7 +400,7 @@ mod tests {
400400
tester.push_to_pr(()).await?;
401401

402402
insta::assert_snapshot!(
403-
tester.get_comment_text(()).await?,
403+
tester.get_next_comment_text(()).await?,
404404
@r"
405405
:warning: A new commit `pr-1-commit-1` was pushed to the branch, the
406406
PR will need to be re-approved.
@@ -713,7 +713,7 @@ mod tests {
713713
.workflow_start(WorkflowRunData::from(tester.auto_branch().await).with_run_id(123))
714714
.await?;
715715
tester.push_to_pr(()).await?;
716-
insta::assert_snapshot!(tester.get_comment_text(()).await?, @r"
716+
insta::assert_snapshot!(tester.get_next_comment_text(()).await?, @r"
717717
:warning: A new commit `pr-1-commit-1` was pushed to the branch, the
718718
PR will need to be re-approved.
719719
@@ -741,7 +741,7 @@ mod tests {
741741

742742
tester.workflow_start(tester.auto_branch().await).await?;
743743
tester.push_to_pr(()).await?;
744-
insta::assert_snapshot!(tester.get_comment_text(()).await?, @r"
744+
insta::assert_snapshot!(tester.get_next_comment_text(()).await?, @r"
745745
:warning: A new commit `pr-1-commit-1` was pushed to the branch, the
746746
PR will need to be re-approved.
747747

src/bors/handlers/refresh.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ timeout = 3600
284284
tester.cancel_timed_out_builds().await;
285285
})
286286
.await;
287-
insta::assert_snapshot!(tester.get_comment_text(()).await?, @":boom: Test timed out after `3600`s");
287+
insta::assert_snapshot!(tester.get_next_comment_text(()).await?, @":boom: Test timed out after `3600`s");
288288
assert_eq!(
289289
tester
290290
.db()

src/bors/handlers/retry.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ mod tests {
5656
.post_comment(Comment::from("@bors retry").with_author(User::unprivileged()))
5757
.await?;
5858
insta::assert_snapshot!(
59-
tester.get_comment_text(()).await?,
59+
tester.get_next_comment_text(()).await?,
6060
@"@unprivileged-user: :key: Insufficient privileges: not in review users"
6161
);
6262
Ok(())
@@ -69,7 +69,7 @@ mod tests {
6969
run_test(pool, async |tester: &mut BorsTester| {
7070
tester.post_comment(Comment::from("@bors retry")).await?;
7171
insta::assert_snapshot!(
72-
tester.get_comment_text(()).await?,
72+
tester.get_next_comment_text(()).await?,
7373
@":exclamation: You can only retry pull requests that are approved and have a previously failed auto build"
7474
);
7575
Ok(())
@@ -90,7 +90,7 @@ mod tests {
9090
tester.wait_for_pr((), |pr| pr.auto_build.is_none()).await?;
9191
tester.process_merge_queue().await;
9292
insta::assert_snapshot!(
93-
tester.get_comment_text(()).await?,
93+
tester.get_next_comment_text(()).await?,
9494
@":hourglass: Testing commit pr-1-sha with merge merge-1-pr-1..."
9595
);
9696
Ok(())

0 commit comments

Comments
 (0)