forked from kemitix/git-next
50 lines
1.3 KiB
Rust
50 lines
1.3 KiB
Rust
use actix::prelude::*;
|
|
use gix::trace::warn;
|
|
use tracing::info;
|
|
|
|
use crate::server::{
|
|
actors::repo::ValidateRepo,
|
|
config::{self, ForgeType},
|
|
forge,
|
|
};
|
|
|
|
use super::AdvanceMainTo;
|
|
|
|
pub async fn check_next(
|
|
next: forge::Commit,
|
|
repo_details: config::RepoDetails,
|
|
addr: Addr<super::RepoActor>,
|
|
net: kxio::network::Network,
|
|
) {
|
|
// get the status - pass, fail, pending (all others map to fail, e.g. error)
|
|
let status = match repo_details.forge.forge_type {
|
|
#[cfg(feature = "forgejo")]
|
|
ForgeType::ForgeJo => {
|
|
forge::forgejo::get_commit_status(next.clone(), &repo_details, net).await
|
|
}
|
|
#[cfg(test)]
|
|
ForgeType::MockForge => {
|
|
forge::mock::get_commit_status(next.clone(), &repo_details, &net).await
|
|
}
|
|
};
|
|
info!(?status, "Checking next branch");
|
|
match status {
|
|
Status::Pass => {
|
|
addr.do_send(AdvanceMainTo(next));
|
|
}
|
|
Status::Pending => {}
|
|
Status::Fail => {
|
|
warn!("Checks have failed");
|
|
}
|
|
}
|
|
// TODO : (#43) sleep and restart while we don't have webhooks
|
|
tokio::time::sleep(std::time::Duration::from_secs(10)).await;
|
|
addr.do_send(ValidateRepo);
|
|
}
|
|
|
|
#[derive(Debug)]
|
|
pub enum Status {
|
|
Pass,
|
|
Fail,
|
|
Pending,
|
|
}
|