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

Looping when branch protection disallows merge commits #190

Open
alex-mckenna opened this issue Nov 9, 2022 · 1 comment
Open

Looping when branch protection disallows merge commits #190

alex-mckenna opened this issue Nov 9, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@alex-mckenna
Copy link

Recently we've seen that on repositories where branch protection forbids merge commits into master, hoff can loop (since it attempts to fast-forward merge on successful builds). GitHub has an API for checking the protection on a branch, we should check that the branch hoff will merge into has compatible permissions.

Since branch protection configuration can change, we should either listen for changes in branch protection rules if possible, or check at the start of every hoff merge. If branch protection rules would prohibit hoff from merging, it should comment this on the PR so users are aware.

@alex-mckenna alex-mckenna added the bug Something isn't working label Nov 9, 2022
@fatho
Copy link
Member

fatho commented Nov 10, 2022

The more general problem is that we treat every failed push as a conflicting commit to master, and thus as a reason to retry:

hoff/src/Logic.hs

Lines 808 to 823 in 266379e

case pushResult of
-- If the push worked, then this was the final stage of the pull request.
-- GitHub will mark the pull request as closed, and when we receive that
-- event, we delete the pull request from the state. Until then, reset
-- the integration candidate, so we proceed with the next pull request.
PushOk -> do
cleanupTestBranch pullRequestId
pure $ Pr.updatePullRequests (unspeculateConflictsAfter pullRequest)
$ Pr.updatePullRequests (unspeculateFailuresAfter pullRequest)
$ Pr.setIntegrationStatus pullRequestId Promoted state
-- If something was pushed to the target branch while the candidate was
-- being tested, try to integrate again and hope that next time the push
-- succeeds. We also cancel integrations in the merge train.
-- These should be automatically restarted when we 'proceed'.
PushRejected _why -> tryIntegratePullRequest pullRequestId
$ unintegrateAfter pullRequestId state

I'd say we should instead whitelist the causes that are know to be fixable by retrying, and give up on the PR (with a comment) in all other cases. Then we also wouldn't necessarily need custom logic for detecting branch protection rules - depending on how good the error messages are we get back from a failed push.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants