Skip to content
Snippets Groups Projects
Commit 9cfa350f authored by Lorenzo Pagliai's avatar Lorenzo Pagliai
Browse files

[CHANGELOG] Improve search for MRs to be collected

* Since now, for each project, the script was searching only for MRs
that were merged into branches having the same name of the manifest main
branch.
* In order to correct this approach, we define a function that searches
  for the INTEGRATION variable in each project and get the name of
the branch whose changes are integrated into the manifest main branch. If
more than one branch integrates into the manifest one, all of them are
considered in the search for MRs to be inserted in the changelog.
* Include BSP repositories and new meta-layers in CHANGELOG_PROJECTS
  variable
parent 6f901acf
No related branches found
No related tags found
No related merge requests found
......@@ -18,11 +18,26 @@ variables:
# Projects to include in the changelog in addition to the manifest project
CHANGELOG_PROJECTS:
edgehog/bsp/nxp/linux-seco-imx
edgehog/bsp/nxp/u-boot-seco-imx
edgehog/bsp/nxp/tools/imx-mkimage
edgehog/bsp/rockchip/linux-seco-rk
edgehog/bsp/rockchip/u-boot-seco-rk
edgehog/bsp/rockchip/tools/rk-tools
edgehog/bsp/rockchip/tools/rkbin
edgehog/tools/menuconfig
edgehog/tools/seco-eeprom-manager
edgehog/seco-base
edgehog/firmware/tools/STM_D23_Tester
edgehog/layers/seco/meta-seco-imx
edgehog/layers/seco/meta-seco-rk
edgehog/layers/seco/meta-seco-intel
edgehog/layers/seco/meta-seco-edgehog-things
edgehog/layers/seco/meta-seco-edgehog-embedded
edgehog/layers/seco/meta-seco-rpi
edgehog/layers/seco/meta-seco-bsp
edgehog/layers/seco/meta-seco-core
edgehog/layers/seco/meta-seco-edgehog
edgehog/layers/external/poky
IMAGES_PATH: "tmp/deploy/images"
TAG_NAME: weekly
......
......@@ -38,6 +38,35 @@ def decode_timestamp(t):
timestamp = datetime.datetime.strptime(t, GITLAB_TIMEFORMAT)
return timestamp
def get_project_branch_from_integration(gitlab, project_path, manifest_branch):
# Get project ID from project path
project_id = gitlab.projects.get(project_path).id
# Get CICD variables for the project
variables = gitlab.projects.get(project_id).variables.list()
# Initialize dictionary to store project branches corresponding to manifest branches
branch_project_dict = {}
# Parse INTEGRATION variable and extract
for variable in variables:
if variable.key == 'INTEGRATION':
integration_value = variable.value.split('\n')
for line in integration_value:
parts = line.split(':')
branch_project, manifest, branch_manifest = parts
if branch_manifest == manifest_branch:
if branch_manifest not in branch_project_dict:
branch_project_dict[branch_manifest] = []
branch_project_dict[branch_manifest].append(branch_project)
# If INTEGRATION variable is not defined or no matching branch_project found, use manifest_branch as branch_project
if not branch_project_dict:
branch_project_dict = {manifest_branch: [manifest_branch]}
# Return branch_projects corresponding to branch_manifest
return branch_project_dict.get(manifest_branch, [])
class Project:
def __init__(self, project):
......@@ -272,23 +301,27 @@ def main(args):
releases = sorted(releases, key=lambda d: d.tag.timestamp, reverse=False)
for p in projects:
for mr in p.project.mergerequests.list(
scope="all", state="merged", target_branch=options.branch, per_page="10000"
):
m = MergeRequest(mr, p)
for r in releases:
if r.add_mergerequest(m):
break
#Iterate again over MR because of the kirkstone/develop -> kirkstone changement
old_branch="kirkstone/develop"
for mr in p.project.mergerequests.list(
scope="all", state="merged", target_branch=old_branch, per_page="10000"
):
m = MergeRequest(mr, p)
for r in releases:
if r.add_mergerequest(m):
break
project_namespace=p.project.path_with_namespace
branch_list=get_project_branch_from_integration(gitlab, project_namespace, options.branch)
for branch in branch_list:
#print(f"For this project {project_namespace} we search for the MRs on this branch {branch}")
for mr in p.project.mergerequests.list(
scope="all", state="merged", target_branch=branch, per_page="10000"
):
m = MergeRequest(mr, p)
for r in releases:
if r.add_mergerequest(m):
break
#Iterate again over MR because of the kirkstone/develop -> kirkstone changement
old_branch="kirkstone/develop"
for mr in p.project.mergerequests.list(
scope="all", state="merged", target_branch=old_branch, per_page="10000"
):
m = MergeRequest(mr, p)
for r in releases:
if r.add_mergerequest(m):
break
# Sort by date, newest first
releases = sorted(releases, key=lambda d: d.tag.timestamp, reverse=True)
......
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