-
Notifications
You must be signed in to change notification settings - Fork 207
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
Merging fails if master is a protected branch and required checks have not yet passed #14
Comments
Yes, unfortunately GH does not (did not? maybe they fixed it now) correctly report the status of checks every time. You should see a log line, before "Failed to merge", like "PR is probably ready: mergeable_state: ...", do you know which state is logged there? Regarding
I think it's the same as described in #7 |
|
Yes, as I suspected, GH reports a wrong state here, in my opinion:
This state is also reported when checks are running that are not required and I think I remember this state being reported in some cases where no checks were running at all. So the only thing we can do at that moment is to try and merge and see if we get an error back. Regarding your other point, "automerge-action is not triggered when checks finish", I think we can do something. There's an open issue #7 and even a PR #8, but I never heard back from the original author. So maybe check if this already helps you and if not, create a new PR 👍 |
I tried the code from the PR and I can't get it to work. I can't even get GitHub to trigger the automerge action when the check run completes (even if I register for the
If this applies to my situation (ie. if one check run finishes it won't trigger any other actions) then I'm afraid my idea won't ever work. |
Yes, that's correct, and I think GH will not change this anytime soon, since it can very easily result in an infinite loop of actions triggering each other. However, I think this is still useful in all the cases where an external CI is used, like CircleCI, TravisCI, etc. |
I'm closing this now, but if you have any additional input or need support, feel free to reopen this and/or create a new issue, of course! |
Would it be possible to use |
|
Hi! I'm facing the same problem in our repo, where we enabled this action today: https://github.com/nextcloud/nextcloud-moment/pull/125/checks?check_run_id=443656543. The master branch is protected. But even after all required checks are finished and no other ones are run, the action is stuck with the protected branch error. Dependabot, however, is able to auto merge PRs. I read a bit of your action's code. Am I understanding this correctly that you merge the branch locally and try to push it back to the target branch? Would it be possible to invoke Github's merge operation instead? It's a wild guess but I could imagine that this makes a difference for Githubs branch protection. |
I think the workflow you described is only used to rebase the branch onto the base branch, in case it's out of date ("behind"). The actual merging into the base happens using regular GH API calls, see https://github.com/pascalgn/automerge-action/blob/master/lib/merge.js#L259 |
Thanks for the info! I'm pretty sure the branch was up to date, hence it shouldn't need to update anything. Tried with |
If there is a way to get more debug logs from the action please let me know and I'll try to gather that! |
Yes, GH user olivierlefloch was so nice and provided details in the README, see here: https://github.com/pascalgn/automerge-action#debugging |
Thanks, that gives some great insight: https://github.com/nextcloud/nextcloud-moment/pull/139/checks?check_run_id=449857817 What I find most interesting is
No idea why it's blocked, though. Checks pass and there was a review. Is this a bug in Github? It might be "blocked" by this action, though it's not set as required step. |
Also now it says |
This could be a bug in the GitHub API and it might be related or even the same problem as described here: #8 (comment) 😞 |
Until you resolve this issue - Add a bookmark, (name it AutoMerge if you want), paste the following script as a URL: This works when the repo is configured to "rebase and merge". javascript:(
function(){
alert("AutoMerge is w8ing for the possibility to merge - please keep the tab open and DO NOT refresh the page");
function queryItems(kind){
return Array.prototype.slice.call(document.querySelectorAll(kind));
};
function autoMerge (){
console.log("running");
const blocked = queryItems('div').filter(el=>el.innerText === 'Merging is blocked')[0];
const blocked2 = queryItems('p').filter(el=>el.innerText === 'As an administrator, you may still merge this pull request.')[0];
if(blocked || blocked2){
console.log("mergeIsBlocked-sleeping");
setTimeout(autoMerge, 1000);
return;
}
const btn = queryItems('button').filter(el=>el.innerText === 'Rebase and merge')[0];
if (btn) {
console.log("merging...");
btn.click();
var btn2 = queryItems('button').filter(btn=>btn.innerText === 'Confirm rebase and merge')[0];
if(!btn2){
btn2 = queryItems('button').filter(btn=>btn.innerText === 'Confirm merge')[0];
}
if (btn2) {
btn2.click();
}
}
const btn3 = queryItems('button').filter(btn=>btn.innerText === 'Delete branch')[0];
if (btn3) {
console.log("removing branch...");
btn3.click();
return;
}
console.log(123);
setTimeout(autoMerge, 1000);
};
autoMerge();
}
)(); Tested on Firefox. |
I think this might be fixed now, but the error is quite hard to reproduce and it's a long time since there was any activity here. I would ask you to try with the latest version and if you have any new information or need any help, feel free to reopen this issue! |
I made the master branch in my repo protected, such that certain checks must pass before merging is allowed. Unfortunately the automerge-action runs in parallel to the required check, and so the merge fails (Failed to merge PR: Required status check "build" is in progress). It seems that automerge-action is not triggered when checks finish, so it never re-runs.
The text was updated successfully, but these errors were encountered: