fix: don't reload config when updating next branch

The StartRepo handler loads the config before then sending the
ValidateRepo message. However, we already have the config, so reloading
it isn't needed.

Added todo markers on sleep and dispatching of ValidateRepo where it is
used as a stop-gap until we have working webhook integration.

Add todo markers for checking valid commit messages before advancing
next branch.
This commit is contained in:
Paul Campbell 2024-04-12 09:55:50 +01:00
parent 0b427f1d4c
commit 3735afb2f8
2 changed files with 9 additions and 3 deletions

View file

@ -6,12 +6,12 @@ use kxio::network;
use tracing::{error, info, warn}; use tracing::{error, info, warn};
use crate::server::{ use crate::server::{
actors::repo::branch, actors::repo::{branch, ValidateRepo},
config::{self, BranchName}, config::{self, BranchName},
forge, forge,
}; };
use super::{RepoActor, StartMonitoring, StartRepo}; use super::{RepoActor, StartMonitoring};
#[tracing::instrument(fields(forge_name = %repo_details.forge.name, repo_name = %repo_details.name), skip_all)] #[tracing::instrument(fields(forge_name = %repo_details.forge.name, repo_name = %repo_details.name), skip_all)]
pub async fn validate_positions( pub async fn validate_positions(
@ -52,6 +52,8 @@ pub async fn validate_positions(
) )
.is_ok() .is_ok()
{ {
// TODO : (#18) sleep and restart while we don't have webhooks
tokio::time::sleep(std::time::Duration::from_secs(10)).await;
addr.do_send(super::ValidateRepo) addr.do_send(super::ValidateRepo)
} }
return; return;
@ -121,6 +123,8 @@ pub async fn advance_next(
warn!("No commits to advance next to"); warn!("No commits to advance next to");
return; return;
}; };
// TODO: (#33) get commit message for 'commit'
// TODO: (#33) verify commit message is valid
match reset( match reset(
&repo_config.branches().next(), &repo_config.branches().next(),
commit, commit,
@ -129,8 +133,9 @@ pub async fn advance_next(
) { ) {
Ok(_) => { Ok(_) => {
info!("Success"); info!("Success");
// TODO : (#18) sleep and restart while we don't have webhooks
tokio::time::sleep(std::time::Duration::from_secs(10)).await; tokio::time::sleep(std::time::Duration::from_secs(10)).await;
addr.do_send(StartRepo); addr.do_send(ValidateRepo);
} }
Err(err) => { Err(err) => {
warn!(?err, "Failed") warn!(?err, "Failed")

View file

@ -34,6 +34,7 @@ pub async fn check_next(
warn!("Checks have failed"); warn!("Checks have failed");
} }
} }
// TODO : (#18) sleep and restart while we don't have webhooks
tokio::time::sleep(std::time::Duration::from_secs(10)).await; tokio::time::sleep(std::time::Duration::from_secs(10)).await;
addr.do_send(ValidateRepo); addr.do_send(ValidateRepo);
} }