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

47 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 {
#[cfg(feature = "forgejo")]
ForgeType::ForgeJo => {
forge::forgejo::get_commit_status(next.clone(), &repo_details, net).await
}
};
2024-04-12 17:41:09 +01:00
info!(?status, "Checking next branch");
match status {
Status::Pass => {
addr.do_send(AdvanceMainTo(next));
}
2024-04-12 17:41:09 +01:00
Status::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,
}