-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
fix: GitLab - use "approvals_left" instead of "approvals_before_merge" when checking if pull is mergeable #5049
base: main
Are you sure you want to change the base?
Conversation
Hi @CaioAugustoo, thanks for this. Some of the current GitLab tests are failing after your change. Can you take a look at these? New tests are also needed to cover this new code. |
@CaioAugustoo, please sign your coming to pass the DCO test. |
@@ -816,6 +816,10 @@ func TestGitlabClient_PullIsMergeable(t *testing.T) { | |||
case fmt.Sprintf("/api/v4/projects/runatlantis%%2Fatlantis/merge_requests/%v", defaultMr): | |||
w.WriteHeader(http.StatusOK) | |||
w.Write(pipelineSuccess) // nolint: errcheck | |||
case fmt.Sprintf("/api/v4/projects/runatlantis%%2Fatlantis/merge_requests/%v/approvals", c.mrID): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you enhance the tests for this? It needs a test where approvals_left
is 0
and another where approvals_left
is greater than 0
.
what
Currently, Atlantis uses the
approvals_before_merge
field on GitLab client in order to check if MR is mergeable. But using that field is not correctly becauseapprovals_before_merge
is the configured number of approvals required for the MR and not the remaining number of approvals.This PR will fix that. Also, there is a related issue here.
why
In cases that GitLab users updates the
approvals_before_merge
on any MR, Atlantis will throwApply Failed: Pull request must be mergeable before running apply.
error. You can read more here.tests
Tested locally
references
Relates to #4949