[IMP] runbot: add to_upgrade option

For now, the sticky flag is used to define bundle to use as target to upgrade.
The plan for future is to continue to test upgrade, even if the bundle is not sticky anymore.
This new flag will allow to remove sticky for old branche.
This will also allow to disable upgrda tests for still sticky branches when needed.

This commit also filter source bundle based on this flag
(before that all base bundle where used as source, even if not sticky)
This commit is contained in:
Xavier-Do 2020-11-17 12:36:02 +01:00 committed by xdo
parent 6aab868883
commit 4ab669e371
3 changed files with 17 additions and 8 deletions

View File

@ -740,26 +740,26 @@ class ConfigStep(models.Model):
upgrade_complement_step = trigger.upgrade_dumps_trigger_id.upgrade_step_id
if next_versions:
if next_versions and bundle.to_upgrade:
for next_version in next_versions:
if bundle.version_id in upgrade_complement_step._get_upgrade_source_versions(next_version):
target_versions |= next_version
return target_versions.with_context(
category_id=category_id, project_id=bundle.project_id.id
).mapped('base_bundle_id.last_done_batch')
).mapped('base_bundle_id').filtered('to_upgrade').mapped('last_done_batch')
def _reference_batches_upgrade(self, bundle, category_id):
target_refs_bundles = self.env['runbot.bundle']
sticky_domain = [('sticky', '=', True), ('project_id', '=', bundle.project_id.id)]
upgrade_domain = [('to_upgrade', '=', True), ('project_id', '=', bundle.project_id.id)]
if self.upgrade_to_version_ids:
target_refs_bundles |= self.env['runbot.bundle'].search(sticky_domain + [('version_id', 'in', self.upgrade_to_version_ids.ids)])
target_refs_bundles |= self.env['runbot.bundle'].search(upgrade_domain + [('version_id', 'in', self.upgrade_to_version_ids.ids)])
else:
if self.upgrade_to_master:
target_refs_bundles |= self.env['runbot.bundle'].search(sticky_domain + [('name', '=', 'master')])
target_refs_bundles |= self.env['runbot.bundle'].search(upgrade_domain + [('name', '=', 'master')])
if self.upgrade_to_all_versions:
target_refs_bundles |= self.env['runbot.bundle'].search(sticky_domain + [('name', '!=', 'master')])
target_refs_bundles |= self.env['runbot.bundle'].search(upgrade_domain + [('name', '!=', 'master')])
elif self.upgrade_to_major_versions:
target_refs_bundles |= self.env['runbot.bundle'].search(sticky_domain + [('name', '!=', 'master'), ('version_id.is_major', '=', True)])
target_refs_bundles |= self.env['runbot.bundle'].search(upgrade_domain + [('name', '!=', 'master'), ('version_id.is_major', '=', True)])
source_refs_bundles = self.env['runbot.bundle']
@ -774,13 +774,14 @@ class ConfigStep(models.Model):
source_refs_bundles |= f_bundle.intermediate_version_base_ids[-1]
if self.upgrade_from_version_ids:
source_refs_bundles |= self.env['runbot.bundle'].search(sticky_domain + [('version_id', 'in', self.upgrade_from_version_ids.ids)])
source_refs_bundles |= self.env['runbot.bundle'].search(upgrade_domain + [('version_id', 'in', self.upgrade_from_version_ids.ids)])
# this is subject to discussion. should this be smart and filter 'from_versions' or should it be flexible and do all possibilities
else:
if self.upgrade_to_current:
from_versions(bundle)
for f_bundle in target_refs_bundles:
from_versions(f_bundle)
source_refs_bundles = source_refs_bundles.filtered('to_upgrade')
return (target_refs_bundles | source_refs_bundles).with_context(
category_id=category_id

View File

@ -33,6 +33,7 @@ class Bundle(models.Model):
is_base = fields.Boolean('Is base', index=True)
defined_base_id = fields.Many2one('runbot.bundle', 'Forced base bundle', domain="[('project_id', '=', project_id), ('is_base', '=', True)]")
base_id = fields.Many2one('runbot.bundle', 'Base bundle', compute='_compute_base_id', store=True)
to_upgrade = fields.Boolean('To upgrade', compute='_compute_to_upgrade', store=True, index=False)
version_id = fields.Many2one('runbot.version', 'Version', compute='_compute_version_id', store=True)
version_number = fields.Char(related='version_id.number', store=True, index=True)
@ -76,6 +77,11 @@ class Bundle(models.Model):
for bundle in self:
bundle.sticky = bundle.is_base
@api.depends('is_base')
def _compute_to_upgrade(self):
for bundle in self:
bundle.to_upgrade = bundle.is_base
@api.depends('name', 'is_base', 'defined_base_id', 'base_id.is_base', 'project_id')
def _compute_base_id(self):
for bundle in self:

View File

@ -25,6 +25,7 @@
<field name="name"/>
<field name="project_id"/>
<field name="sticky" readonly="0"/>
<field name="to_upgrade" readonly="0"/>
<field name="is_base"/>
<field name="base_id"/>
<field name="defined_base_id"/>
@ -70,6 +71,7 @@
<field name="version_number"/>
<field name="is_base"/>
<field name="sticky"/>
<field name="to_upgrade"/>
<field name="no_build"/>
<field name="branch_ids"/>
<field name="version_id"/>