Skip to content

Commit 1aa03a4

Browse files
authored
Merge pull request #1532 from rust-lang/try-build-rollup
Do not set GitHub label for try runs on rolled up PRs
2 parents 7088eb0 + 418ec86 commit 1aa03a4

File tree

2 files changed

+45
-13
lines changed

2 files changed

+45
-13
lines changed

site/src/github.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ pub const RUST_REPO_GITHUB_API_URL: &str = "https://api.github.com/repos/rust-la
1616
/// They are removed once a perf. run comparison summary is posted on a PR.
1717
pub const COMMENT_MARK_TEMPORARY: &str = "<!-- rust-timer: temporary -->";
1818

19+
/// Used for comment that contains unrolled commits for merged rolled-up PRs.
20+
pub const COMMENT_MARK_ROLLUP: &str = "<!-- rust-timer: rollup -->";
21+
1922
pub use comparison_summary::post_finished;
2023

2124
/// Enqueues try build artifacts and posts a message about them on the original rollup PR
@@ -51,7 +54,8 @@ pub async fn unroll_rollup(
5154
format!("📌 Perf builds for each rolled up PR:\n\n\
5255
|PR# | Perf Build Sha|\n|----|:-----:|\n\
5356
{mapping}\n\n*previous master*: {previous_master}\n\nIn the case of a perf regression, \
54-
run the following command for each PR you suspect might be the cause: `@rust-timer build $SHA`");
57+
run the following command for each PR you suspect might be the cause: `@rust-timer build $SHA`\n\
58+
{COMMENT_MARK_ROLLUP}");
5559
main_repo_client.post_comment(rollup_pr_number, msg).await;
5660
Ok(())
5761
}

site/src/github/comparison_summary.rs

+40-12
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::load::SiteCtxt;
66

77
use database::{ArtifactId, QueuedCommit};
88

9-
use crate::github::{COMMENT_MARK_TEMPORARY, RUST_REPO_GITHUB_API_URL};
9+
use crate::github::{COMMENT_MARK_ROLLUP, COMMENT_MARK_TEMPORARY, RUST_REPO_GITHUB_API_URL};
1010
use std::collections::HashSet;
1111
use std::fmt::Write;
1212

@@ -76,13 +76,11 @@ async fn post_comparison_comment(
7676
) -> anyhow::Result<()> {
7777
let client = super::client::Client::from_ctxt(ctxt, RUST_REPO_GITHUB_API_URL.to_owned());
7878
let pr = commit.pr;
79-
let body = match summarize_run(ctxt, commit, is_master_commit).await {
80-
Ok(message) => message,
81-
Err(error) => error,
82-
};
8379

84-
client.post_comment(pr, body).await;
80+
// Was this perf. run triggered from a PR that was already merged and is a rollup?
81+
let mut is_rollup = false;
8582

83+
// Scan comments to hide outdated ones and gather context
8684
let graph_client = super::client::GraphQLClient::from_ctxt(ctxt);
8785
for comment in graph_client.get_comments(pr).await? {
8886
// If this bot is the author of the comment, the comment is not yet minimized and it is
@@ -94,7 +92,27 @@ async fn post_comparison_comment(
9492
log::debug!("Hiding comment {}", comment.id);
9593
graph_client.hide_comment(&comment.id, "OUTDATED").await?;
9694
}
95+
96+
if comment.viewer_did_author && comment.body.contains(COMMENT_MARK_ROLLUP) {
97+
is_rollup = true;
98+
}
9799
}
100+
101+
let source = if is_master_commit {
102+
PerfRunSource::MasterCommit
103+
} else if is_rollup {
104+
PerfRunSource::TryBuildRollup
105+
} else {
106+
PerfRunSource::TryBuild
107+
};
108+
109+
let body = match summarize_run(ctxt, commit, source).await {
110+
Ok(message) => message,
111+
Err(error) => error,
112+
};
113+
114+
client.post_comment(pr, body).await;
115+
98116
Ok(())
99117
}
100118

@@ -125,10 +143,20 @@ async fn calculate_metric_comparison(
125143
}
126144
}
127145

146+
/// What caused this perf. run to be executed?
147+
enum PerfRunSource {
148+
// PR merged to master
149+
MasterCommit,
150+
// Manual try build on a PR
151+
TryBuild,
152+
// Manual try build on a merged rollup PR
153+
TryBuildRollup,
154+
}
155+
128156
async fn summarize_run(
129157
ctxt: &SiteCtxt,
130158
commit: QueuedCommit,
131-
is_master_commit: bool,
159+
source: PerfRunSource,
132160
) -> Result<String, String> {
133161
let benchmark_map = ctxt.get_benchmark_category_map().await;
134162

@@ -179,16 +207,16 @@ async fn summarize_run(
179207
)
180208
.unwrap();
181209

182-
let next_steps = if is_master_commit {
183-
master_run_body(is_regression)
184-
} else {
185-
try_run_body(is_regression)
210+
let next_steps = match source {
211+
PerfRunSource::TryBuild => try_run_body(is_regression),
212+
PerfRunSource::TryBuildRollup => "".to_string(),
213+
PerfRunSource::MasterCommit => master_run_body(is_regression),
186214
};
187215
writeln!(&mut message, "{next_steps}\n").unwrap();
188216

189217
if !errors.is_empty() {
190218
writeln!(&mut message, "\n{errors}").unwrap();
191-
if is_master_commit {
219+
if matches!(source, PerfRunSource::MasterCommit) {
192220
writeln!(&mut message, "\ncc @rust-lang/wg-compiler-performance").unwrap();
193221
}
194222
}

0 commit comments

Comments
 (0)