summaryrefslogtreecommitdiff
path: root/src/ci_runner.rs
diff options
context:
space:
mode:
authoriximeow <git@iximeow.net>2022-12-28 10:00:27 +0000
committeriximeow <git@iximeow.net>2022-12-28 10:00:27 +0000
commit2903c0696ff1851cf6598bff456c30b9f64529a6 (patch)
tree04d1916c894a276d83be84c50333155947a5b2de /src/ci_runner.rs
parentf60c18aadd8d776751cb61140eef578424f8cffc (diff)
support Build.run parameters, more consistently insert tmpdir/ into paths
Diffstat (limited to 'src/ci_runner.rs')
-rw-r--r--src/ci_runner.rs29
1 files changed, 27 insertions, 2 deletions
diff --git a/src/ci_runner.rs b/src/ci_runner.rs
index de423eb..a88b135 100644
--- a/src/ci_runner.rs
+++ b/src/ci_runner.rs
@@ -291,15 +291,40 @@ impl RunningJob {
}
}
- async fn run_command(&self, command: &[String]) -> Result<(), String> {
+ async fn run_command(&mut self, command: &[String], working_dir: Option<&str>) -> Result<(), String> {
+ self.client.send(serde_json::json!({
+ "kind": "command",
+ "state": "started",
+ "command": command,
+ "cwd": working_dir,
+ "id": 1,
+ })).await.unwrap();
+
let mut cmd = Command::new(&command[0]);
+ let cwd = match working_dir {
+ Some(dir) => {
+ format!("tmpdir/{}", dir)
+ },
+ None => {
+ "tmpdir".to_string()
+ }
+ };
+ eprintln!("running {:?} in {}", &command, &cwd);
let human_name = command.join(" ");
cmd
- .current_dir("tmpdir")
+ .current_dir(cwd)
.args(&command[1..]);
let cmd_res = self.execute_command(cmd, &format!("{} log", human_name), &human_name).await?;
+ self.client.send(serde_json::json!({
+ "kind": "command",
+ "state": "finished",
+ "exit_code": cmd_res.code(),
+ "id": 1,
+ })).await.unwrap();
+
+
if !cmd_res.success() {
return Err(format!("{} failed: {:?}", &human_name, cmd_res));
}