mirror of
https://github.com/odoo/runbot.git
synced 2025-03-15 15:35:46 +07:00
[IMP] runbot: allow to use dev foreigh branches
Using dev branch from foreign project to fill missing commits looks like a bad idea, mainly because the lifecycle of the branches is not the same In some case, it can be useful to allow that to test a branch with a future change in the base project that will be needed to make the branch work. As an example introducing a small api change in odoo to make an override easier, or introducing a module that may be needed to use the feature. This commit changes that by allowing to configure on the project or bundle if we allow to use foreign bundle as reference *before* checking the base bundle.
This commit is contained in:
parent
3f260ba08f
commit
f2dd945873
@ -181,11 +181,13 @@ class Batch(models.Model):
|
||||
dependency_repos = triggers.mapped('dependency_ids')
|
||||
all_repos = triggers.mapped('repo_ids') | dependency_repos
|
||||
missing_repos = all_repos - pushed_repo
|
||||
foreign_projects = dependency_repos.mapped('project_id') - project
|
||||
|
||||
######################################
|
||||
# Find missing commits
|
||||
######################################
|
||||
def _fill_missing(branch_commits, match_type):
|
||||
used_branches = []
|
||||
if branch_commits:
|
||||
for branch, commit in branch_commits.items(): # branch first in case pr is closed.
|
||||
nonlocal missing_repos
|
||||
@ -203,6 +205,8 @@ class Batch(models.Model):
|
||||
values['merge_base_commit_id'] = commit.id
|
||||
self.write({'commit_link_ids': [(0, 0, values)]})
|
||||
missing_repos -= commit.repo_id
|
||||
used_branches.append(branch)
|
||||
return used_branches
|
||||
|
||||
# CHECK branch heads consistency
|
||||
branch_per_repo = {}
|
||||
@ -249,6 +253,14 @@ class Batch(models.Model):
|
||||
if batches:
|
||||
self.base_reference_batch_id = batches[0]
|
||||
|
||||
if missing_repos and bundle.always_use_foreign and foreign_projects:
|
||||
self._log('Starting by filling foreign repo')
|
||||
foreign_bundles = bundle.search([('name', '=', bundle.name), ('project_id', 'in', foreign_projects.ids)])
|
||||
used_branches = _fill_missing({branch: branch.head for branch in foreign_bundles.mapped('branch_ids').sorted('is_pr', reverse=True)}, 'head')
|
||||
if used_branches:
|
||||
commits = ', '.join([f'[{branch.repo_id.name}]({branch.bundle_id.name})' for branch in used_branches])
|
||||
self._log(f'Found {len(used_branches)} commits in foreigh repo: {commits}')
|
||||
|
||||
batch = self.base_reference_batch_id
|
||||
if batch:
|
||||
if missing_repos:
|
||||
@ -279,14 +291,9 @@ class Batch(models.Model):
|
||||
|
||||
# 4. FIND missing commit in foreign project
|
||||
if missing_repos:
|
||||
foreign_projects = dependency_repos.mapped('project_id') - project
|
||||
if foreign_projects:
|
||||
self._log('Not all commit found. Fallback on foreign base branches heads.')
|
||||
foreign_bundles = bundle.search([('name', '=', bundle.name), ('project_id', 'in', foreign_projects.ids)])
|
||||
_fill_missing({branch: branch.head for branch in foreign_bundles.mapped('branch_ids').sorted('is_pr', reverse=True)}, 'head')
|
||||
if missing_repos:
|
||||
foreign_bundles = bundle.search([('name', '=', bundle.base_id.name), ('project_id', 'in', foreign_projects.ids)])
|
||||
_fill_missing({branch: branch.head for branch in foreign_bundles.mapped('branch_ids')}, 'base_head')
|
||||
base_foreign_bundles = bundle.search([('name', '=', bundle.base_id.name), ('project_id', 'in', foreign_projects.ids)])
|
||||
_fill_missing({branch: branch.head for branch in base_foreign_bundles.mapped('branch_ids')}, 'base_head')
|
||||
|
||||
# CHECK missing commit
|
||||
if missing_repos:
|
||||
|
@ -7,8 +7,6 @@ from collections import defaultdict
|
||||
from odoo import models, fields, api, tools
|
||||
from ..common import dt2time, s2human_long
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class Bundle(models.Model):
|
||||
_name = 'runbot.bundle'
|
||||
@ -23,6 +21,7 @@ class Bundle(models.Model):
|
||||
no_build = fields.Boolean('No build')
|
||||
no_auto_run = fields.Boolean('No run')
|
||||
build_all = fields.Boolean('Force all triggers')
|
||||
always_use_foreign = fields.Boolean('Use foreigh bundle', help='By default, check for the same bundle name in another project to fill missing commits.', default=lambda self: self.project_id.always_use_foreign)
|
||||
modules = fields.Char("Modules to install", help="Comma-separated list of modules to install and test.")
|
||||
|
||||
batch_ids = fields.One2many('runbot.batch', 'bundle_id')
|
||||
|
@ -17,6 +17,8 @@ class Project(models.Model):
|
||||
token = fields.Char("Github token", groups="runbot.group_runbot_admin")
|
||||
master_bundle_id = fields.Many2one('runbot.bundle', string='Master bundle')
|
||||
dummy_bundle_id = fields.Many2one('runbot.bundle', string='Dummy bundle')
|
||||
always_use_foreign = fields.Boolean('Use foreigh bundle', help='By default, check for the same bundle name in another project to fill missing commits.', default=False)
|
||||
|
||||
|
||||
@api.model_create_multi
|
||||
def create(self, vals_list):
|
||||
|
@ -8,6 +8,7 @@
|
||||
<group>
|
||||
<field name="name"/>
|
||||
<field name="keep_sticky_running"/>
|
||||
<field name="always_use_foreign"/>
|
||||
<field name="dockerfile_id"/>
|
||||
<field name="group_ids"/>
|
||||
<field name="trigger_ids"/>
|
||||
@ -58,6 +59,7 @@
|
||||
<field name="no_auto_run"/>
|
||||
<field name="priority"/>
|
||||
<field name="build_all"/>
|
||||
<field name="always_use_foreign"/>
|
||||
<field name="dockerfile_id"/>
|
||||
<field name="host_id" readonly="0"/>
|
||||
<field name="commit_limit"/>
|
||||
|
Loading…
Reference in New Issue
Block a user