Compare commits

..

2 commits

Author SHA1 Message Date
bd6b0b2d31 WIP: feat(tui): update state model from server messages
All checks were successful
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
2024-08-22 19:55:32 +01:00
7a4f9a45a6 fix(github): register webhook with valid callback url
All checks were successful
Rust / build (push) Successful in 8m58s
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
Release Please / Release-plz (push) Successful in 1m33s
2024-08-22 19:55:32 +01:00
6 changed files with 19 additions and 10 deletions

View file

@ -18,22 +18,26 @@ impl Handler<CloneRepo> for RepoActor {
#[instrument(name = "RepoActor::CloneRepo", skip_all, fields(repo = %self.repo_details))] #[instrument(name = "RepoActor::CloneRepo", skip_all, fields(repo = %self.repo_details))]
fn handle(&mut self, _msg: CloneRepo, ctx: &mut Self::Context) -> Self::Result { fn handle(&mut self, _msg: CloneRepo, ctx: &mut Self::Context) -> Self::Result {
logger(self.log.as_ref(), "Handler: CloneRepo: start"); logger(self.log.as_ref(), "Handler: CloneRepo: start");
self.update_tui(RepoUpdate::Cloning); self.update_tui(RepoUpdate::Opening);
debug!("Handler: CloneRepo: start"); debug!("Handler: CloneRepo: start");
match git::repository::open(&*self.repository_factory, &self.repo_details) { match git::repository::open(&*self.repository_factory, &self.repo_details) {
Ok(repository) => { Ok(repository) => {
logger(self.log.as_ref(), "open okay"); logger(self.log.as_ref(), "open okay");
debug!("open okay"); debug!("open okay");
self.update_tui(RepoUpdate::Opened);
self.open_repository.replace(repository); self.open_repository.replace(repository);
if self.repo_details.repo_config.is_none() { if self.repo_details.repo_config.is_none() {
self.update_tui(RepoUpdate::LoadingConfigFromRepo);
do_send(&ctx.address(), LoadConfigFromRepo, self.log.as_ref()); do_send(&ctx.address(), LoadConfigFromRepo, self.log.as_ref());
} else { } else {
self.update_tui(RepoUpdate::RegisteringWebhook);
do_send(&ctx.address(), RegisterWebhook::new(), self.log.as_ref()); do_send(&ctx.address(), RegisterWebhook::new(), self.log.as_ref());
} }
} }
Err(err) => { Err(err) => {
logger(self.log.as_ref(), "open failed"); logger(self.log.as_ref(), "open failed");
warn!("Could not open repo: {err:?}"); warn!("Could not open repo: {err:?}");
self.alert_tui(err.to_string());
} }
} }
debug!("Handler: CloneRepo: finish"); debug!("Handler: CloneRepo: finish");

View file

@ -1,7 +1,7 @@
// //
use actix::prelude::*; use actix::prelude::*;
use tracing::{debug, Instrument as _}; use tracing::{debug, error, Instrument as _};
use crate::{ use crate::{
repo::{ repo::{
@ -33,7 +33,7 @@ impl Handler<RegisterWebhook> for RepoActor {
async move { async move {
match forge.register_webhook(&repo_listen_url).await { match forge.register_webhook(&repo_listen_url).await {
Ok(registered_webhook) => { Ok(registered_webhook) => {
debug!(?registered_webhook, ""); debug!(?registered_webhook, "webhook registered");
do_send( do_send(
&addr, &addr,
WebhookRegistered::from(registered_webhook), WebhookRegistered::from(registered_webhook),
@ -41,6 +41,7 @@ impl Handler<RegisterWebhook> for RepoActor {
); );
} }
Err(err) => { Err(err) => {
error!(?err, "failed to register webhook");
notify_user( notify_user(
notify_user_recipient.as_ref(), notify_user_recipient.as_ref(),
UserNotification::WebhookRegistration { UserNotification::WebhookRegistration {
@ -56,6 +57,8 @@ impl Handler<RegisterWebhook> for RepoActor {
.in_current_span() .in_current_span()
.into_actor(self) .into_actor(self)
.wait(ctx); .wait(ctx);
} else {
self.alert_tui("already have a webhook id - cant register webhook");
} }
} }
} }

View file

@ -73,7 +73,7 @@ pub enum RepoUpdate {
AdvancingMain { AdvancingMain {
commit: git::Commit, commit: git::Commit,
}, },
Cloning, Opening,
LoadingConfigFromRepo, LoadingConfigFromRepo,
ReceiveCIStatus { ReceiveCIStatus {
status: Status, status: Status,
@ -88,6 +88,7 @@ pub enum RepoUpdate {
push: Push, push: Push,
}, },
RegisteredWebhook, RegisteredWebhook,
Opened,
} }
message!( message!(

View file

@ -56,8 +56,11 @@ impl Handler<ServerUpdate> for Tui {
RepoUpdate::AdvancingMain { commit } => { RepoUpdate::AdvancingMain { commit } => {
repo_state.update_message(format!("advancing main to {commit}")); repo_state.update_message(format!("advancing main to {commit}"));
} }
RepoUpdate::Cloning => { RepoUpdate::Opening => {
repo_state.update_message("cloning..."); repo_state.update_message("opening...");
}
RepoUpdate::Opened => {
repo_state.update_message("opened");
} }
RepoUpdate::LoadingConfigFromRepo => { RepoUpdate::LoadingConfigFromRepo => {
repo_state.update_message("loading config from repo..."); repo_state.update_message("loading config from repo...");

View file

@ -5,11 +5,9 @@ use ratatui::{
buffer::Buffer, buffer::Buffer,
layout::{Constraint, Direction, Layout, Rect}, layout::{Constraint, Direction, Layout, Rect},
text::{Line, Text}, text::{Line, Text},
widgets::{Paragraph, Widget}, widgets::Widget,
}; };
use crate::trace_dbg;
pub struct ConfiguredRepoWidget<'a> { pub struct ConfiguredRepoWidget<'a> {
pub repo_alias: &'a RepoAlias, pub repo_alias: &'a RepoAlias,
pub message: &'a str, pub message: &'a str,

View file

@ -35,7 +35,7 @@ pub async fn register(
"active": true, "active": true,
"events": ["push"], "events": ["push"],
"config": { "config": {
"url": repo_listen_url.as_ref(), "url": repo_listen_url.to_string(),
"content_type": "json", "content_type": "json",
"secret": authorisation.to_string(), "secret": authorisation.to_string(),
"insecure_ssl": "0", "insecure_ssl": "0",