feat(server): next commit status is returned as pass, fail ro pending
All checks were successful
ci/woodpecker/push/cron-docker-builder Pipeline was successful
ci/woodpecker/push/tag-created Pipeline was successful
ci/woodpecker/push/push-next Pipeline was successful

This commit is contained in:
Paul Campbell 2024-04-10 09:16:42 +01:00
parent 79d0b2ff75
commit 546d91554c
3 changed files with 22 additions and 8 deletions

View file

@ -1,6 +1,6 @@
mod branch;
mod config;
mod status;
pub mod status;
mod webhook;
use actix::prelude::*;

View file

@ -13,12 +13,27 @@ pub async fn check_next(
addr: Addr<super::RepoActor>,
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,
}

View file

@ -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)]