From 0f30db840dbbfbb08be9fb815543ee53f7ea9ecb Mon Sep 17 00:00:00 2001 From: "matej.vukosav" Date: Mon, 4 Nov 2024 00:02:06 +0800 Subject: [PATCH] fix: special cases --- .husky/pre-commit | 6 ++-- crates/server-primitives/src/jsonrpc.rs | 1 - scripts/test.sh | 42 ++++++++++++++++++------- 3 files changed, 33 insertions(+), 16 deletions(-) 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/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..0335b5667 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" == "merod" ]]; then + echo "Testing crate merod" + cargo +nightly test -p "merod" + elif [[ "$item" == "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