forked from kemitix/git-next
feat(server): next commit status is returned as pass, fail ro pending
This commit is contained in:
parent
79d0b2ff75
commit
546d91554c
3 changed files with 22 additions and 8 deletions
|
@ -1,6 +1,6 @@
|
||||||
mod branch;
|
mod branch;
|
||||||
mod config;
|
mod config;
|
||||||
mod status;
|
pub mod status;
|
||||||
mod webhook;
|
mod webhook;
|
||||||
|
|
||||||
use actix::prelude::*;
|
use actix::prelude::*;
|
||||||
|
|
|
@ -13,12 +13,27 @@ pub async fn check_next(
|
||||||
addr: Addr<super::RepoActor>,
|
addr: Addr<super::RepoActor>,
|
||||||
net: kxio::network::Network,
|
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 => {
|
ForgeType::ForgeJo => {
|
||||||
forge::forgejo::get_commit_status(next.clone(), repo_details, net).await
|
forge::forgejo::get_commit_status(next.clone(), repo_details, net).await
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if is_success {
|
match status {
|
||||||
addr.do_send(AdvanceMainTo(next));
|
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,
|
||||||
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ use kxio::network;
|
||||||
use terrors::OneOf;
|
use terrors::OneOf;
|
||||||
use tracing::{error, info};
|
use tracing::{error, info};
|
||||||
|
|
||||||
use crate::server::{config::BranchName, forge};
|
use crate::server::{actors::repo::status::Status, config::BranchName, forge};
|
||||||
|
|
||||||
use super::CommitHistories;
|
use super::CommitHistories;
|
||||||
|
|
||||||
|
@ -65,15 +65,14 @@ struct Commit {
|
||||||
sha: String,
|
sha: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
|
||||||
pub async fn get_commit_status(
|
pub async fn get_commit_status(
|
||||||
_next: forge::Commit,
|
_next: forge::Commit,
|
||||||
_repo_details: crate::server::config::RepoDetails,
|
_repo_details: crate::server::config::RepoDetails,
|
||||||
_net: network::Network,
|
_net: network::Network,
|
||||||
) -> bool {
|
) -> Status {
|
||||||
// TODO: (#13) check statuses for next head - if ok, advance main to next and reassess
|
// 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}
|
// https://{hostname}/api/v1/repos/{path}/commits/{commit}/status?token={token}
|
||||||
false
|
Status::Pending
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, serde::Deserialize)]
|
#[derive(Debug, serde::Deserialize)]
|
||||||
|
|
Loading…
Reference in a new issue