git-next/src/server/actors/repo/status.rs

48 lines
1.1 KiB
Rust
Raw Normal View History

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 {
ForgeType::ForgeJo => {
forge::forgejo::get_commit_status(next.clone(), &repo_details, net).await
}
};
info!(?status, "Checking next branch status");
match status {
Status::Pass => {
addr.do_send(AdvanceMainTo(next));
}
Status::Pending => {
info!("Checks are pending");
}
Status::Fail => {
warn!("Checks have failed");
}
}
// TODO : (#18) 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,
}