Skip to content

Commit

Permalink
Merge pull request #1 from stjude-rust-labs/windows
Browse files Browse the repository at this point in the history
revise: fixes Windows issues from initial commit
  • Loading branch information
claymcleod authored Sep 20, 2024
2 parents 78be9f9 + 2c73d90 commit 082b1dd
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 11 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ jobs:
- run: cargo clippy --all-features -- --deny warnings

test:
runs-on: ubuntu-22.04
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v4
- name: Update Rust
Expand Down
17 changes: 15 additions & 2 deletions crankshaft-docker/src/container.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
mod builder;

use std::io::Cursor;
#[cfg(unix)]
use std::os::unix::process::ExitStatusExt as _;
#[cfg(windows)]
use std::os::windows::process::ExitStatusExt as _;
use std::process::ExitStatus;
use std::process::Output;

Expand Down Expand Up @@ -168,11 +171,21 @@ impl Container {
.exit_code
.expect("exit code should be present at this point") as i32;

Ok(Output {
#[cfg(unix)]
let output = Output {
status: ExitStatus::from_raw(status),
stdout,
stderr,
})
};

#[cfg(windows)]
let output = Output {
status: ExitStatus::from_raw(status as u32),
stdout,
stderr,
};

Ok(output)
}

/// Removes a container with the level of force specified.
Expand Down
17 changes: 15 additions & 2 deletions crankshaft-engine/src/service/runner/backend/generic/driver.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
//! Command drivers in a generic backend.

use std::io::Read as _;
#[cfg(unix)]
use std::os::unix::process::ExitStatusExt;
#[cfg(windows)]
use std::os::windows::process::ExitStatusExt;
use std::process::ExitStatus;
use std::process::Output;
use std::time::Duration;
Expand Down Expand Up @@ -391,11 +394,21 @@ async fn run_ssh_command(
.map_err(Error::SSH2)
.context("waiting for the SSH channel to be closed from the client's end")?;

eyre::Result::<Output>::Ok(Output {
#[cfg(unix)]
let output = Output {
status: ExitStatus::from_raw(status),
stdout,
stderr,
})
};

#[cfg(windows)]
let output = Output {
status: ExitStatus::from_raw(status as u32),
stdout,
stderr,
};

eyre::Result::<Output>::Ok(output)
};

tokio::task::spawn_blocking(f)
Expand Down
27 changes: 21 additions & 6 deletions crankshaft-engine/src/service/runner/backend/tes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
//!
//! [tes]: https://www.ga4gh.org/product/task-execution-service-tes/

#[cfg(unix)]
use std::os::unix::process::ExitStatusExt;
#[cfg(windows)]
use std::os::windows::process::ExitStatusExt;
use std::process::ExitStatus;
use std::process::Output;
use std::sync::Arc;
Expand Down Expand Up @@ -99,12 +102,24 @@ fn run(backend: &Backend, task: Task) -> BoxFuture<'static, TaskResult> {
.unwrap()
.into_iter()
.flat_map(|task| task.logs)
.map(|log| Output {
status: ExitStatus::from_raw(
log.exit_code.expect("exit code to be present") as i32,
),
stdout: log.stdout.unwrap_or_default().as_bytes().to_vec(),
stderr: log.stderr.unwrap_or_default().as_bytes().to_vec(),
.map(|log| {
let status = log.exit_code.expect("exit code to be present");

#[cfg(unix)]
let output = Output {
status: ExitStatus::from_raw(status as i32),
stdout: log.stdout.unwrap_or_default().as_bytes().to_vec(),
stderr: log.stderr.unwrap_or_default().as_bytes().to_vec(),
};

#[cfg(windows)]
let output = Output {
status: ExitStatus::from_raw(status),
stdout: log.stdout.unwrap_or_default().as_bytes().to_vec(),
stderr: log.stderr.unwrap_or_default().as_bytes().to_vec(),
};

output
});

let mut executions = NonEmpty::new(results.next().unwrap());
Expand Down

0 comments on commit 082b1dd

Please sign in to comment.