| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 0f36ee3 commit a457631
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -10,12 +10,62 @@ COMMIT_QUEUE_FAILED_LABEL="commit-queue-failed" | |||
| 10 | 10 | ||
| 11 | 11 | cqurl="${GITHUB_SERVER_URL:?}/${GITHUB_REPOSITORY:?}/actions/runs/${GITHUB_RUN_ID:?}" | |
| 12 | 12 | ||
| 13 | + escape_code_block_or_line() { | ||
| 14 | + case $1 in | ||
| 15 | + *" | ||
| 16 | + "*|'') fence='```' sep=' | ||
| 17 | + ' ;; | ||
| 18 | + *[![:space:]]*) fence='`' sep=' ' ;; | ||
| 19 | + *) fence='`' sep='' ;; | ||
| 20 | + esac | ||
| 21 | + while case $1 in *"$fence"*) ;; *) false ;; esac; do | ||
| 22 | + fence=$fence'`' | ||
| 23 | + done | ||
| 24 | + printf '%s%s%s%s%s\n' "$fence" "$sep" "$1" "$sep" "$fence" | ||
| 25 | + } | ||
| 26 | + | ||
| 13 | 27 | commit_queue_failed() { | |
| 14 | 28 | pr=$1 | |
| 29 | + reported_failure=${2:-} | ||
| 15 | 30 | ||
| 16 | 31 | gh -R "$GITHUB_REPOSITORY" pr edit "$pr" --add-label "${COMMIT_QUEUE_FAILED_LABEL}" --remove-label "${COMMIT_QUEUE_LABEL}" | |
| 17 | 32 | ||
| 18 | - body="<details><summary>Commit Queue failed</summary><pre>$(sed -e 's/&/\&/g' -e 's/</\</g' -e 's/>/\>/g' output)</pre><a href='$cqurl'>$cqurl</a></details>" | ||
| 33 | + last_output_line=$(awk 'NF { line = $0 } END { sub(/^[[:space:]]*/, "", line); print line }' output) | ||
| 34 | + # shellcheck disable=SC2016 | ||
| 35 | + missing_policy_message='ℹ Add `commit-queue-squash` label to land the PR as one commit, or `commit-queue-rebase` to land as separate commits.' | ||
| 36 | + if [ "$last_output_line" = "$missing_policy_message" ]; then | ||
| 37 | + failure_body='This pull request has multiple commits, but no landing policy was selected. | ||
| 38 | + | ||
| 39 | + Add https://github.com/nodejs/node/labels/commit-queue-squash to land it as one commit, or https://github.com/nodejs/node/labels/commit-queue-rebase to land the commits separately.' | ||
| 40 | + else | ||
| 41 | + if [ -z "$reported_failure" ]; then | ||
| 42 | + reported_failure=$(grep -e '✘' -e '⚠' output | tail -n 10) | ||
| 43 | + fi | ||
| 44 | + if [ -z "$reported_failure" ]; then | ||
| 45 | + reported_failure=$(tail -n 10 output) | ||
| 46 | + fi | ||
| 47 | + if [ -z "$reported_failure" ]; then | ||
| 48 | + reported_failure='No failure reason was reported.' | ||
| 49 | + fi | ||
| 50 | + failure_body=$(escape_code_block_or_line "$reported_failure") | ||
| 51 | + fi | ||
| 52 | + | ||
| 53 | + raw_output=$(cat output) | ||
| 54 | + | ||
| 55 | + body="### Commit Queue failed | ||
| 56 | + | ||
| 57 | + $failure_body | ||
| 58 | + | ||
| 59 | + The pull request was removed from the Commit Queue and labeled https://github.com/nodejs/node/labels/commit-queue-failed. After resolving the failure, remove that label and add https://github.com/nodejs/node/labels/commit-queue to retry. | ||
| 60 | + | ||
| 61 | + <details> | ||
| 62 | + <summary>Full Commit Queue output</summary> | ||
| 63 | + | ||
| 64 | + $(escape_code_block_or_line "$raw_output") | ||
| 65 | + | ||
| 66 | + </details> | ||
| 67 | + | ||
| 68 | + [View workflow run]($cqurl)" | ||
| 19 | 69 | echo "$body" | |
| 20 | 70 | ||
| 21 | 71 | gh -R "$GITHUB_REPOSITORY" pr comment "$pr" --body "$body" | |
@@ -63,7 +113,8 @@ for pr in "$@"; do | |||
| 63 | 113 | commits="${start_sha}...${end_sha}" | |
| 64 | 114 | ||
| 65 | 115 | if ! git push $UPSTREAM $DEFAULT_BRANCH >> output 2>&1; then | |
| 66 | - commit_queue_failed "$pr" | ||
| 116 | + commit_queue_failed "$pr" \ | ||
| 117 | + "Failed to push the landed commits to ${UPSTREAM}/${DEFAULT_BRANCH}." | ||
| 67 | 118 | continue | |
| 68 | 119 | fi | |
| 69 | 120 | else | |
@@ -80,9 +131,10 @@ for pr in "$@"; do | |||
| 80 | 131 | --arg head "${commit_head}" \ | |
| 81 | 132 | '{merge_method:"squash",commit_title:$title,commit_message:$body,sha:$head}' |\ | |
| 82 | 133 | gh api -X PUT "repos/${GITHUB_REPOSITORY}/pulls/${pr}/merge" --input -\ | |
| 83 | - --jq 'if .merged then .sha else halt_error end' | ||
| 134 | + --jq 'if .merged then .sha else halt_error end' 2>> output | ||
| 84 | 135 | )"; then | |
| 85 | - commit_queue_failed "$pr" | ||
| 136 | + commit_queue_failed "$pr" \ | ||
| 137 | + 'GitHub failed to squash and merge this pull request.' | ||
| 86 | 138 | continue | |
| 87 | 139 | fi | |
| 88 | 140 | fi | |
| Back | FazBrowse Home | New Git URL |
0 commit comments