From fd3bf44de3c452e0ba07d835b3fe916a7344eae4 Mon Sep 17 00:00:00 2001 From: Filip Skokan Date: Fri, 11 Sep 2026 11:35:25 +0200 Subject: [PATCH] tools: summarize auto-start-ci failures Signed-off-by: Filip Skokan --- tools/actions/start-ci.sh | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/tools/actions/start-ci.sh b/tools/actions/start-ci.sh index d4d19b92082d..a9ae07a365eb 100755 --- a/tools/actions/start-ci.sh +++ b/tools/actions/start-ci.sh @@ -6,6 +6,20 @@ REQUEST_CI_LABEL="request-ci" REQUEST_CI_FAILED_LABEL="request-ci-failed" cqurl="${GITHUB_SERVER_URL:?}/${GITHUB_REPOSITORY:?}/actions/runs/${GITHUB_RUN_ID:?}" +escape_code_block_or_line() { + case $1 in + *" +"*|'') fence='```' sep=' +' ;; + *[![:space:]]*) fence='`' sep=' ' ;; + *) fence='`' sep='' ;; + esac + while case $1 in *"$fence"*) ;; *) false ;; esac; do + fence=$fence'`' + done + printf '%s%s%s%s%s\n' "$fence" "$sep" "$1" "$sep" "$fence" +} + for pr in "$@"; do gh -R "$GITHUB_REPOSITORY" pr edit "$pr" --remove-label "$REQUEST_CI_LABEL" @@ -18,7 +32,28 @@ for pr in "$@"; do # Do we need to reset? gh -R "$GITHUB_REPOSITORY" pr edit "$pr" --add-label "$REQUEST_CI_FAILED_LABEL" - body="
Failed to start CI
$(cat output)
$cqurl
" + reported_failure=$(grep -e '✘' -e '✖' -e '⚠' -e 'ℹ' output | tail -n 10) + if [ -z "$reported_failure" ]; then + reported_failure=$(tail -n 10 output) + fi + if [ -z "$reported_failure" ]; then + reported_failure='No failure reason was reported.' + fi + failure_body=$(escape_code_block_or_line "$reported_failure") + raw_output=$(cat output) + + body="### Failed to start CI + +$failure_body + +
+Full Auto Start CI output + +$(escape_code_block_or_line "$raw_output") + +
+ +[View workflow run]($cqurl)" echo "$body" gh -R "$GITHUB_REPOSITORY" pr comment "$pr" --body "$body"