Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
parent
52266599e2
commit
93e73cc66e
@ -17,6 +17,7 @@ eyre.workspace = true
|
||||
clap.workspace = true
|
||||
async-trait.workspace = true
|
||||
futures.workspace = true
|
||||
tokio.workspace = true
|
||||
|
||||
[dev-dependencies]
|
||||
tokio.workspace = true
|
||||
|
@ -1,18 +1,19 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use async_trait::async_trait;
|
||||
use tokio::sync::Mutex;
|
||||
|
||||
pub struct CuddleCI {
|
||||
pr_action: Arc<dyn PullRequestAction + Send + Sync>,
|
||||
main_action: Arc<dyn MainAction + Send + Sync>,
|
||||
release_action: Arc<dyn ReleaseAction + Send + Sync>,
|
||||
pr_action: Arc<Mutex<dyn PullRequestAction + Send + Sync>>,
|
||||
main_action: Arc<Mutex<dyn MainAction + Send + Sync>>,
|
||||
release_action: Arc<Mutex<dyn ReleaseAction + Send + Sync>>,
|
||||
}
|
||||
|
||||
impl CuddleCI {
|
||||
pub fn new(
|
||||
pr: Arc<dyn PullRequestAction + Send + Sync>,
|
||||
main: Arc<dyn MainAction + Send + Sync>,
|
||||
release: Arc<dyn ReleaseAction + Send + Sync>,
|
||||
pr: Arc<Mutex<dyn PullRequestAction + Send + Sync>>,
|
||||
main: Arc<Mutex<dyn MainAction + Send + Sync>>,
|
||||
release: Arc<Mutex<dyn ReleaseAction + Send + Sync>>,
|
||||
) -> Self {
|
||||
Self {
|
||||
pr_action: pr,
|
||||
@ -21,19 +22,25 @@ impl CuddleCI {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn with_pull_request(&mut self, pr: Arc<dyn PullRequestAction + Send + Sync>) -> &mut Self {
|
||||
pub fn with_pull_request(
|
||||
&mut self,
|
||||
pr: Arc<Mutex<dyn PullRequestAction + Send + Sync>>,
|
||||
) -> &mut Self {
|
||||
self.pr_action = pr;
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_main(&mut self, main: Arc<dyn MainAction + Send + Sync>) -> &mut Self {
|
||||
pub fn with_main(&mut self, main: Arc<Mutex<dyn MainAction + Send + Sync>>) -> &mut Self {
|
||||
self.main_action = main;
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_release(&mut self, release: Arc<dyn ReleaseAction + Send + Sync>) -> &mut Self {
|
||||
pub fn with_release(
|
||||
&mut self,
|
||||
release: Arc<Mutex<dyn ReleaseAction + Send + Sync>>,
|
||||
) -> &mut Self {
|
||||
self.release_action = release;
|
||||
|
||||
self
|
||||
@ -52,17 +59,17 @@ impl CuddleCI {
|
||||
Some((name, args)) => match (name, args) {
|
||||
("pr", _args) => {
|
||||
eprintln!("starting pr validate");
|
||||
self.pr_action.execute_pull_request().await?;
|
||||
self.pr_action.lock().await.execute_pull_request().await?;
|
||||
eprintln!("finished pr validate");
|
||||
}
|
||||
("main", _args) => {
|
||||
eprintln!("starting main validate");
|
||||
self.main_action.execute_main().await?;
|
||||
self.main_action.lock().await.execute_main().await?;
|
||||
eprintln!("finished main validate");
|
||||
}
|
||||
("release", _args) => {
|
||||
eprintln!("starting release validate");
|
||||
self.release_action.execute_release().await?;
|
||||
self.release_action.lock().await.execute_release().await?;
|
||||
eprintln!("finished release validate");
|
||||
}
|
||||
(command_name, _) => {
|
||||
@ -79,9 +86,9 @@ impl CuddleCI {
|
||||
impl Default for CuddleCI {
|
||||
fn default() -> Self {
|
||||
Self::new(
|
||||
Arc::new(DefaultPullRequestAction {}),
|
||||
Arc::new(DefaultMainAction {}),
|
||||
Arc::new(DefaultReleaseAction {}),
|
||||
Arc::new(Mutex::new(DefaultPullRequestAction {})),
|
||||
Arc::new(Mutex::new(DefaultMainAction {})),
|
||||
Arc::new(Mutex::new(DefaultReleaseAction {})),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
use async_trait::async_trait;
|
||||
use dagger_sdk::Container;
|
||||
use std::{future::Future, pin::Pin};
|
||||
|
||||
pub type DynMiddleware = Box<dyn DaggerMiddleware + Send + Sync>;
|
||||
|
||||
#[async_trait]
|
||||
|
Loading…
Reference in New Issue
Block a user