From 142b32a1e11cf39003db63de7bdb719616db224b Mon Sep 17 00:00:00 2001 From: Jerens Lensun Date: Wed, 4 Jun 2025 13:49:51 +0800 Subject: [PATCH] improve jq bash shell error for clippy Signed-off-by: Jerens Lensun --- etc/ci/clippy-annotation.sh | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/etc/ci/clippy-annotation.sh b/etc/ci/clippy-annotation.sh index 22f3ecc83ca..22c6a9ad7be 100755 --- a/etc/ci/clippy-annotation.sh +++ b/etc/ci/clippy-annotation.sh @@ -1,7 +1,6 @@ #!/usr/bin/env bash -# Usage: ./clippy-to-annotations.sh < input.json > output.json -# Will exit with an error if there are no valid annotations. +# Usage: ./mach clippy --message-format=json --use-crown --locked -- -- --deny warnings | ./etc/ci/clippy-annotation.sh > temp/clippy-output.json set -euo pipefail @@ -19,7 +18,7 @@ output=$(jq -c ' $in.message.level | if . == "help" or . == "note" then "notice" elif . == "warning" then "warning" - else "failure" + else "error" end ), title: $in.message.message, @@ -36,10 +35,8 @@ output=$(jq -c ' end ' | jq -s '.') -if [[ "$output" == "[]" || -z "$output" ]]; then - echo "❌ No annotations to output." >&2 - exit 0 -fi - -# Output the final result echo "$output" + +if echo "$output" | jq -e 'map(select(.annotation_level == "error")) | length > 0' >/dev/null; then + exit 1 +fi