From 097f4ce17a3a1e3256faeda10d16add11c7116a4 Mon Sep 17 00:00:00 2001 From: aoiasd <45024769+aoiasd@users.noreply.github.com> Date: Wed, 16 Jul 2025 14:32:50 +0800 Subject: [PATCH] fix: rustcheck not work in CI (#43302) relate: https://github.com/milvus-io/milvus/issues/42806 Signed-off-by: aoiasd --- Makefile | 5 ++++- scripts/run_cargo_format.sh | 15 +++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index f94f22672c..910124d3b8 100644 --- a/Makefile +++ b/Makefile @@ -145,10 +145,13 @@ cppcheck: @#(env bash ${PWD}/scripts/core_build.sh -l) @(env bash ${PWD}/scripts/check_cpp_fmt.sh) -rustcheck: +rustfmt: @echo "Running cargo format" @env bash ${PWD}/scripts/run_cargo_format.sh ${PWD}/internal/core/thirdparty/tantivy/tantivy-binding/ +rustcheck: + @echo "Running cargo check" + @env bash ${PWD}/scripts/run_cargo_format.sh ${PWD}/internal/core/thirdparty/tantivy/tantivy-binding/ --check fmt: ifdef GO_DIFF_FILES diff --git a/scripts/run_cargo_format.sh b/scripts/run_cargo_format.sh index 49b1831229..495aa04687 100644 --- a/scripts/run_cargo_format.sh +++ b/scripts/run_cargo_format.sh @@ -1,6 +1,17 @@ #!/bin/bash ( - cd $1 - cargo fmt + cd "$1" || exit 1 + + if [ "$2" == "--check" ]; then + if ! cargo fmt --all -- --check; then + echo "Rust code is not properly formatted." + exit 1 + fi + echo "Check rust format success" + else + cargo fmt --all + fi + + exit 0 ) \ No newline at end of file