Skip to content

Commit 169e5f4

Browse files
authored
fix(cli): fix for meta-cli deploy exit with code 0 on failure (#600)
fix the issue where `meta-cli deploy` command exits with code 0 on failure. #### Motivation and context bug fix #### Migration notes No changes needed. ### Checklist - [ ] The change come with new or modified tests - [ ] Hard-to-understand functions have explanatory comments - [ ] End-user documentation is updated to reflect the change
1 parent fffe530 commit 169e5f4

File tree

3 files changed

+32
-2
lines changed

3 files changed

+32
-2
lines changed

meta-cli/src/cli/deploy.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,11 @@ mod default_mode {
259259
};
260260

261261
log::debug!("loader stopped, stopping pusher");
262-
pusher.stop().await?;
262+
let result = pusher.stop().await;
263+
if let Err(e) = result {
264+
System::current().stop_with_code(1);
265+
return Err(e);
266+
}
263267
ret
264268
}
265269

meta-cli/src/deploy/actors/push_manager.rs

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ impl PushManagerBuilder {
7272
retry_config: self.retry_config,
7373
typegraph_paths: HashMap::new(),
7474
one_time_push_options: HashMap::new(),
75+
failed_push_exists: false,
7576
}
7677
})
7778
}
@@ -90,6 +91,7 @@ pub struct PushManagerActor {
9091
typegraph_paths: HashMap<String, PathBuf>,
9192
// maps: typegraph_key -> option
9293
one_time_push_options: HashMap<String, Vec<OneTimePushOption>>,
94+
failed_push_exists: bool,
9395
}
9496

9597
impl PushManagerActor {
@@ -363,6 +365,9 @@ impl Handler<PushFinished> for PushManagerActor {
363365
name = name.cyan()
364366
));
365367
}
368+
if !self.failed_push_exists {
369+
self.failed_push_exists = !msg.success;
370+
}
366371

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

420+
#[derive(Message)]
421+
#[rtype(result = "()")]
422+
struct SendBackFailedStatus {
423+
failure_tx: oneshot::Sender<bool>,
424+
}
425+
426+
impl Handler<SendBackFailedStatus> for PushManagerActor {
427+
type Result = ();
428+
429+
fn handle(&mut self, msg: SendBackFailedStatus, _ctx: &mut Self::Context) -> Self::Result {
430+
msg.failure_tx.send(self.failed_push_exists).unwrap();
431+
}
432+
}
433+
415434
#[derive(Message)]
416435
#[rtype(result = "()")]
417436
struct CancelAllFromModule {
@@ -441,7 +460,13 @@ impl PushManager for Addr<PushManagerActor> {
441460
self.do_send(Stop { tx });
442461
rx.await?;
443462
log::trace!("PushManager stopped");
444-
Ok(())
463+
let (failure_tx, failure_rx) = oneshot::channel();
464+
self.do_send(SendBackFailedStatus { failure_tx });
465+
let failed = failure_rx.await.unwrap();
466+
match failed {
467+
false => Ok(()),
468+
true => Err(anyhow::anyhow!("Pushing one or more typegraphs failed")),
469+
}
445470
}
446471

447472
async fn cancel_all_from(&self, path: &Path) -> Result<()> {

typegate/tests/e2e/cli/deploy_test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ Meta.test(
114114
});
115115

116116
try {
117+
await reset("e2e7895alt");
117118
await deploy(port);
118119
} catch (e) {
119120
assertStringIncludes(

0 commit comments

Comments
 (0)