test: add more debug tracing
All checks were successful
Rust / build (push) Successful in 1m28s
ci/woodpecker/push/cron-docker-builder Pipeline was successful
ci/woodpecker/push/push-next Pipeline was successful
ci/woodpecker/push/tag-created Pipeline was successful
ci/woodpecker/cron/cron-docker-builder Pipeline was successful
ci/woodpecker/cron/push-next Pipeline was successful
ci/woodpecker/cron/tag-created Pipeline was successful

This commit is contained in:
Paul Campbell 2024-06-30 19:30:53 +01:00
parent 73ab149aba
commit 40c61fa9ff
3 changed files with 15 additions and 4 deletions

View file

@ -12,7 +12,7 @@ pub struct Positions {
pub dev_commit_history: Vec<git::Commit>,
}
// #[allow(clippy::cognitive_complexity)] // TODO: (#83) reduce complexity
#[allow(clippy::cognitive_complexity)] // TODO: (#83) reduce complexity
pub fn validate_positions(
open_repository: &dyn git::repository::OpenRepositoryLike,
repo_details: &git::RepoDetails,
@ -21,23 +21,29 @@ pub fn validate_positions(
let main_branch = repo_config.branches().main();
let next_branch = repo_config.branches().next();
let dev_branch = repo_config.branches().dev();
tracing::debug!(%main_branch, %next_branch, %dev_branch, "branches");
// Collect Commit Histories for `main`, `next` and `dev` branches
open_repository.fetch()?;
tracing::debug!("fetch okay");
let commit_histories = get_commit_histories(open_repository, &repo_config)?;
tracing::debug!(?commit_histories, "get commit histories okay");
// branch tips
let main =
commit_histories.main.first().cloned().ok_or_else(|| {
Error::NonRetryable(format!("Branch has no commits: {}", main_branch))
})?;
tracing::debug!("main branch okay");
let next =
commit_histories.next.first().cloned().ok_or_else(|| {
Error::NonRetryable(format!("Branch has no commits: {}", next_branch))
})?;
tracing::debug!("next branch okay");
let dev = commit_histories
.dev
.first()
.cloned()
.ok_or_else(|| Error::NonRetryable(format!("Branch has no commits: {}", dev_branch)))?;
tracing::debug!("dev branch okay");
// Validations:
// Dev must be on main branch, else the USER must rebase it
if is_not_based_on(&commit_histories.dev, &main) {
@ -47,6 +53,7 @@ pub fn validate_positions(
dev_branch, main_branch
)));
}
tracing::debug!("dev based on main okay");
// verify that next is on main or at most one commit on top of main, else reset it back to main
if is_not_based_on(
commit_histories
@ -61,11 +68,13 @@ pub fn validate_positions(
tracing::info!("Main not on same commit as next, or it's parent - resetting next to main",);
return reset_next_to_main(open_repository, repo_details, &main, &next, &next_branch);
}
tracing::debug!("next on or near main okay");
// verify that next is an ancestor of dev, else reset it back to main
if is_not_based_on(&commit_histories.dev, &next) {
tracing::info!("Next is not an ancestor of dev - resetting next to main");
return reset_next_to_main(open_repository, repo_details, &main, &next, &next_branch);
}
tracing::debug!("dev based on next okay");
Ok(git::validation::positions::Positions {
main,

View file

@ -59,6 +59,7 @@ impl Handler<actor::messages::ValidateRepo> for actor::RepoActor {
dev,
dev_commit_history,
}) => {
tracing::debug!(%main, %next, %dev, "positions");
if next != main {
actor::do_send(
ctx.address(),

View file

@ -5,7 +5,7 @@ use actix::prelude::*;
use derive_more::Constructor;
use git_next_config::{ForgeAlias, RepoAlias};
use git_next_repo_actor::messages::WebhookNotification;
use tracing::{debug, info};
use tracing::info;
pub struct WebhookRouter {
span: tracing::Span,
@ -36,14 +36,15 @@ impl Handler<WebhookNotification> for WebhookRouter {
let _gaurd = self.span.enter();
let forge_alias = msg.forge_alias();
let repo_alias = msg.repo_alias();
debug!(forge = %forge_alias, repo = %repo_alias, "Router...");
tracing::debug!(forge = %forge_alias, repo = %repo_alias, "Router...");
let Some(forge_repos) = self.recipients.get(forge_alias) else {
tracing::warn!(forge = %forge_alias, "No forge repos found");
return;
};
let Some(recipient) = forge_repos.get(repo_alias) else {
tracing::debug!(forge = %forge_alias, repo = %repo_alias, "No recipient found");
return;
};
info!(repo = %repo_alias, "Sending to Recipient");
recipient.do_send(msg);
}
}