diff --git a/Cargo.toml b/Cargo.toml index d5e7c16..c752d80 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,6 +9,7 @@ members = [ "crates/forge-forgejo", "crates/forge-github", "crates/repo-actor", + "crates/webhook-actor", ] [workspace.package] @@ -29,6 +30,7 @@ git-next-forge = { path = "crates/forge" } git-next-forge-forgejo = { path = "crates/forge-forgejo" } git-next-forge-github = { path = "crates/forge-github" } git-next-repo-actor = { path = "crates/repo-actor" } +git-next-webhook-actor = { path = "crates/webhook-actor" } # CLI parsing clap = { version = "4.5", features = ["cargo", "derive"] } diff --git a/crates/git/src/repository/open/otest.rs b/crates/git/src/repository/open/otest.rs index 7fed767..4a44548 100644 --- a/crates/git/src/repository/open/otest.rs +++ b/crates/git/src/repository/open/otest.rs @@ -67,6 +67,7 @@ pub struct TestOpenRepository { push_counter: Arc>, real: git::repository::RealOpenRepository, } +#[cfg(not(tarpaulin_include))] impl git::repository::OpenRepositoryLike for TestOpenRepository { fn remote_branches(&self) -> git::push::Result> { self.real.remote_branches() diff --git a/crates/server/Cargo.toml b/crates/server/Cargo.toml index 3d21f08..488c11e 100644 --- a/crates/server/Cargo.toml +++ b/crates/server/Cargo.toml @@ -8,37 +8,16 @@ git-next-config = { workspace = true } git-next-git = { workspace = true } git-next-forge = { workspace = true } git-next-repo-actor = { workspace = true } +git-next-webhook-actor = { workspace = true } # logging console-subscriber = { workspace = true } tracing = { workspace = true } tracing-subscriber = { workspace = true } -# base64 decoding -base64 = { workspace = true } - -# git -async-trait = { workspace = true } - # fs/network kxio = { workspace = true } -# TOML parsing -serde = { workspace = true } -serde_json = { workspace = true } -toml = { workspace = true } - -# Secrets and Password -secrecy = { workspace = true } - -# Conventional Commit check -git-conventional = { workspace = true } - -# Webhooks -bytes = { workspace = true } -ulid = { workspace = true } -warp = { workspace = true } - # boilerplate derive_more = { workspace = true } thiserror = { workspace = true } @@ -49,7 +28,6 @@ inotify = { workspace = true } # Actors actix = { workspace = true } actix-rt = { workspace = true } -tokio = { workspace = true } [dev-dependencies] # Testing diff --git a/crates/server/src/actors/mod.rs b/crates/server/src/actors/mod.rs index baf0b68..771b9fe 100644 --- a/crates/server/src/actors/mod.rs +++ b/crates/server/src/actors/mod.rs @@ -1,4 +1,3 @@ pub mod file_watcher; pub mod messages; pub mod server; -pub mod webhook; diff --git a/crates/server/src/actors/server.rs b/crates/server/src/actors/server.rs index 54bdd1d..b6567a9 100644 --- a/crates/server/src/actors/server.rs +++ b/crates/server/src/actors/server.rs @@ -3,6 +3,7 @@ use std::path::PathBuf; use actix::prelude::*; +use crate::actors::{file_watcher::FileUpdated, messages::ReceiveServerConfig}; use config::server::{ServerConfig, ServerStorage, Webhook}; use git_next_config::{ self as config, ForgeAlias, ForgeConfig, GitDir, RepoAlias, ServerRepoConfig, @@ -10,14 +11,10 @@ use git_next_config::{ use git_next_git::{repository::RepositoryFactory, Generation, RepoDetails}; use git_next_repo_actor::messages::CloneRepo; use git_next_repo_actor::RepoActor; +use git_next_webhook_actor as webhook; use kxio::{fs::FileSystem, network::Network}; use tracing::{error, info, warn}; - -use crate::actors::{ - file_watcher::FileUpdated, - messages::ReceiveServerConfig, - webhook::{AddWebhookRecipient, ShutdownWebhook, WebhookActor, WebhookRouter}, -}; +use webhook::{AddWebhookRecipient, ShutdownWebhook, WebhookActor, WebhookRouter}; #[derive(Debug, derive_more::Display, derive_more::From)] pub enum Error { @@ -98,7 +95,7 @@ impl Handler for Server { // Webhook Server info!("Starting Webhook Server..."); - let webhook_router = WebhookRouter::new().start(); + let webhook_router = WebhookRouter::default().start(); let webhook = server_config.webhook(); // Forge Actors diff --git a/crates/webhook-actor/Cargo.toml b/crates/webhook-actor/Cargo.toml new file mode 100644 index 0000000..8d1eb5d --- /dev/null +++ b/crates/webhook-actor/Cargo.toml @@ -0,0 +1,31 @@ +[package] +name = "git-next-webhook-actor" +version = { workspace = true } +edition = { workspace = true } + +[dependencies] +git-next-config = { workspace = true } +git-next-repo-actor = { workspace = true } + +# logging +tracing = { workspace = true } + +# Webhooks +bytes = { workspace = true } +warp = { workspace = true } + +# boilerplate +derive_more = { workspace = true } + +# Actors +actix = { workspace = true } + +[dev-dependencies] +# Testing +# assert2 = { workspace = true } + +[lints.clippy] +nursery = { level = "warn", priority = -1 } +# pedantic = "warn" +unwrap_used = "warn" +expect_used = "warn" diff --git a/crates/server/src/actors/webhook/mod.rs b/crates/webhook-actor/src/lib.rs similarity index 97% rename from crates/server/src/actors/webhook/mod.rs rename to crates/webhook-actor/src/lib.rs index 287e805..cf37e0d 100644 --- a/crates/server/src/actors/webhook/mod.rs +++ b/crates/webhook-actor/src/lib.rs @@ -1,4 +1,4 @@ -// crate::server::actors::webhook +// use actix::prelude::*; mod router; diff --git a/crates/server/src/actors/webhook/router.rs b/crates/webhook-actor/src/router.rs similarity index 96% rename from crates/server/src/actors/webhook/router.rs rename to crates/webhook-actor/src/router.rs index 9179de7..8ecfb08 100644 --- a/crates/server/src/actors/webhook/router.rs +++ b/crates/webhook-actor/src/router.rs @@ -11,6 +11,11 @@ pub struct WebhookRouter { span: tracing::Span, recipients: BTreeMap>>, } +impl Default for WebhookRouter { + fn default() -> Self { + Self::new() + } +} impl WebhookRouter { pub fn new() -> Self { let span = tracing::info_span!("WebhookRouter"); diff --git a/crates/server/src/actors/webhook/server.rs b/crates/webhook-actor/src/server.rs similarity index 100% rename from crates/server/src/actors/webhook/server.rs rename to crates/webhook-actor/src/server.rs