From 52f5c5381aaef484780cb7cdd70b4c9a701dfe16 Mon Sep 17 00:00:00 2001 From: Philipp Herzog Date: Thu, 13 Jun 2024 11:10:18 +0200 Subject: [PATCH] continue building when a remote build fails and report errors afterwards --- src/cli.rs | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/cli.rs b/src/cli.rs index 1ace92e..397999c 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -8,7 +8,7 @@ use std::io::{stdin, stdout, Write}; use clap::{ArgMatches, Clap, FromArgMatches}; use futures_util::future::{join_all, try_join_all}; -use tokio::try_join; +use tokio::{try_join, join}; use crate as deploy; use crate::push::{PushProfileData, PushProfileError}; @@ -600,9 +600,9 @@ async fn run_deploy( } }); - try_join!( + let remote_results = join!( // remote builds can be run asynchronously (per host) - try_join_all(remote_build_map.into_iter().map(deploy_profiles_to_host)), + join_all(remote_build_map.into_iter().map(deploy_profiles_to_host)), async { // run local builds synchronously to prevent hardware deadlocks for data in &local_builds { @@ -614,11 +614,18 @@ async fn run_deploy( let data = data; deploy::push::push_profile(&data).await })).await; - - Ok(()) } - )?; + ).0; + for result in remote_results { + match result { + Err((host, profile, e)) => { + error!("failed building profile {} on host {}: {:?}", profile, host, e); + return Err(RunDeployError::PushProfile(e)); + }, + _ => (), + } + } let mut succeeded: Vec<(&deploy::DeployData, &deploy::DeployDefs)> = vec![]; @@ -750,9 +757,9 @@ pub async fn run(args: Option<&ArgMatches>) -> Result<(), RunError> { Ok(()) } -async fn deploy_profiles_to_host<'a>((_host, profiles): (&str, Vec<&'a PushProfileData<'a>>)) -> Result<(), PushProfileError> { +async fn deploy_profiles_to_host<'a>((host, profiles): (&str, Vec<&'a PushProfileData<'a>>)) -> Result<(), (String, String, PushProfileError)> { for profile in &profiles { - deploy::push::build_profile(profile).await?; + deploy::push::build_profile(profile).await.map_err(|e| (host.to_string(), profile.deploy_data.profile_name.to_string(), e))?; }; Ok(()) }