Skip to content

Commit 8158f78

Browse files
authored
Merge pull request #2023 from Kobzol/move-to-rust-lang
Use `rust-lang` instead of `rust-lang-ci` for all commits
2 parents d4ae17a + 8ba4856 commit 8158f78

File tree

2 files changed

+18
-38
lines changed

2 files changed

+18
-38
lines changed

site/src/github.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,12 @@ use database::Connection;
2626

2727
/// Enqueues try build artifacts and posts a message about them on the original rollup PR
2828
pub async fn unroll_rollup(
29-
ci_client: client::Client,
30-
main_repo_client: client::Client,
29+
gh_client: client::Client,
3130
rollup_merges: impl Iterator<Item = &Commit>,
3231
previous_master: &str,
3332
rollup_pr_number: u32,
3433
) -> Result<(), String> {
35-
let commit_link = |sha: &str| format!("https://github.com/rust-lang-ci/rust/commit/{sha}");
34+
let commit_link = |sha: &str| format!("https://github.com/rust-lang/rust/commit/{sha}");
3635

3736
let format_commit = |s: &str, truncate: bool| {
3837
let display = truncate.then(|| s.split_at(10).0).unwrap_or(s);
@@ -42,7 +41,7 @@ pub async fn unroll_rollup(
4241
// Sort rolled up commits by their PR number in ascending order, so that they have the
4342
// same ordering as in the rollup PR description.
4443
let mut unrolled_builds: Vec<UnrolledCommit> =
45-
enqueue_unrolled_try_builds(ci_client, rollup_merges, previous_master).await?;
44+
enqueue_unrolled_try_builds(&gh_client, rollup_merges, previous_master).await?;
4645
// The number should really be an integer, but if not, we will just sort the "non-integer" PRs
4746
// first.
4847
unrolled_builds.sort_by_cached_key(|commit| commit.original_pr_number.parse::<u64>().ok());
@@ -93,14 +92,14 @@ pub async fn unroll_rollup(
9392
{mapping}\n\n*previous master*: {previous_master}\n\nIn the case of a perf regression, \
9493
run the following command for each PR you suspect might be the cause: `@rust-timer build $SHA`\n\
9594
{COMMENT_MARK_ROLLUP}");
96-
main_repo_client.post_comment(rollup_pr_number, msg).await;
95+
gh_client.post_comment(rollup_pr_number, msg).await;
9796
Ok(())
9897
}
9998

10099
/// Enqueues try builds on the try-perf branch for every rollup merge in `rollup_merges`.
101100
/// Returns a mapping between the rollup merge commit and the try build sha.
102101
async fn enqueue_unrolled_try_builds<'a>(
103-
client: client::Client,
102+
client: &client::Client,
104103
rollup_merges: impl Iterator<Item = &'a Commit>,
105104
previous_master: &str,
106105
) -> Result<Vec<UnrolledCommit<'a>>, String> {
@@ -236,14 +235,13 @@ pub async fn rollup_pr_number(
236235

237236
pub async fn enqueue_shas(
238237
ctxt: &SiteCtxt,
239-
main_client: &client::Client,
240-
ci_client: &client::Client,
238+
gh_client: &client::Client,
241239
pr_number: u32,
242240
commits: impl Iterator<Item = &str>,
243241
) -> Result<(), String> {
244242
let mut msg = String::new();
245243
for commit in commits {
246-
let mut commit_response = ci_client
244+
let mut commit_response = gh_client
247245
.get_commit(commit)
248246
.await
249247
.map_err(|e| e.to_string())?;
@@ -299,7 +297,7 @@ It will probably take at least ~{:.1} hours until the benchmark run finishes."#,
299297

300298
if !msg.is_empty() {
301299
msg.push_str(&format!("\n{COMMENT_MARK_TEMPORARY}"));
302-
main_client.post_comment(pr_number, msg).await;
300+
gh_client.post_comment(pr_number, msg).await;
303301
}
304302

305303
Ok(())

site/src/request_handlers/github.rs

Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,14 @@ pub async fn handle_github(
2020
}
2121

2222
async fn handle_push(ctxt: Arc<SiteCtxt>, push: github::Push) -> ServerResult<github::Response> {
23-
let ci_client = client::Client::from_ctxt(
24-
&ctxt,
25-
"https://api.github.com/repos/rust-lang-ci/rust".to_owned(),
26-
);
27-
let main_repo_client = client::Client::from_ctxt(&ctxt, RUST_REPO_GITHUB_API_URL.to_owned());
23+
let gh_client = client::Client::from_ctxt(&ctxt, RUST_REPO_GITHUB_API_URL.to_owned());
2824
if push.r#ref != "refs/heads/master" || push.sender.login != "bors" {
2925
return Ok(github::Response);
3026
}
31-
let rollup_pr_number =
32-
match rollup_pr_number(&main_repo_client, &push.head_commit.message).await? {
33-
Some(pr) => pr,
34-
None => return Ok(github::Response),
35-
};
27+
let rollup_pr_number = match rollup_pr_number(&gh_client, &push.head_commit.message).await? {
28+
Some(pr) => pr,
29+
None => return Ok(github::Response),
30+
};
3631

3732
let previous_master = push.before;
3833
let commits = push.commits;
@@ -44,14 +39,8 @@ async fn handle_push(ctxt: Arc<SiteCtxt>, push: github::Push) -> ServerResult<gi
4439
.iter()
4540
.rev()
4641
.filter(|c| c.message.starts_with("Rollup merge of #"));
47-
let result = unroll_rollup(
48-
ci_client,
49-
main_repo_client,
50-
rollup_merges,
51-
&previous_master,
52-
rollup_pr_number,
53-
)
54-
.await;
42+
let result =
43+
unroll_rollup(gh_client, rollup_merges, &previous_master, rollup_pr_number).await;
5544
log::info!("Processing of rollup merge finished: {:#?}", result);
5645
});
5746
Ok(github::Response)
@@ -62,17 +51,12 @@ async fn handle_issue(
6251
issue: github::Issue,
6352
comment: github::Comment,
6453
) -> ServerResult<github::Response> {
65-
let main_client = client::Client::from_ctxt(&ctxt, RUST_REPO_GITHUB_API_URL.to_owned());
66-
let ci_client = client::Client::from_ctxt(
67-
&ctxt,
68-
"https://api.github.com/repos/rust-lang-ci/rust".to_owned(),
69-
);
54+
let gh_client = client::Client::from_ctxt(&ctxt, RUST_REPO_GITHUB_API_URL.to_owned());
7055
if comment.body.contains(" homu: ") {
7156
if let Some(sha) = parse_homu_comment(&comment.body).await {
7257
enqueue_shas(
7358
&ctxt,
74-
&main_client,
75-
&ci_client,
59+
&gh_client,
7660
issue.number,
7761
std::iter::once(sha.as_str()),
7862
)
@@ -82,7 +66,7 @@ async fn handle_issue(
8266
}
8367

8468
if comment.body.contains("@rust-timer ") {
85-
return handle_rust_timer(ctxt, &main_client, &ci_client, comment, issue).await;
69+
return handle_rust_timer(ctxt, &gh_client, comment, issue).await;
8670
}
8771

8872
Ok(github::Response)
@@ -91,7 +75,6 @@ async fn handle_issue(
9175
async fn handle_rust_timer(
9276
ctxt: Arc<SiteCtxt>,
9377
main_client: &client::Client,
94-
ci_client: &client::Client,
9578
comment: github::Comment,
9679
issue: github::Issue,
9780
) -> ServerResult<github::Response> {
@@ -168,7 +151,6 @@ async fn handle_rust_timer(
168151
enqueue_shas(
169152
&ctxt,
170153
main_client,
171-
ci_client,
172154
issue.number,
173155
valid_build_cmds.iter().map(|c| c.sha),
174156
)

0 commit comments

Comments
 (0)