2024-04-09 22:51:55 +01:00
|
|
|
use actix::prelude::*;
|
2024-04-10 18:02:04 +01:00
|
|
|
use gix::trace::warn;
|
2024-04-10 11:47:14 +01:00
|
|
|
use tracing::info;
|
2024-04-09 22:51:55 +01:00
|
|
|
|
2024-04-18 19:15:26 +01:00
|
|
|
use crate::server::{actors::repo::ValidateRepo, gitforge};
|
2024-04-09 22:51:55 +01:00
|
|
|
|
|
|
|
use super::AdvanceMainTo;
|
2024-04-09 19:30:05 +01:00
|
|
|
|
2024-04-18 19:15:26 +01:00
|
|
|
pub async fn check_next(
|
|
|
|
next: gitforge::Commit,
|
|
|
|
addr: Addr<super::RepoActor>,
|
|
|
|
forge: gitforge::Forge,
|
|
|
|
) {
|
2024-04-10 09:16:42 +01:00
|
|
|
// get the status - pass, fail, pending (all others map to fail, e.g. error)
|
2024-04-16 22:21:55 +01:00
|
|
|
let status = forge.commit_status(&next).await;
|
2024-04-12 17:41:09 +01:00
|
|
|
info!(?status, "Checking next branch");
|
2024-04-10 09:16:42 +01:00
|
|
|
match status {
|
2024-04-16 22:21:55 +01:00
|
|
|
gitforge::CommitStatus::Pass => {
|
2024-04-10 09:16:42 +01:00
|
|
|
addr.do_send(AdvanceMainTo(next));
|
|
|
|
}
|
2024-04-16 22:21:55 +01:00
|
|
|
gitforge::CommitStatus::Pending => {
|
2024-04-14 18:33:01 +01:00
|
|
|
tokio::time::sleep(tokio::time::Duration::from_secs(10)).await;
|
|
|
|
addr.do_send(ValidateRepo);
|
2024-04-14 15:46:21 +01:00
|
|
|
}
|
2024-04-16 22:21:55 +01:00
|
|
|
gitforge::CommitStatus::Fail => {
|
2024-04-11 14:27:59 +01:00
|
|
|
warn!("Checks have failed");
|
|
|
|
}
|
2024-04-09 22:51:55 +01:00
|
|
|
}
|
2024-04-09 19:30:05 +01:00
|
|
|
}
|