diff --git a/.ci/check-style b/.ci/check-style index 1e4f025f4..117a122ae 100755 --- a/.ci/check-style +++ b/.ci/check-style @@ -9,6 +9,7 @@ set -e set -o pipefail CLANGFORMAT=${CLANGFORMAT:-clang-format-18} +RUSTFMT=${RUSTFMT:-rustfmt} command -v git >/dev/null 2>&1 || { echo >&2 "git is missing"; exit 1; } command -v xargs >/dev/null 2>&1 || { echo >&2 "xargs is missing"; exit 1; } @@ -37,3 +38,9 @@ if git --no-pager diff --diff-filter=d --name-only ${TARGET_BRANCH} HEAD | grep git --no-pager diff exit 1 fi + +RUST_SOURCES=$(git --no-pager diff --diff-filter=d --name-only ${TARGET_BRANCH} HEAD | grep -E "^src/rust.*\.rs\$" | grep -v -E "^src/rust/vendor" || true) +if [ -n "$RUST_SOURCES" ] ; then + echo $RUST_SOURCES + "$RUSTFMT" --check $RUST_SOURCES +fi diff --git a/.ci/ci b/.ci/ci index 301122ae7..abfd7d2e2 100755 --- a/.ci/ci +++ b/.ci/ci @@ -6,7 +6,7 @@ set -e # Deny warnings in rust. CI will fail to compile any code with warnings in it. export RUSTFLAGS="-Dwarnings" -# Check style for C +# Check style for C and Rust ./.ci/check-style # Check that we can generate protobuf definitions for python