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

CI: merge gitlab-ci: manifest is merged at last

The merge job of a subproject include in the merge request merged by
gitlab ci, should not merge the integration branch in the manifest by
themself. This is now disabled by checking the source branch name.

This allow to merge the manifests commit at last.
parent e8c2f221
No related branches found
No related tags found
1 merge request!115CI: Rename gitlab-ci jobs
Pipeline #9116 failed with stages
in 56 seconds
...@@ -16,14 +16,13 @@ def check_if_integration_branch_is_up_to_date( ...@@ -16,14 +16,13 @@ def check_if_integration_branch_is_up_to_date(
integration_branch = None integration_branch = None
branch_list = [] branch_list = []
if merge_request.source_branch.startswith("integrate/gitlab-ci"): if common.is_gitlab_ci_integration_branch(merge_request.source_branch):
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) branch_list.append(merge_request.source_branch)
except GitlabGetError: except GitlabGetError:
# Branch not found # Branch not found
pass pass
...@@ -40,9 +39,7 @@ def check_if_integration_branch_is_up_to_date( ...@@ -40,9 +39,7 @@ def check_if_integration_branch_is_up_to_date(
except GitlabGetError: except GitlabGetError:
sys.exit( sys.exit(
"ERROR: could not find integration branch in {}," "ERROR: could not find integration branch in {},"
"branch names checked: {}\n".format( "branch names checked: {}\n".format(manifest_project.name, branch_list)
manifest_project.name,
branch_list)
) )
try: try:
......
...@@ -22,6 +22,11 @@ def integration_branch_name(project_name, branch_name): ...@@ -22,6 +22,11 @@ def integration_branch_name(project_name, branch_name):
return "integrate/" + project_name.lower() + "/" + branch_name return "integrate/" + project_name.lower() + "/" + branch_name
def is_gitlab_ci_integration_branch(branch_name):
gitlab_ci_integration_branch = "integrate/.gitlab_ci"
return branch_name.startswith(gitlab_ci_integration_branch)
def find_gitlab_ci_integration_branch(repo: Repo, branch_name): def find_gitlab_ci_integration_branch(repo: Repo, branch_name):
""" """
# Special handling for the gitlab-ci integration # Special handling for the gitlab-ci integration
...@@ -29,7 +34,7 @@ def find_gitlab_ci_integration_branch(repo: Repo, branch_name): ...@@ -29,7 +34,7 @@ def find_gitlab_ci_integration_branch(repo: Repo, branch_name):
# integrate/gitlab-ci we add our new commit to this branch # integrate/gitlab-ci we add our new commit to this branch
# Otherwise (normal behaviour) a new integration branch is created # Otherwise (normal behaviour) a new integration branch is created
""" """
if not branch_name.startswith("integrate/gitlab-ci"): if not is_gitlab_ci_integration_branch(branch_name):
return None return None
logging.debug("Integration of gitlab-ci: %s", branch_name) logging.debug("Integration of gitlab-ci: %s", branch_name)
......
...@@ -134,10 +134,9 @@ def main(): ...@@ -134,10 +134,9 @@ def main():
# Start with the manifest here, so the subproject # Start with the manifest here, so the subproject
# can see that they are already integrated # can see that they are already integrated
for p in [args.project] + args.projects: for p in args.projects + [args.project]:
project = common.get_project(gitlab, p) project = common.get_project(gitlab, p)
branch = args.branch branch = args.branch
should_remove_source_branch = True
if branch is None: if branch is None:
branch = project.default_branch branch = project.default_branch
...@@ -161,10 +160,6 @@ def main(): ...@@ -161,10 +160,6 @@ def main():
if p == args.project: if p == args.project:
manifest_project = project manifest_project = project
manifest_integration_mr = mr manifest_integration_mr = mr
# For the manifest we keep the source branch
# otherwise does the check job fail for not yet merged
# child projects
should_remove_source_branch = False
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
...@@ -176,8 +171,8 @@ def main(): ...@@ -176,8 +171,8 @@ def main():
mr, mr,
# 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
# TODO implement rebase
rebase=(p == args.project), rebase=(p == args.project),
should_remove_source_branch=should_remove_source_branch,
) )
if not merged: if not merged:
......
...@@ -10,7 +10,6 @@ from accept_merge_request import accept_merge_request ...@@ -10,7 +10,6 @@ from accept_merge_request import accept_merge_request
from create_merge_request import create_merge_request from create_merge_request import create_merge_request
from get_merge_requests import get_merge_requests from get_merge_requests import get_merge_requests
from integrate_into_manifest import integrate_into_manifest from integrate_into_manifest import integrate_into_manifest
from get_current_revision_from_manifest import get_current_revision_from_manifest
def merge_into_manifest( def merge_into_manifest(
...@@ -28,28 +27,6 @@ def merge_into_manifest( ...@@ -28,28 +27,6 @@ def merge_into_manifest(
the current manifest master. the current manifest master.
""" """
# Check if the commit is already merged
# Currently this is especially true if the gitlab-ci
# pipeline already has merged an gitlab-ci update
current_revisions = get_current_revision_from_manifest(
manifest_project=manifest_project,
manifest_branch=master_branch,
project=project,
recipe_name=recipe_name,
srcrev_file=srcrev_file,
)
logging.debug(current_revisions)
# This commit is contained there if current_revisions contains
# it directly or any parrent of current_revisions is commit
for rev in current_revisions.values():
if common.is_commit_parent_of_project_commit(project, rev, commit):
print(
"Commit {} is already merged into {}".format(
commit, manifest_project.name
)
)
return ""
# Get source merge request # Get source merge request
mrs = get_merge_requests( mrs = get_merge_requests(
project, project,
...@@ -65,6 +42,13 @@ def merge_into_manifest( ...@@ -65,6 +42,13 @@ def merge_into_manifest(
# Get original branch for commit # Get original branch for commit
original_branch = source_mr.source_branch original_branch = source_mr.source_branch
if common.is_gitlab_ci_integration_branch(original_branch):
print(
"Commit {} is a gitlab-ci integration branch and will be merged by the gitlab-ci pipeline."
)
return ""
integration_branch = common.integration_branch_name(project.name, original_branch) integration_branch = common.integration_branch_name(project.name, original_branch)
target_branch = master_branch target_branch = master_branch
......
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