Skip to content

Commit

Permalink
fix: special cases
Browse files Browse the repository at this point in the history
  • Loading branch information
MatejVukosav committed Nov 3, 2024
1 parent 0d2f89b commit 607c923
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 16 deletions.
6 changes: 3 additions & 3 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions crates/meroctl/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ where

// return Ok(result);
// }
//

pub fn load_config(home: &Utf8Path, node_name: &str) -> EyreResult<ConfigFile> {
let path = home.join(node_name);
Expand Down
1 change: 0 additions & 1 deletion crates/server-primitives/src/jsonrpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ impl ExecuteRequest {
#[serde(rename_all = "camelCase")]
#[non_exhaustive]
pub struct ExecuteResponse {
//test
pub output: Option<Value>,
}

Expand Down
42 changes: 30 additions & 12 deletions scripts/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

0 comments on commit 607c923

Please sign in to comment.