2024-04-09 22:51:55 +01:00
|
|
|
use actix::prelude::*;
|
2024-04-10 11:47:14 +01:00
|
|
|
use tracing::info;
|
2024-04-09 22:51:55 +01:00
|
|
|
|
|
|
|
use crate::server::{
|
|
|
|
config::{self, ForgeType},
|
|
|
|
forge,
|
|
|
|
};
|
|
|
|
|
|
|
|
use super::AdvanceMainTo;
|
2024-04-09 19:30:05 +01:00
|
|
|
|
|
|
|
pub async fn check_next(
|
2024-04-09 22:51:55 +01:00
|
|
|
next: forge::Commit,
|
|
|
|
repo_details: config::RepoDetails,
|
|
|
|
addr: Addr<super::RepoActor>,
|
|
|
|
net: kxio::network::Network,
|
2024-04-09 19:30:05 +01:00
|
|
|
) {
|
2024-04-10 09:16:42 +01:00
|
|
|
// get the status - pass, fail, pending (all others map to fail, e.g. error)
|
|
|
|
let status = match repo_details.forge.forge_type {
|
2024-04-09 22:51:55 +01:00
|
|
|
ForgeType::ForgeJo => {
|
|
|
|
forge::forgejo::get_commit_status(next.clone(), repo_details, net).await
|
|
|
|
}
|
|
|
|
};
|
2024-04-10 11:47:14 +01:00
|
|
|
info!(?status, "Checking next branch status");
|
2024-04-10 09:16:42 +01:00
|
|
|
match status {
|
|
|
|
Status::Pass => {
|
|
|
|
addr.do_send(AdvanceMainTo(next));
|
|
|
|
}
|
|
|
|
Status::Pending => (), // TODO: (#22) wait and try again OR can webhook tell us when it's done, in
|
|
|
|
// which case we can do nothing here and wait for the webhook to trigger
|
|
|
|
Status::Fail => (), // TODO: (#21) reset next and wait for dev to be updated and this
|
|
|
|
// commit removed from the commit history before trying again
|
2024-04-09 22:51:55 +01:00
|
|
|
}
|
2024-04-09 19:30:05 +01:00
|
|
|
}
|
2024-04-10 09:16:42 +01:00
|
|
|
|
2024-04-10 11:47:14 +01:00
|
|
|
#[derive(Debug)]
|
2024-04-10 09:16:42 +01:00
|
|
|
pub enum Status {
|
|
|
|
#[allow(dead_code)] // TODO: (#13) remove this when we have results from the forge
|
|
|
|
Pass,
|
|
|
|
#[allow(dead_code)] // TODO: (#13) remove this when we have results from the forge
|
|
|
|
Fail,
|
|
|
|
Pending,
|
|
|
|
}
|