mirror of
https://github.com/odoo/runbot.git
synced 2025-03-27 13:25:47 +07:00
[IMP] runbot: copy steps when duplicating a config
When a build.config is copied, the config steps are not copied. The steps have to be explicitly ordered otherwise it leads to a traceback when trying to copy a 'run' step which have to be the last one.
This commit is contained in:
parent
31e10a059e
commit
3a428d4877
@ -26,7 +26,7 @@ class Config(models.Model):
|
|||||||
|
|
||||||
name = fields.Char('Config name', required=True, unique=True, track_visibility='onchange', help="Unique name for config please use trigram as postfix for custom configs")
|
name = fields.Char('Config name', required=True, unique=True, track_visibility='onchange', help="Unique name for config please use trigram as postfix for custom configs")
|
||||||
description = fields.Char('Config description')
|
description = fields.Char('Config description')
|
||||||
step_order_ids = fields.One2many('runbot.build.config.step.order', 'config_id')
|
step_order_ids = fields.One2many('runbot.build.config.step.order', 'config_id', copy=True)
|
||||||
update_github_state = fields.Boolean('Notify build state to github', default=False, track_visibility='onchange')
|
update_github_state = fields.Boolean('Notify build state to github', default=False, track_visibility='onchange')
|
||||||
protected = fields.Boolean('Protected', default=False, track_visibility='onchange')
|
protected = fields.Boolean('Protected', default=False, track_visibility='onchange')
|
||||||
group = fields.Many2one('runbot.build.config', 'Configuration group', help="Group of config's and config steps")
|
group = fields.Many2one('runbot.build.config', 'Configuration group', help="Group of config's and config steps")
|
||||||
@ -55,7 +55,7 @@ class Config(models.Model):
|
|||||||
|
|
||||||
def step_ids(self):
|
def step_ids(self):
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
return [ordered_step.step_id for ordered_step in self.step_order_ids]
|
return [ordered_step.step_id for ordered_step in self.step_order_ids.sorted('sequence')]
|
||||||
|
|
||||||
def _check_step_ids_order(self):
|
def _check_step_ids_order(self):
|
||||||
install_job = False
|
install_job = False
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from unittest.mock import patch, mock_open
|
from unittest.mock import patch, mock_open
|
||||||
from odoo.tests import common
|
from odoo.exceptions import UserError
|
||||||
from odoo.addons.runbot.models.repo import RunbotException
|
from odoo.addons.runbot.models.repo import RunbotException
|
||||||
from .common import RunbotCase
|
from .common import RunbotCase
|
||||||
|
|
||||||
@ -83,6 +83,67 @@ class TestBuildConfigStep(RunbotCase):
|
|||||||
|
|
||||||
self.assertFalse(self.parent_build.global_result)
|
self.assertFalse(self.parent_build.global_result)
|
||||||
|
|
||||||
|
def test_config_step_raises(self):
|
||||||
|
""" Test a config raises when run step position is wrong"""
|
||||||
|
|
||||||
|
run_step = self.ConfigStep.create({
|
||||||
|
'name': 'run_step',
|
||||||
|
'job_type': 'run_odoo',
|
||||||
|
})
|
||||||
|
|
||||||
|
create_step = self.ConfigStep.create({
|
||||||
|
'name': 'test_step',
|
||||||
|
'job_type': 'create_build',
|
||||||
|
})
|
||||||
|
|
||||||
|
config = self.Config.create({'name': 'test_config'})
|
||||||
|
|
||||||
|
# test that the run_odoo step has to be the last one
|
||||||
|
with self.assertRaises(UserError):
|
||||||
|
config.write({
|
||||||
|
'step_order_ids': [
|
||||||
|
(0, 0, {'sequence': 10, 'step_id': run_step.id}),
|
||||||
|
(0, 0, {'sequence': 15, 'step_id': create_step.id}),
|
||||||
|
]
|
||||||
|
})
|
||||||
|
|
||||||
|
# test that the run_odoo step should be preceded by an install step
|
||||||
|
with self.assertRaises(UserError):
|
||||||
|
config.write({
|
||||||
|
'step_order_ids': [
|
||||||
|
(0, 0, {'sequence': 15, 'step_id': run_step.id}),
|
||||||
|
(0, 0, {'sequence': 10, 'step_id': create_step.id}),
|
||||||
|
]
|
||||||
|
})
|
||||||
|
|
||||||
|
def test_config_step_copy(self):
|
||||||
|
""" Test a config copy with step_order_ids """
|
||||||
|
|
||||||
|
install_step = self.ConfigStep.create({
|
||||||
|
'name': 'install_step',
|
||||||
|
'job_type': 'install_odoo'
|
||||||
|
})
|
||||||
|
|
||||||
|
run_step = self.ConfigStep.create({
|
||||||
|
'name': 'run_step',
|
||||||
|
'job_type': 'run_odoo',
|
||||||
|
})
|
||||||
|
|
||||||
|
create_step = self.ConfigStep.create({
|
||||||
|
'name': 'test_step',
|
||||||
|
'job_type': 'create_build',
|
||||||
|
})
|
||||||
|
|
||||||
|
config = self.Config.create({'name': 'test_config'})
|
||||||
|
StepOrder = self.env['runbot.build.config.step.order']
|
||||||
|
# Creation order is impoortant to reproduce the Odoo copy bug/feature :-)
|
||||||
|
StepOrder.create({'sequence': 15, 'step_id': run_step.id, 'config_id': config.id})
|
||||||
|
StepOrder.create({'sequence': 10, 'step_id': create_step.id, 'config_id': config.id})
|
||||||
|
StepOrder.create({'sequence': 12, 'step_id': install_step.id, 'config_id': config.id})
|
||||||
|
|
||||||
|
dup_config = config.copy()
|
||||||
|
self.assertEqual(dup_config.step_order_ids.mapped('step_id'), config.step_order_ids.mapped('step_id'))
|
||||||
|
|
||||||
@patch('odoo.addons.runbot.models.build.runbot_build._checkout')
|
@patch('odoo.addons.runbot.models.build.runbot_build._checkout')
|
||||||
def test_coverage(self, mock_checkout):
|
def test_coverage(self, mock_checkout):
|
||||||
config_step = self.ConfigStep.create({
|
config_step = self.ConfigStep.create({
|
||||||
|
Loading…
Reference in New Issue
Block a user