Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 0c90fd8

Browse filesBrowse files
aduh95danielleadams
authored andcommitted
tools: avoid crashing CQ when git push fails
PR-URL: #36861 Reviewed-By: Mary Marchini <oss@mmarchini.me>
1 parent a19170e commit 0c90fd8
Copy full SHA for 0c90fd8

File tree

Expand file treeCollapse file tree

1 file changed

+25
-18
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+25
-18
lines changed
Open diff view settings
Collapse file

‎tools/actions/commit-queue.sh‎

Copy file name to clipboardExpand all lines: tools/actions/commit-queue.sh
+25-18Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,18 @@ gitHubCurl() {
3737
--header 'content-type: application/json' "$@"
3838
}
3939

40+
commit_queue_failed() {
41+
gitHubCurl "$(labelsUrl "${1}")" POST --data '{"labels": ["'"${COMMIT_QUEUE_FAILED_LABEL}"'"]}'
42+
43+
# shellcheck disable=SC2154
44+
cqurl="${GITHUB_SERVER_URL}/${OWNER}/${REPOSITORY}/actions/runs/${GITHUB_RUN_ID}"
45+
jq -n --arg content "<details><summary>Commit Queue failed</summary><pre>$(cat output)</pre><a href='$cqurl'>$cqurl</a></details>" '{body: $content}' > output.json
46+
cat output.json
47+
48+
gitHubCurl "$(commentsUrl "${1}")" POST --data @output.json
49+
50+
rm output output.json
51+
}
4052

4153
# TODO(mmarchini): should this be set with whoever added the label for each PR?
4254
git config --local user.email "github-bot@iojs.org"
@@ -64,30 +76,25 @@ for pr in "$@"; do
6476

6577
# TODO(mmarchini): workaround for ncu not returning the expected status code,
6678
# if the "Landed in..." message was not on the output we assume land failed
67-
if ! tail -n 10 output | grep '. Post "Landed in .*/pull/'"${pr}"; then
68-
gitHubCurl "$(labelsUrl "$pr")" POST --data '{"labels": ["'"${COMMIT_QUEUE_FAILED_LABEL}"'"]}'
69-
70-
# shellcheck disable=SC2154
71-
cqurl="${GITHUB_SERVER_URL}/${OWNER}/${REPOSITORY}/actions/runs/${GITHUB_RUN_ID}"
72-
jq -n --arg content "<details><summary>Commit Queue failed</summary><pre>$(cat output)</pre><a href='$cqurl'>$cqurl</a></details>" '{body: $content}' > output.json
73-
cat output.json
74-
75-
gitHubCurl "$(commentsUrl "$pr")" POST --data @output.json
76-
77-
rm output output.json
79+
if ! grep -q '. Post "Landed in .*/pull/'"${pr}" output; then
80+
commit_queue_failed "$pr"
7881
# If `git node land --abort` fails, we're in unknown state. Better to stop
7982
# the script here, current PR was removed from the queue so it shouldn't
8083
# interfere again in the future.
8184
git node land --abort --yes
82-
else
83-
rm output
85+
continue
86+
fi
87+
88+
commits="$(git rev-parse $UPSTREAM/$DEFAULT_BRANCH)...$(git rev-parse HEAD)"
8489

85-
commits="$(git rev-parse $UPSTREAM/$DEFAULT_BRANCH)...$(git rev-parse HEAD)"
90+
if ! git push $UPSTREAM $DEFAULT_BRANCH >> output 2>&1; then
91+
commit_queue_failed "$pr"
92+
continue
93+
fi
8694

87-
git push $UPSTREAM $DEFAULT_BRANCH
95+
rm output
8896

89-
gitHubCurl "$(commentsUrl "$pr")" POST --data '{"body": "Landed in '"$commits"'"}'
97+
gitHubCurl "$(commentsUrl "$pr")" POST --data '{"body": "Landed in '"$commits"'"}'
9098

91-
gitHubCurl "$(issueUrl "$pr")" PATCH --data '{"state": "closed"}'
92-
fi
99+
gitHubCurl "$(issueUrl "$pr")" PATCH --data '{"state": "closed"}'
93100
done

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.