Skip to content

Commit 73606a9

Browse files
authored
Merge pull request #2547 from JonathanBrouwer/fix-triage-update
Fix triage comment update
2 parents 1c8f187 + 6dfe682 commit 73606a9

2 files changed

Lines changed: 24 additions & 18 deletions

File tree

site/src/github/client.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ impl GraphQLClient {
131131
comments(first: 100, after: $cursor) {
132132
nodes {
133133
id
134+
fullDatabaseId
134135
body
135136
isMinimized
136137
viewerDidAuthor
@@ -291,6 +292,7 @@ struct GraphPageInfo {
291292
#[serde(rename_all = "camelCase")]
292293
pub struct ResponseComment {
293294
pub id: String,
295+
pub full_database_id: String,
294296
pub body: String,
295297
pub is_minimized: bool,
296298
// Is the account that fetches this comment also the original author of the comment?

site/src/github/comparison_summary.rs

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,11 @@ pub async fn post_comparison_comment(
4545
let triage_summary = metrics_result(ctxt, &commit)
4646
.await
4747
.unwrap_or_else(|error| error);
48-
match update_triage_body(&mut triage_run.triage_comment.body, pr, triage_summary) {
48+
match update_triage_body(
49+
&mut triage_run.triage_comment.body,
50+
pr,
51+
format!("{}\n", triage_summary),
52+
) {
4953
Ok(()) => {
5054
// While in theory this is racy (the comment could have been edited since querying it),
5155
// in practice this should never happen
@@ -130,11 +134,23 @@ async fn summarize_run(
130134
) -> Result<String, String> {
131135
let benchmark_map = ctxt.get_benchmark_category_map().await;
132136

133-
let mut message = format!(
137+
let mut message = String::new();
138+
if let PerfRunSource::TriageBuild(build) = &source {
139+
write!(
140+
&mut message,
141+
"> [!NOTE]\n> This PR was benchmarked as part of triage of its containing rollup: [triage URL](/rust-lang/rust/pull/{}#issuecomment-{}).\n\n",
142+
build.rollup_pr_number,
143+
build.triage_comment.full_database_id
144+
).unwrap();
145+
}
146+
147+
write!(
148+
&mut message,
134149
"Finished benchmarking commit ({sha}): [comparison URL]({comparison_url}).\n\n",
135150
sha = commit.sha,
136151
comparison_url = make_comparison_url(&commit, Metric::InstructionsUser)
137-
);
152+
)
153+
.unwrap();
138154

139155
let inst_comparison =
140156
calculate_metric_comparison(ctxt, &commit, Metric::InstructionsUser).await?;
@@ -187,8 +203,9 @@ async fn summarize_run(
187203

188204
let next_steps = match &source {
189205
PerfRunSource::TryBuild => try_run_body(is_regression, deserves_attention),
190-
PerfRunSource::MasterCommit => master_run_body(is_regression),
191-
PerfRunSource::TriageBuild(triage_build) => triage_run_body(triage_build, is_regression),
206+
PerfRunSource::MasterCommit | PerfRunSource::TriageBuild(..) => {
207+
master_run_body(is_regression)
208+
}
192209
};
193210
writeln!(&mut message, "{next_steps}\n").unwrap();
194211

@@ -400,16 +417,3 @@ Benchmarking means the PR may be perf-sensitive. \
400417
@rustbot label: -S-waiting-on-perf {sign}perf-regression",
401418
)
402419
}
403-
404-
fn triage_run_body(build: &TriageBuild, is_regression: bool) -> String {
405-
// The triage url deliberately not prefixed with "https://github.com/" as to not trigger the
406-
// "mentioned this pull request" github entry on the rollup
407-
format!(
408-
"This PR was benchmarked as part of triage of its containing rollup: [triage URL](/rust-lang/rust/pull/{}#issuecomment-{}).\
409-
\n\n\
410-
{}",
411-
build.rollup_pr_number,
412-
build.triage_comment.id,
413-
master_run_body(is_regression)
414-
)
415-
}

0 commit comments

Comments
 (0)