feat: when no action to take, wait 10 seconds then restart
Some checks failed
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
ci/woodpecker/tag/push-next Pipeline was successful
ci/woodpecker/tag/cron-docker-builder Pipeline was successful
ci/woodpecker/tag/tag-created Pipeline failed

As a stop-gap until we have a working webhook server, this will poll the
repo for updates to it's status.

Closes kemitix/git-next#22
This commit is contained in:
Paul Campbell 2024-04-11 18:30:36 +01:00
parent bb4d171174
commit c9d52a5b7f
3 changed files with 10 additions and 5 deletions

View file

@ -133,8 +133,7 @@ impl Handler<StartMonitoring> for RepoActor {
} else if self.webhook_id.is_none() { } else if self.webhook_id.is_none() {
webhook::register(repo_details, addr, net) webhook::register(repo_details, addr, net)
.into_actor(self) .into_actor(self)
.wait(ctx) .wait(ctx);
// TODO: (#18) watch for changes on dev
} }
} }
} }

View file

@ -3,6 +3,7 @@ use gix::trace::warn;
use tracing::info; use tracing::info;
use crate::server::{ use crate::server::{
actors::repo::ValidateRepo,
config::{self, ForgeType}, config::{self, ForgeType},
forge, forge,
}; };
@ -28,12 +29,13 @@ pub async fn check_next(
} }
Status::Pending => { Status::Pending => {
info!("Checks are pending"); info!("Checks are 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 => { Status::Fail => {
warn!("Checks have failed"); warn!("Checks have failed");
} }
} }
tokio::time::sleep(std::time::Duration::from_secs(10)).await;
addr.do_send(ValidateRepo);
} }
#[derive(Debug)] #[derive(Debug)]

View file

@ -1,5 +1,7 @@
use std::ops::Deref; use std::ops::Deref;
use crate::server::actors::repo::ValidateRepo;
#[derive(Clone, Debug, PartialEq, Eq)] #[derive(Clone, Debug, PartialEq, Eq)]
pub struct WebhookId(String); pub struct WebhookId(String);
impl WebhookId { impl WebhookId {
@ -27,8 +29,10 @@ pub async fn unregister(
pub async fn register( pub async fn register(
_repo_details: crate::server::config::RepoDetails, _repo_details: crate::server::config::RepoDetails,
_addr: actix::prelude::Addr<super::RepoActor>, addr: actix::prelude::Addr<super::RepoActor>,
_net: kxio::network::Network, _net: kxio::network::Network,
) { ) {
// TODO: (#15) register webhook - on success send webhook id to RepoActor // TODO: (#15) register webhook - on success send webhook id to RepoActor
tokio::time::sleep(std::time::Duration::from_secs(10)).await;
addr.do_send(ValidateRepo);
} }