From fad8aef22f70a3702e16fee4eef0d1f79b559682 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Mon, 21 Oct 2019 15:34:01 +0200 Subject: [PATCH 1/5] Copy back the lock file. --- src/main.rs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/main.rs b/src/main.rs index c1d1239..5e109fb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -21,6 +21,12 @@ enum Opts { )] copy_back: bool, + #[structopt( + long = "no-copy-lock", + help = "don't transfer the Cargo.lock file back to the local machine" + )] + no_copy_lock: bool, + #[structopt( long = "manifest-path", help = "Path to the manifest to execute", @@ -80,6 +86,7 @@ fn main() { let Opts::Remote { remote, copy_back, + no_copy_lock, manifest_path, hidden, command, @@ -193,4 +200,26 @@ fn main() { exit(-6); }); } + + if !no_copy_lock { + info!("Transferring Cargo.lock file back to client."); + Command::new("rsync") + .arg("-a") + .arg("--delete") + .arg("--compress") + .arg("--info=progress2") + .arg(format!("{}:{}/Cargo.lock", build_server, build_path)) + .arg(format!("{}/Cargo.lock", project_dir.to_string_lossy())) + .stdout(Stdio::inherit()) + .stderr(Stdio::inherit()) + .stdin(Stdio::inherit()) + .output() + .unwrap_or_else(|e| { + error!( + "Failed to transfer Cargo.lock back to local machine (error: {})", + e + ); + exit(-6); + }); + } } From bd053415e12c02c61853311e72ea397ad480d7d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Mon, 21 Oct 2019 15:52:45 +0200 Subject: [PATCH 2/5] Propagate error code. --- src/main.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 5e109fb..43b108f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -166,7 +166,7 @@ fn main() { ); info!("Starting build process."); - Command::new("ssh") + let output = Command::new("ssh") .arg("-t") .arg(&build_server) .arg(build_command) @@ -222,4 +222,8 @@ fn main() { exit(-6); }); } + + if !output.status.success() { + exit(output.status.code().unwrap_or(0)) + } } From 09db6b2aa93349ab0f6480756ac1eff9bfaa7b70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Mon, 21 Oct 2019 16:00:52 +0200 Subject: [PATCH 3/5] Allow transferring only a subset of files. --- src/main.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index 43b108f..d5320c7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -17,9 +17,9 @@ enum Opts { #[structopt( short = "c", long = "copy-back", - help = "transfer the target folder back to the local machine" + help = "transfer the target folder or specific file from that folder back to the local machine" )] - copy_back: bool, + copy_back: Option>, #[structopt( long = "no-copy-lock", @@ -179,15 +179,16 @@ fn main() { exit(-5); }); - if copy_back { + if let Some(file_name) = copy_back { info!("Transferring artifacts back to client."); + let file_name = file_name.unwrap_or_else(String::new); Command::new("rsync") .arg("-a") .arg("--delete") .arg("--compress") .arg("--info=progress2") - .arg(format!("{}:{}/target/", build_server, build_path)) - .arg(format!("{}/target/", project_dir.to_string_lossy())) + .arg(format!("{}:{}/target/{}", build_server, build_path, file_name)) + .arg(format!("{}/target/{}", project_dir.to_string_lossy(), file_name)) .stdout(Stdio::inherit()) .stderr(Stdio::inherit()) .stdin(Stdio::inherit()) From deaa45792595130f7ad40089eb13765c57f4d68c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Mon, 21 Oct 2019 16:01:49 +0200 Subject: [PATCH 4/5] Change error code for Cargo.lock --- src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index d5320c7..e2d53f7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -220,7 +220,7 @@ fn main() { "Failed to transfer Cargo.lock back to local machine (error: {})", e ); - exit(-6); + exit(-7); }); } From 700369a5f9ea0938648cc5360917a73ee06fdc7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Fri, 25 Oct 2019 09:34:38 +0200 Subject: [PATCH 5/5] Change to error if code is not present (Unix kill-by-signal). --- src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index e2d53f7..076ba24 100644 --- a/src/main.rs +++ b/src/main.rs @@ -225,6 +225,6 @@ fn main() { } if !output.status.success() { - exit(output.status.code().unwrap_or(0)) + exit(output.status.code().unwrap_or(1)) } }