diff --git a/.husky/pre-commit b/.husky/pre-commit index 0a823c32b..02b857533 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -10,12 +10,12 @@ if git diff --cached --name-only | grep -q '\.mdx?$'; then fi # Check for changes in Rust files -changed_rust_files=$(git diff --cached --name-only | grep -E '\.rs$') -if [ -n "${changed_rust_files:-""}" ]; then +if git diff --cached --name-only | grep -q '\.rs$'; then echo "Running checks for the Rust code..." cargo +nightly fmt # Run tests only for the changed files - #./scripts/test.sh --local ${changed_rust_files} + # changed_rust_files=$(git diff --cached --name-only | grep -E '\.rs$') + # ./scripts/test.sh --local ${changed_rust_files} fi # Check for changes in the 'node-ui' directory (Next.js app) diff --git a/crates/meroctl/src/common.rs b/crates/meroctl/src/common.rs index b21ac4aa6..422ba9cad 100644 --- a/crates/meroctl/src/common.rs +++ b/crates/meroctl/src/common.rs @@ -120,6 +120,7 @@ where // return Ok(result); // } +// pub fn load_config(home: &Utf8Path, node_name: &str) -> EyreResult { let path = home.join(node_name); diff --git a/crates/server-primitives/src/jsonrpc.rs b/crates/server-primitives/src/jsonrpc.rs index 9744282da..235edcd4a 100644 --- a/crates/server-primitives/src/jsonrpc.rs +++ b/crates/server-primitives/src/jsonrpc.rs @@ -161,7 +161,6 @@ impl ExecuteRequest { #[serde(rename_all = "camelCase")] #[non_exhaustive] pub struct ExecuteResponse { - //test pub output: Option, } diff --git a/scripts/test.sh b/scripts/test.sh index c6309579e..daac94e7e 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -81,10 +81,8 @@ for file in "${changed_files[@]}"; do done done -echo "vuuuuuuuuuki" echo $matched_crates - calimero_package_names=() # Loop through each element in the original array for item in "${matched_crates[@]}"; do @@ -122,19 +120,39 @@ for calimero_package_name in "${calimero_package_names[@]}"; do done done +crates_to_test=() +seen=() +# Loop through the calimero_package_names array +for item in "${calimero_package_names[@]}"; do + if [[ -z "${seen[$item]}" ]]; then + seen[$item]=1 # Mark the item as seen + crates_to_test+=("$item") + fi +done + +# Loop through the dep_arr array +for item in "${dep_arr[@]}"; do + if [[ -z "${seen[$item]}" ]]; then + seen[$item]=1 + crates_to_test+=("$item") + fi +done + # Run tests for each module and its dependencies echo "Running tests for affected modules and their dependencies..." # Install the nightly toolchain rustup toolchain install nightly -#Test crates from changed files -for crate in "${calimero_package_names[@]}"; do - echo "Testing crate $crate" - cargo +nightly test -p "$crate" +#Test all crates from changed files +for crate in "${crates_to_test[@]}"; do + if [[ "$item" == "calimero-merod" ]]; then + echo "Testing crate merod" + cargo +nightly test -p "merod" + elif [[ "$item" == "calimero-meroctl" ]]; then + echo "Testing crate meroctl" + cargo +nightly test -p "meroctl" + else + echo "Testing crate $crate" + cargo +nightly test -p "$crate" + fi done - -#Test dependencies -for crate in "${dep_arr[@]}"; do - echo "Testing crate $crate" - cargo +nightly test -p "$crate" -done \ No newline at end of file