When a push is made to a repos, GH will send a check_suite.requested
event. In this event, the check status is set to queued
According to the docs:
The requested
action triggers when new code is pushed to the app's repository.
For example, this event is received when a push is made to master and also when a push is made to the branch of a PR.
We need to handle this especially so when this event is received and the payload has an array of pull_request that is not empty. This array contains all PRs that has the same head_branch and head_sha as the push (according to the docs). Not sure how it can ever be more than one element though.
The problem
This may cause intermittent "hanging" checks in a PR โ when a user pushes to the branch of the PR, two events are received by Mergeable: pull_request.synchronize
and check_suite.requested
โ IF the check_suite.requested
is received after mergeable finishes processing the pull_request.synchronize event and sent a status completed
check, that check is potentially now in queue status.
There is a race-condition.
Potential Solution
What we need to do when check_suite.requested event is received:
- Add this event to special cases function and get the pull_request. For now only get the first element and assume there's ever only one element in the pull_request array.
- Add check_suite.requested to the checks action.
- If there are config errors call Checks.run
- else processWorkflow.
Update 2019-02-07
Did a little bit more testing with various scenarios:
-
As long as checks are created and updated with complete or cancelled status, everything looks normal from a user perspective and there is no need to take action on the check_suite.requested event for that PR. It works as expected.
-
If there are no checks manually created and completed for a PR where the check_suite.requested event is triggered then the UI will not show anything in the conversations tab, however it will show a queued status for the app in the checks tab. It does not prevent merging though.
Currently, mergeable will always create a check and finish it with completed status for every event it is asked to listen to in the configuration -- regardless of whether the check_suitre.requested is received. This is the expected behavior.
There isn't any race conditions that I can determine since we do 1
. The check_suite.requested event has a totally different check run id as compared to the one we receive when creating a check_suite.