Skip to content

Commit

Permalink
Always more logs
Browse files Browse the repository at this point in the history
  • Loading branch information
elegaanz committed Jul 24, 2024
1 parent 6193ef0 commit c897da2
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions src/github.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use codespan_reporting::{
diagnostic::{Diagnostic, Severity},
files::Files,
};
use eyre::Context;
use hook::CheckRunPayload;
use jwt_simple::prelude::*;
use tracing::{debug, info, warn};
Expand Down Expand Up @@ -117,7 +118,9 @@ async fn github_hook(
mut api_client: GitHub,
payload: HookPayload,
) -> Result<(), WebError> {
debug!("GitHub hook was triggered");
api_client.auth_installation(&payload).await?;
debug!("Successfully authenticated application");

let (head_sha, repository, previous_check_run) = match payload {
HookPayload::CheckSuite(CheckSuitePayload {
Expand All @@ -140,6 +143,7 @@ async fn github_hook(
_ => return Err(WebError::UnexpectedEvent),
};

debug!("Starting checks for {}", head_sha);
tokio::spawn(async move {
async fn inner(
state: AppState,
Expand Down Expand Up @@ -194,7 +198,8 @@ async fn github_hook(
check_run_name,
&head_sha,
)
.await?
.await
.context("Failed to create a new check run")?
};

if touches_outside_of_packages {
Expand All @@ -208,12 +213,16 @@ async fn github_hook(
summary: "A PR should either change packages/, or the rest of the repository, but not both.",
annotations: &[],
},
).await?;
).await
.context("Failed to cancel a check run because the branch does too many things")?;
continue;
}

let checkout_dir = format!("checkout-{}", head_sha);
git_repo.checkout_commit(&head_sha, &checkout_dir).await?;
git_repo
.checkout_commit(&head_sha, &checkout_dir)
.await
.context("Failed to checkout commit")?;

let (world, diags) = match check::all_checks(
Some(package),
Expand Down Expand Up @@ -243,7 +252,8 @@ async fn github_hook(
annotations: &[],
},
)
.await?;
.await
.context("Failed to report fatal error")?;
return Err(e);
}
};
Expand Down Expand Up @@ -301,7 +311,8 @@ async fn github_hook(
.collect::<Vec<_>>(),
},
)
.await?;
.await
.context("Failed to send report")?;

tokio::fs::remove_dir_all(checkout_dir).await?;
}
Expand Down

0 comments on commit c897da2

Please sign in to comment.