diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index a717261..febfb9e 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -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 diff --git a/crankshaft-docker/src/container.rs b/crankshaft-docker/src/container.rs index ef56a00..dab94b2 100644 --- a/crankshaft-docker/src/container.rs +++ b/crankshaft-docker/src/container.rs @@ -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; @@ -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. diff --git a/crankshaft-engine/src/service/runner/backend/generic/driver.rs b/crankshaft-engine/src/service/runner/backend/generic/driver.rs index 8b4915c..739375e 100644 --- a/crankshaft-engine/src/service/runner/backend/generic/driver.rs +++ b/crankshaft-engine/src/service/runner/backend/generic/driver.rs @@ -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; @@ -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::::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::::Ok(output) }; tokio::task::spawn_blocking(f) diff --git a/crankshaft-engine/src/service/runner/backend/tes.rs b/crankshaft-engine/src/service/runner/backend/tes.rs index b199af9..b4a2e68 100644 --- a/crankshaft-engine/src/service/runner/backend/tes.rs +++ b/crankshaft-engine/src/service/runner/backend/tes.rs @@ -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; @@ -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());