2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-09-02 15:45:25 +00:00

Use approve button workflow in danger CI

Since the LGTM label was deprecated in favor of using the Approve button
in gitlab, adjust the detection in danger bot.

Unfortunately, danger-python seems no longer maintained since 2020 and
MR approvals aren't available in its Python API (even though they're
supported in its Ruby/JS APIs). Going forward, let's use the more
comprehensive python-gitlab API.

It still makes sense to utilize the danger-python, since it handles the
integration with gitlab which doesn't need to be reimplemented as long
as it works - same with the other checks.
This commit is contained in:
Tom Krizek
2022-11-04 13:05:29 +01:00
parent 0f46bcc86e
commit e901342dd9

View File

@@ -11,8 +11,11 @@
# information regarding copyright ownership. # information regarding copyright ownership.
############################################################################ ############################################################################
import os
import re import re
import gitlab
# Helper functions and variables # Helper functions and variables
@@ -44,6 +47,13 @@ modified_files = danger.git.modified_files
mr_labels = danger.gitlab.mr.labels mr_labels = danger.gitlab.mr.labels
target_branch = danger.gitlab.mr.target_branch target_branch = danger.gitlab.mr.target_branch
gl = gitlab.Gitlab(
url=f"https://{os.environ['CI_SERVER_HOST']}",
private_token=os.environ["DANGER_GITLAB_API_TOKEN"],
)
proj = gl.projects.get(os.environ["CI_PROJECT_ID"])
mr = proj.mergerequests.get(os.environ["CI_MERGE_REQUEST_IID"])
############################################################################### ###############################################################################
# COMMIT MESSAGES # COMMIT MESSAGES
############################################################################### ###############################################################################
@@ -167,15 +177,16 @@ if not backport_label_set and not version_labels:
# remind developers about the need to set the latter on merge requests which # remind developers about the need to set the latter on merge requests which
# passed review.) # passed review.)
approved = mr.approvals.get().approved
if "Review" not in mr_labels: if "Review" not in mr_labels:
warn( warn(
"This merge request does not have the *Review* label set. " "This merge request does not have the *Review* label set. "
"Please set it if you would like the merge request to be reviewed." "Please set it if you would like the merge request to be reviewed."
) )
elif "LGTM (Merge OK)" not in mr_labels: elif not approved:
warn( warn(
"This merge request is currently in review. " "This merge request is currently in review. "
"It should not be merged until it is marked with the *LGTM* label." "It should not be merged until it is approved."
) )
############################################################################### ###############################################################################