Skip to content
Snippets Groups Projects
Commit 2aeb899a authored by Jonas Höppner's avatar Jonas Höppner
Browse files

CI: merge_gitlab_ci: Fix some post merge issues

parent 7381d598
No related branches found
No related tags found
1 merge request!113CI: merge_gitlab_ci: Fix some post merge issues
Pipeline #9069 failed with stage
in 1 minute and 57 seconds
...@@ -19,7 +19,7 @@ critical_error = ( ...@@ -19,7 +19,7 @@ critical_error = (
) )
def accept_merge_request(project, mr, rebase=False): def accept_merge_request(project, mr, rebase=False, should_remove_source_branch=True):
"""Attempt to merge a merge request, rebase if necessary""" """Attempt to merge a merge request, rebase if necessary"""
merged = False merged = False
pipeline_pending = False pipeline_pending = False
...@@ -37,7 +37,7 @@ def accept_merge_request(project, mr, rebase=False): ...@@ -37,7 +37,7 @@ def accept_merge_request(project, mr, rebase=False):
# Try to merge the merge request # Try to merge the merge request
try: try:
mr.merge(should_remove_source_branch=True) mr.merge(should_remove_source_branch=should_remove_source_branch)
if pipeline_pending: if pipeline_pending:
print("") print("")
if mr.state == "merged": if mr.state == "merged":
......
...@@ -15,12 +15,14 @@ def check_if_integration_branch_is_up_to_date( ...@@ -15,12 +15,14 @@ def check_if_integration_branch_is_up_to_date(
): ):
integration_branch = None integration_branch = None
branch_list = []
if merge_request.source_branch.startswith("integrate/gitlab-ci"): if merge_request.source_branch.startswith("integrate/gitlab-ci"):
try: try:
integration_branch = manifest_project.branches.get( integration_branch = manifest_project.branches.get(
merge_request.source_branch, merge_request.source_branch,
retry_transient_errors=True, retry_transient_errors=True,
) )
branch_list.append(merge_request.source_branch)
except GitlabGetError: except GitlabGetError:
# Branch not found # Branch not found
...@@ -29,13 +31,19 @@ def check_if_integration_branch_is_up_to_date( ...@@ -29,13 +31,19 @@ def check_if_integration_branch_is_up_to_date(
integration_branch_name = common.integration_branch_name( integration_branch_name = common.integration_branch_name(
project.name, merge_request.source_branch project.name, merge_request.source_branch
) )
branch_list.append(integration_branch)
try: try:
integration_branch = manifest_project.branches.get( integration_branch = manifest_project.branches.get(
integration_branch_name, integration_branch_name,
retry_transient_errors=True, retry_transient_errors=True,
) )
except GitlabGetError: except GitlabGetError:
sys.exit("ERROR: could not find integration branch\n") sys.exit(
"ERROR: could not find integration branch in %s,"
"branch names checked: %s\n",
manifest_project.name,
branch_list,
)
try: try:
integration_base_branch = manifest_project.branches.get( integration_base_branch = manifest_project.branches.get(
......
...@@ -280,7 +280,7 @@ def is_commit_parent_of_project_commit(project: Project, project_commit, commit) ...@@ -280,7 +280,7 @@ def is_commit_parent_of_project_commit(project: Project, project_commit, commit)
) from e ) from e
# The integration branch is up to date if its parent is the integration base # The integration branch is up to date if its parent is the integration base
logging.debug("Compare '%s' and '%s'",parent.id, commit) logging.debug("Compare '%s' and '%s'", parent.id, commit)
if parent.id == commit: if parent.id == commit:
return True return True
if len(parent.parent_ids) == 0: if len(parent.parent_ids) == 0:
......
...@@ -156,6 +156,11 @@ def main(): ...@@ -156,6 +156,11 @@ def main():
# deploy_gitlab_ci again to create a new integration # deploy_gitlab_ci again to create a new integration
# commit or make sure the change is already integrated. # commit or make sure the change is already integrated.
# Store for later usage:
if p == args.project:
manifest_project = project
manifest_integration_mr = mr
print("Merge {}!{}: {}".format(project.name, mr.iid, mr.title)) print("Merge {}!{}: {}".format(project.name, mr.iid, mr.title))
# Wait until GitLab has checked merge status # Wait until GitLab has checked merge status
common.wait_until_merge_status_is_set(project, mr) common.wait_until_merge_status_is_set(project, mr)
...@@ -167,6 +172,10 @@ def main(): ...@@ -167,6 +172,10 @@ def main():
# Only the file manifest commit may be rebased # Only the file manifest commit may be rebased
# other rebase would require new integration commits # other rebase would require new integration commits
rebase=(p == args.project), rebase=(p == args.project),
# For the manifest we keep the source branch
# otherwise does the check job fail for not yet merged
# child projects
should_remove_source_branch=(p == args.project),
) )
if not merged: if not merged:
...@@ -185,9 +194,18 @@ def main(): ...@@ -185,9 +194,18 @@ def main():
continue continue
if not found: if not found:
continue continue
print(" {}".format(p2.name)) print(" {}".format(p2))
sys.exit() sys.exit()
# Delete args.project (manifests) integration branch
# (skipped the deletion during the merge request merge before)
integration_branch = manifest_project.branches.get(
manifest_integration_mr.source_branch
)
manifest_project.branches.delete(
integration_branch.get_id(), retry_transient_errors=True
)
print("Successfully merged") print("Successfully merged")
exit() exit()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment