diff --git a/src/server/actors/repo/mod.rs b/src/server/actors/repo/mod.rs index 59f4af27..41cc55fe 100644 --- a/src/server/actors/repo/mod.rs +++ b/src/server/actors/repo/mod.rs @@ -1,6 +1,6 @@ mod branch; mod config; -mod status; +pub mod status; mod webhook; use actix::prelude::*; diff --git a/src/server/actors/repo/status.rs b/src/server/actors/repo/status.rs index 2e58c3ed..345048ec 100644 --- a/src/server/actors/repo/status.rs +++ b/src/server/actors/repo/status.rs @@ -13,12 +13,27 @@ pub async fn check_next( addr: Addr, net: kxio::network::Network, ) { - let is_success = match repo_details.forge.forge_type { + // 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 } }; - if is_success { - addr.do_send(AdvanceMainTo(next)); + 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 } } + +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, +} diff --git a/src/server/forge/forgejo/mod.rs b/src/server/forge/forgejo/mod.rs index 810ed87a..fe04f780 100644 --- a/src/server/forge/forgejo/mod.rs +++ b/src/server/forge/forgejo/mod.rs @@ -2,7 +2,7 @@ use kxio::network; use terrors::OneOf; use tracing::{error, info}; -use crate::server::{config::BranchName, forge}; +use crate::server::{actors::repo::status::Status, config::BranchName, forge}; use super::CommitHistories; @@ -65,15 +65,14 @@ struct Commit { sha: String, } -#[allow(dead_code)] pub async fn get_commit_status( _next: forge::Commit, _repo_details: crate::server::config::RepoDetails, _net: network::Network, -) -> bool { +) -> Status { // TODO: (#13) check statuses for next head - if ok, advance main to next and reassess // https://{hostname}/api/v1/repos/{path}/commits/{commit}/status?token={token} - false + Status::Pending } #[derive(Debug, serde::Deserialize)]