-
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
feat: improving apply requirements for mergeable on Gitlab #1675
Merged
jamengual
merged 7 commits into
runatlantis:master
from
devlucasc:gitlab_mr_apply_reqs_improvement
Aug 2, 2021
Merged
feat: improving apply requirements for mergeable on Gitlab #1675
jamengual
merged 7 commits into
runatlantis:master
from
devlucasc:gitlab_mr_apply_reqs_improvement
Aug 2, 2021
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
chenrui333
changed the title
Improving apply requirements for mergeable on Gitlab
feat: improving apply requirements for mergeable on Gitlab
Jul 7, 2021
Awesome work @devlucasc can't wait to see a release with this be cut, will save us a lot of issues. |
Someone can rerun the CI, please? An exception was raised due to docker container and I don't have permission to do that. |
@devlucasc you got it. |
Any update on this it would greatly improve issues we are seeing at present. |
jamengual
reviewed
Jul 27, 2021
msarvar
referenced
this pull request
in lyft/atlantis
Sep 27, 2021
* Improving apply requirements for mergeable on Gitlab * Fixing end of line * Renaming variables * Renaming variables * Fixing variable assignment * Fixing variable assignment
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Why:
This PR solves the following issues:
This PR changes the behavior of apply_requirements for the mergeable requirement.
First, the code gets the project settings.
Second, the code gets statuses for all jobs for the head pipeline.
Then, will be checked the status for each build job. If the build job has a failure status and if doesn't allow failures, if it is a requirement, it will be marked as a non-mergeable status. (The status for Atlantis apply command will be ignored to avoid blocking the apply command itself).
Then, if the pipeline has a skipped status and if the project doesn't allow merge on skipped pipelines, it will be marked as a non-mergeable status.
Lastly, the verification of the blocking_discussions_resolved field was implemented. When the MR has open threads and it is a project requirement for the merge, this field returns false. When there are threads open but it is not a requirement or when there are no threads open regardless of whether it is a requirement or not of the project, this field returns true. This field exists since v12.5 for all tiers.
I added a pipeline wait routine because Atlantis was trying to merge the MR before the pipeline ended. The pipeline status returned from the Get Merge Request API has a delay compared to the statuses from the Get Commit Statuses API.
In summary, this PR allows blocking the merge, given the project requirements, that pipelines have success status and that there are no open discussions.