Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: use purple merge instead of close on CQ #35001

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion tools/actions/commit-queue.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ API_URL=https://api.github.com
COMMIT_QUEUE_LABEL='commit-queue'
COMMIT_QUEUE_FAILED_LABEL='commit-queue-failed'

function prUrl() {
echo "$API_URL/repos/${OWNER}/${REPOSITORY}/pulls/${1}"
}

function issueUrl() {
echo "$API_URL/repos/${OWNER}/${REPOSITORY}/issues/${1}"
}
Expand Down Expand Up @@ -76,10 +80,18 @@ for pr in "$@"; do
git node land --abort --yes
else
rm output
head=$(gitHubCurl "$(prUrl "$pr")" GET | jq '{ ref: .head.ref, remote: .head.repo.ssh_url, can_modify: .maintainer_can_modify }')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we split the value right here to avoid the "$(echo "$head" .. below so that it will be a bit cleaner. Perhaps like:

head=$(gitHubCurl "$(prUrl "$pr")" GET)
head_ref="$(echo "$head" | jq -r '.head.ref')"
remote_url="$(echo "$head" | jq -r '.head.repo.ssh_url')"
can_modify="$(echo "$head" | jq -r '.maintainer_can_modify')"

if [ "$(echo "$head" | jq -r .can_modify)" == "true" ]; then
git push --force "$(echo "$head" | jq -r .remote)" master:"$(echo "$head" | jq -r .ref)"
# Give GitHub time to sync before pushing to master
sleep 5s
Copy link
Contributor Author

@mmarchini mmarchini Sep 3, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might increase this to a whole minute or something, I just did this manually with a 15 seconds gap between push to PR branch and push to nodejs/node and I still got a race condition.

image

Note how even though I pushed to the PR branch first, GitHub only registered the event after I pushed to nodejs/node, which lead to the PR getting automatically closed and losing the commits and file changes in the UI

image

If that's a propagation issue on GitHub (which is what it seems like), an API call to confirm if the push propagated probably wouldn't work :/, so long sleep might be the way to go.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have to wait until the origin/pull/123 ref has updated, which a git fetch can verify.

fi
git push origin master

gitHubCurl "$(commentsUrl "$pr")" POST --data '{"body": "Landed in '"$(git rev-parse HEAD)"'"}'

gitHubCurl "$(issueUrl "$pr")" PATCH --data '{"state": "closed"}'
if [ "$(echo "$head" | jq -r .can_modify)" != "true" ]; then
gitHubCurl "$(issueUrl "$pr")" PATCH --data '{"state": "closed"}'
fi
fi
done