Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[do not merge] Use rust-lang instead of rust-lang-ci for all commits #2023

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions site/src/github.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,12 @@ use database::Connection;

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

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

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

pub async fn enqueue_shas(
ctxt: &SiteCtxt,
main_client: &client::Client,
ci_client: &client::Client,
gh_client: &client::Client,
pr_number: u32,
commits: impl Iterator<Item = &str>,
) -> Result<(), String> {
let mut msg = String::new();
for commit in commits {
let mut commit_response = ci_client
let mut commit_response = gh_client
.get_commit(commit)
.await
.map_err(|e| e.to_string())?;
Expand Down Expand Up @@ -300,7 +298,7 @@ It will probably take at least ~{:.1} hours until the benchmark run finishes."#,

if !msg.is_empty() {
msg.push_str(&format!("\n{COMMENT_MARK_TEMPORARY}"));
main_client.post_comment(pr_number, msg).await;
gh_client.post_comment(pr_number, msg).await;
}

Ok(())
Expand Down
38 changes: 10 additions & 28 deletions site/src/request_handlers/github.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,14 @@ pub async fn handle_github(
}

async fn handle_push(ctxt: Arc<SiteCtxt>, push: github::Push) -> ServerResult<github::Response> {
let ci_client = client::Client::from_ctxt(
&ctxt,
"https://api.github.com/repos/rust-lang-ci/rust".to_owned(),
);
let main_repo_client = client::Client::from_ctxt(&ctxt, RUST_REPO_GITHUB_API_URL.to_owned());
let gh_client = client::Client::from_ctxt(&ctxt, RUST_REPO_GITHUB_API_URL.to_owned());
if push.r#ref != "refs/heads/master" || push.sender.login != "bors" {
return Ok(github::Response);
}
let rollup_pr_number =
match rollup_pr_number(&main_repo_client, &push.head_commit.message).await? {
Some(pr) => pr,
None => return Ok(github::Response),
};
let rollup_pr_number = match rollup_pr_number(&gh_client, &push.head_commit.message).await? {
Some(pr) => pr,
None => return Ok(github::Response),
};

let previous_master = push.before;
let commits = push.commits;
Expand All @@ -44,14 +39,8 @@ async fn handle_push(ctxt: Arc<SiteCtxt>, push: github::Push) -> ServerResult<gi
.iter()
.rev()
.filter(|c| c.message.starts_with("Rollup merge of #"));
let result = unroll_rollup(
ci_client,
main_repo_client,
rollup_merges,
&previous_master,
rollup_pr_number,
)
.await;
let result =
unroll_rollup(gh_client, rollup_merges, &previous_master, rollup_pr_number).await;
log::info!("Processing of rollup merge finished: {:#?}", result);
});
Ok(github::Response)
Expand All @@ -62,17 +51,12 @@ async fn handle_issue(
issue: github::Issue,
comment: github::Comment,
) -> ServerResult<github::Response> {
let main_client = client::Client::from_ctxt(&ctxt, RUST_REPO_GITHUB_API_URL.to_owned());
let ci_client = client::Client::from_ctxt(
&ctxt,
"https://api.github.com/repos/rust-lang-ci/rust".to_owned(),
);
let gh_client = client::Client::from_ctxt(&ctxt, RUST_REPO_GITHUB_API_URL.to_owned());
if comment.body.contains(" homu: ") {
if let Some(sha) = parse_homu_comment(&comment.body).await {
enqueue_shas(
&ctxt,
&main_client,
&ci_client,
&gh_client,
issue.number,
std::iter::once(sha.as_str()),
)
Expand All @@ -82,7 +66,7 @@ async fn handle_issue(
}

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

Ok(github::Response)
Expand All @@ -91,7 +75,6 @@ async fn handle_issue(
async fn handle_rust_timer(
ctxt: Arc<SiteCtxt>,
main_client: &client::Client,
ci_client: &client::Client,
comment: github::Comment,
issue: github::Issue,
) -> ServerResult<github::Response> {
Expand Down Expand Up @@ -168,7 +151,6 @@ async fn handle_rust_timer(
enqueue_shas(
&ctxt,
main_client,
ci_client,
issue.number,
valid_build_cmds.iter().map(|c| c.sha),
)
Expand Down
Loading