From 8f9c6e1647b4155d671cab396f20ed3046509d14 Mon Sep 17 00:00:00 2001 From: fmaccha Date: Mon, 29 Jul 2024 18:45:53 +0900 Subject: [PATCH 1/3] Remove the if statement that skipping the CWL test on M1 Mac since it was a temporary workaround. #11 --- tests/integration_tests.rs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/tests/integration_tests.rs b/tests/integration_tests.rs index 57ab830..2db1b2f 100644 --- a/tests/integration_tests.rs +++ b/tests/integration_tests.rs @@ -240,12 +240,6 @@ fn can_be_verbose() { #[test] // 9. -c cwl.conf fn can_run_cwl() { - // TEMPORARY: skip this test on M1 Mac due (issue #9) - // This will be removed when tataki supports M1 Mac. - if is_running_on_m1_mac() { - return; - } - check_and_create_cache_dir().expect("Failed to create the cache directory"); let out = tataki( From 75f5cab003ee2eed7c1d0527eae125d30fe1c706 Mon Sep 17 00:00:00 2001 From: fmaccha Date: Sun, 25 Aug 2024 11:57:23 +0900 Subject: [PATCH 2/3] chore: Allow dead code which was for skipping CWL test on M1 Mac #11 --- tests/common.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/common.rs b/tests/common.rs index ecde76f..ff87e81 100644 --- a/tests/common.rs +++ b/tests/common.rs @@ -47,6 +47,7 @@ pub fn check_and_create_cache_dir() -> io::Result<()> { } // whether the current environment is M1 Mac +#[allow(dead_code)] pub fn is_running_on_m1_mac() -> bool { let os = std::env::consts::OS; let arch = std::env::consts::ARCH; From 7e797b55b6cdba46674e635b751dab2762550916 Mon Sep 17 00:00:00 2001 From: fmaccha Date: Sun, 25 Aug 2024 12:04:18 +0900 Subject: [PATCH 3/3] Create a dummy docker executable to make cwl-inspector find a docker executable. #11 --- Cargo.lock | 99 ++++++++++++++++++++++++++---------------------- Cargo.toml | 2 +- src/ext_tools.rs | 30 ++++++++++----- src/module.rs | 24 +++++++++++- 4 files changed, 97 insertions(+), 58 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 88f1fda..5158cda 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -880,9 +880,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.150" +version = "0.2.158" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" +checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" [[package]] name = "libz-sys" @@ -897,9 +897,9 @@ dependencies = [ [[package]] name = "linux-raw-sys" -version = "0.4.11" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "969488b55f8ac402214f3f5fd243ebb7206cf82de60d3172994707a4bcc2b829" +checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" [[package]] name = "log" @@ -1216,9 +1216,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.18.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "openssl" @@ -1366,15 +1366,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "redox_syscall" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" -dependencies = [ - "bitflags 1.3.2", -] - [[package]] name = "regex" version = "1.10.2" @@ -1471,9 +1462,9 @@ checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" [[package]] name = "rustix" -version = "0.38.28" +version = "0.38.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72e572a5e8ca657d7366229cdde4bd14c4eb5499a9573d4d366fe1b599daa316" +checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" dependencies = [ "bitflags 2.4.1", "errno", @@ -1754,15 +1745,15 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.9.0" +version = "3.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01ce4141aa927a6d1bd34a041795abd0db1cccba5d5f24b009f694bdf3a1f3fa" +checksum = "04cbcdd0c794ebb0d4cf35e88edd2f7d2c4c3e9a5a6dab322839b321c6a87a64" dependencies = [ "cfg-if", "fastrand", - "redox_syscall", + "once_cell", "rustix", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -2062,7 +2053,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ - "windows-targets 0.52.0", + "windows-targets 0.52.6", ] [[package]] @@ -2080,7 +2071,16 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.0", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets 0.52.6", ] [[package]] @@ -2100,17 +2100,18 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm 0.52.0", - "windows_aarch64_msvc 0.52.0", - "windows_i686_gnu 0.52.0", - "windows_i686_msvc 0.52.0", - "windows_x86_64_gnu 0.52.0", - "windows_x86_64_gnullvm 0.52.0", - "windows_x86_64_msvc 0.52.0", + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", + "windows_i686_gnullvm", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", ] [[package]] @@ -2121,9 +2122,9 @@ checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" [[package]] name = "windows_aarch64_msvc" @@ -2133,9 +2134,9 @@ checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_aarch64_msvc" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[package]] name = "windows_i686_gnu" @@ -2145,9 +2146,15 @@ checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_gnu" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" [[package]] name = "windows_i686_msvc" @@ -2157,9 +2164,9 @@ checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_i686_msvc" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_x86_64_gnu" @@ -2169,9 +2176,9 @@ checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnu" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] name = "windows_x86_64_gnullvm" @@ -2181,9 +2188,9 @@ checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] name = "windows_x86_64_msvc" @@ -2193,9 +2200,9 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "windows_x86_64_msvc" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winreg" diff --git a/Cargo.toml b/Cargo.toml index 9f8a685..36aab85 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,7 +32,7 @@ serde_yaml = "0.9.27" serde_json = "1.0.109" url = "2.5.0" reqwest = { version = "0.12.5", features = ["blocking"] } -tempfile = "3.9.0" +tempfile = "3.12.0" csv = "1.3.0" log = "0.4.20" env_logger = "0.11.0" diff --git a/src/ext_tools.rs b/src/ext_tools.rs index 4f0d72b..97e9ac8 100644 --- a/src/ext_tools.rs +++ b/src/ext_tools.rs @@ -2,7 +2,9 @@ use anyhow::{anyhow, bail, Context, Result}; use log::{debug, info}; use serde::{Deserialize, Serialize}; use std::collections::HashMap; +use std::fs; use std::io::Write; +use std::os::unix::fs::PermissionsExt; use std::path::{Path, PathBuf}; use tempfile::{Builder, NamedTempFile, TempDir}; @@ -17,16 +19,11 @@ pub fn invoke( cwl_file_path: &Path, target_file_path: &Path, cwl_input_file_path: &NamedTempFile, + dummy_docker_path: &NamedTempFile, _options: &InvokeOptions, ) -> Result { info!("Invoking ext_tools {}", cwl_file_path.display()); - let docker_path = docker_path()?; - debug!( - "The path of the docker command in your environment: {:?}.", - docker_path - ); - // make sure that the both paths are canonicalized. let target_file_path = target_file_path.canonicalize().with_context(|| { format!( @@ -50,7 +47,7 @@ pub fn invoke( "--rm", "-i", "-v", - &format!("{}:/usr/bin/docker:ro", docker_path.to_str().unwrap()), + &format!("{}:/usr/bin/docker:ro", dummy_docker_path.path().display()), "-v", &format!( "{}:/workdir/input_file.yaml:ro", @@ -141,7 +138,8 @@ pub fn invoke( Ok(module_result) } -fn docker_path() -> Result { +// check whether `which docker` succeeds or not to see the docker binary is in the PATH. +pub fn ensure_docker_presence() -> Result { let process = std::process::Command::new("which") .arg("docker") .stdout(std::process::Stdio::piped()) @@ -152,10 +150,24 @@ fn docker_path() -> Result { let path = String::from_utf8(process.stdout)?; Ok(PathBuf::from(path.trim())) } else { - bail!("Please make sure that the docker command is present in your PATH"); + bail!("Please make sure that the docker command is present in your PATH when invoking CWL modules."); } } +// create a dummy Docker executable +// - create a empty file in the temporary directory. +// - grant execution permission to the file. +// - return the file as NamedTempFile. +pub fn create_dummy_docker_executable(temp_dir: &TempDir) -> Result { + let read_execution_permission = std::fs::Permissions::from_mode(0o500); + let dummy_docker_file = Builder::new() + .prefix("dummy_docker_") + .permissions(read_execution_permission) + .tempfile_in(temp_dir)?; + + Ok(dummy_docker_file) +} + #[derive(Deserialize, Debug)] struct CwlFields { #[serde(flatten)] diff --git a/src/module.rs b/src/module.rs index afd31a4..cde5b3b 100644 --- a/src/module.rs +++ b/src/module.rs @@ -7,6 +7,7 @@ use tempfile::{NamedTempFile, TempDir}; use url::Url; use crate::args::{Args, OutputFormat}; +use crate::ext_tools::{create_dummy_docker_executable, ensure_docker_presence}; use crate::source::{CompressedFormat, Source}; // Struct to store the result of Parser invocation and ExtTools invocation. @@ -455,6 +456,13 @@ fn run_modules( None }; + // create a dummy Docker executable just for cwl-inspecter to work properly in Docker container only if there are one or more CWL module in the config file + let dummy_docker_path = if cwl_module_exists(config)? { + Some(create_dummy_docker_executable(temp_dir)?) + } else { + None + }; + let module_result = config .order .iter() @@ -474,6 +482,7 @@ fn run_modules( module_path, target_file_path, cwl_input_file_path.as_ref().unwrap(), + dummy_docker_path.as_ref().unwrap(), invoke_options,) }, _ => Err(anyhow!( @@ -552,8 +561,19 @@ fn check_run_condition_cwl_module( - tidy needed */ - if cwl_module_exists && stdin_exists && !invoke_options.tidy { - bail!("The `--tidy` option is required when reading from STDIN and invoking CWL modules."); + if cwl_module_exists { + if stdin_exists && !invoke_options.tidy { + bail!( + "The `--tidy` option is required when reading from STDIN and invoking CWL modules." + ); + } + + // check for existence of docker binary if a CWL module is specified + let docker_path = ensure_docker_presence()?; + debug!( + "The path of the docker command in your environment: {:?}.", + docker_path + ); } Ok(())