Skip to content

Commit

Permalink
continue building when a remote build fails and report errors afterwards
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilTaken committed Jun 13, 2024
1 parent 1cc6e35 commit 52f5c53
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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 {
Expand All @@ -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![];

Expand Down Expand Up @@ -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(())
}

0 comments on commit 52f5c53

Please sign in to comment.