Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cli): fix for meta-cli deploy exit with code 0 on failure #600

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion meta-cli/src/cli/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,11 @@ mod default_mode {
};

log::debug!("loader stopped, stopping pusher");
pusher.stop().await?;
let result = pusher.stop().await;
if let Err(e) = result {
System::current().stop_with_code(1);
return Err(e);
}
ret
}

Expand Down
27 changes: 26 additions & 1 deletion meta-cli/src/deploy/actors/push_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ impl PushManagerBuilder {
retry_config: self.retry_config,
typegraph_paths: HashMap::new(),
one_time_push_options: HashMap::new(),
failed_push_exists: false,
}
})
}
Expand All @@ -90,6 +91,7 @@ pub struct PushManagerActor {
typegraph_paths: HashMap<String, PathBuf>,
// maps: typegraph_key -> option
one_time_push_options: HashMap<String, Vec<OneTimePushOption>>,
failed_push_exists: bool,
}

impl PushManagerActor {
Expand Down Expand Up @@ -363,6 +365,9 @@ impl Handler<PushFinished> for PushManagerActor {
name = name.cyan()
));
}
if !self.failed_push_exists {
self.failed_push_exists = !msg.success;
}

let res = self.remove_active(&msg.push.typegraph);
let Some(CancelationStatus(is_cancelled)) = res else {
Expand Down Expand Up @@ -412,6 +417,20 @@ impl Handler<Stop> for PushManagerActor {
}
}

#[derive(Message)]
#[rtype(result = "()")]
struct SendBackFailedStatus {
failure_tx: oneshot::Sender<bool>,
}

impl Handler<SendBackFailedStatus> for PushManagerActor {
type Result = ();

fn handle(&mut self, msg: SendBackFailedStatus, _ctx: &mut Self::Context) -> Self::Result {
msg.failure_tx.send(self.failed_push_exists).unwrap();
}
}

#[derive(Message)]
#[rtype(result = "()")]
struct CancelAllFromModule {
Expand Down Expand Up @@ -441,7 +460,13 @@ impl PushManager for Addr<PushManagerActor> {
self.do_send(Stop { tx });
rx.await?;
log::trace!("PushManager stopped");
Ok(())
let (failure_tx, failure_rx) = oneshot::channel();
self.do_send(SendBackFailedStatus { failure_tx });
let failed = failure_rx.await.unwrap();
match failed {
false => Ok(()),
true => Err(anyhow::anyhow!("Pushing one or more typegraphs failed")),
}
}

async fn cancel_all_from(&self, path: &Path) -> Result<()> {
Expand Down
1 change: 1 addition & 0 deletions typegate/tests/e2e/cli/deploy_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ Meta.test(
});

try {
await reset("e2e7895alt");
await deploy(port);
} catch (e) {
assertStringIncludes(
Expand Down
Loading