forked from kemitix/git-next
42 lines
1.5 KiB
Rust
42 lines
1.5 KiB
Rust
//
|
|
use crate as actor;
|
|
use actix::prelude::*;
|
|
use git_next_git as git;
|
|
|
|
impl Handler<actor::messages::ReceiveCIStatus> for actor::RepoActor {
|
|
type Result = ();
|
|
|
|
fn handle(
|
|
&mut self,
|
|
msg: actor::messages::ReceiveCIStatus,
|
|
ctx: &mut Self::Context,
|
|
) -> Self::Result {
|
|
let log = self.log.clone();
|
|
actor::logger(&log, "start: ReceiveCIStatus");
|
|
let addr = ctx.address();
|
|
let (next, status) = msg.unwrap();
|
|
let message_token = self.message_token;
|
|
let sleep_duration = self.sleep_duration;
|
|
|
|
tracing::debug!(?status, "");
|
|
match status {
|
|
git::forge::commit::Status::Pass => {
|
|
actor::do_send(addr, actor::messages::AdvanceMain::new(next), &self.log);
|
|
}
|
|
git::forge::commit::Status::Pending => {
|
|
std::thread::sleep(sleep_duration);
|
|
actor::do_send(
|
|
addr,
|
|
actor::messages::ValidateRepo::new(message_token),
|
|
&self.log,
|
|
);
|
|
}
|
|
git::forge::commit::Status::Fail => {
|
|
tracing::warn!("Checks have failed");
|
|
// TODO: (#95) test: repo with next ahead of main and failing CI should notify user
|
|
// TODO: (#88) recheck after a longer than normal delay
|
|
actor::logger(&log, "send: nothing"); // replace with messages to send notification and revalidate later
|
|
}
|
|
}
|
|
}
|
|
}
|