mirror of
https://github.com/odoo/runbot.git
synced 2025-03-27 13:25:47 +07:00
[IMP] runbot: allow build copy
This commit is contained in:
parent
c561f212e2
commit
6909b7e583
@ -22,6 +22,9 @@ class JsonDictField(Field):
|
|||||||
def convert_to_record(self, value, record):
|
def convert_to_record(self, value, record):
|
||||||
return FieldDict(value or {}, self, record)
|
return FieldDict(value or {}, self, record)
|
||||||
|
|
||||||
|
def convert_to_read(self, value, record, use_name_get=True):
|
||||||
|
return self.convert_to_cache(value, record)
|
||||||
|
|
||||||
|
|
||||||
class FieldDict(MutableMapping):
|
class FieldDict(MutableMapping):
|
||||||
|
|
||||||
|
@ -24,6 +24,27 @@ _logger = logging.getLogger(__name__)
|
|||||||
result_order = ['ok', 'warn', 'ko', 'skipped', 'killed', 'manually_killed']
|
result_order = ['ok', 'warn', 'ko', 'skipped', 'killed', 'manually_killed']
|
||||||
state_order = ['pending', 'testing', 'waiting', 'running', 'duplicate', 'done']
|
state_order = ['pending', 'testing', 'waiting', 'running', 'duplicate', 'done']
|
||||||
|
|
||||||
|
COPY_WHITELIST = [
|
||||||
|
"branch_id",
|
||||||
|
"repo_id",
|
||||||
|
"name",
|
||||||
|
"description",
|
||||||
|
"date",
|
||||||
|
"author",
|
||||||
|
"author_email",
|
||||||
|
"committer",
|
||||||
|
"committer_email",
|
||||||
|
"subject",
|
||||||
|
"config_data",
|
||||||
|
"extra_params",
|
||||||
|
"build_type",
|
||||||
|
"parent_id",
|
||||||
|
"hidden",
|
||||||
|
"dependency_ids",
|
||||||
|
"config_id",
|
||||||
|
"orphan_result",
|
||||||
|
"commit_path_mode",
|
||||||
|
]
|
||||||
|
|
||||||
def make_selection(array):
|
def make_selection(array):
|
||||||
def format(string):
|
def format(string):
|
||||||
@ -56,7 +77,7 @@ class runbot_build(models.Model):
|
|||||||
sequence = fields.Integer('Sequence')
|
sequence = fields.Integer('Sequence')
|
||||||
log_ids = fields.One2many('ir.logging', 'build_id', string='Logs')
|
log_ids = fields.One2many('ir.logging', 'build_id', string='Logs')
|
||||||
error_log_ids = fields.One2many('ir.logging', 'build_id', domain=[('level', 'in', ['WARNING', 'ERROR', 'CRITICAL'])], string='Error Logs')
|
error_log_ids = fields.One2many('ir.logging', 'build_id', domain=[('level', 'in', ['WARNING', 'ERROR', 'CRITICAL'])], string='Error Logs')
|
||||||
config_data = JsonDictField('Json Data')
|
config_data = JsonDictField('Config Data')
|
||||||
|
|
||||||
# state machine
|
# state machine
|
||||||
|
|
||||||
@ -101,7 +122,7 @@ class runbot_build(models.Model):
|
|||||||
# should we add a has children stored boolean?
|
# should we add a has children stored boolean?
|
||||||
hidden = fields.Boolean("Don't show build on main page", default=False) # index?
|
hidden = fields.Boolean("Don't show build on main page", default=False) # index?
|
||||||
children_ids = fields.One2many('runbot.build', 'parent_id')
|
children_ids = fields.One2many('runbot.build', 'parent_id')
|
||||||
dependency_ids = fields.One2many('runbot.build.dependency', 'build_id')
|
dependency_ids = fields.One2many('runbot.build.dependency', 'build_id', copy=True)
|
||||||
|
|
||||||
config_id = fields.Many2one('runbot.build.config', 'Run Config', required=True, default=lambda self: self.env.ref('runbot.runbot_build_config_default', raise_if_not_found=False))
|
config_id = fields.Many2one('runbot.build.config', 'Run Config', required=True, default=lambda self: self.env.ref('runbot.runbot_build_config_default', raise_if_not_found=False))
|
||||||
real_build = fields.Many2one('runbot.build', 'Real Build', help="duplicate_id or self", compute='_compute_real_build')
|
real_build = fields.Many2one('runbot.build', 'Real Build', help="duplicate_id or self", compute='_compute_real_build')
|
||||||
@ -190,8 +211,18 @@ class runbot_build(models.Model):
|
|||||||
for build in self:
|
for build in self:
|
||||||
build.real_build = build.duplicate_id or build
|
build.real_build = build.duplicate_id or build
|
||||||
|
|
||||||
def copy(self, values=None):
|
def copy_data(self, default=None):
|
||||||
raise UserError("Cannot duplicate build!")
|
values = super().copy_data(default)[0]
|
||||||
|
values = {key: value for key, value in values.items() if key in COPY_WHITELIST}
|
||||||
|
values.update({
|
||||||
|
'host': 'PAUSED', # hack to keep the build in pending waiting for a manual update. Todo: add a paused state instead
|
||||||
|
'local_state': 'pending',
|
||||||
|
})
|
||||||
|
return [values]
|
||||||
|
|
||||||
|
def copy(self, default=None):
|
||||||
|
return super(runbot_build, self.with_context(force_rebuild=True)).copy(default)
|
||||||
|
|
||||||
|
|
||||||
@api.model_create_single
|
@api.model_create_single
|
||||||
def create(self, vals):
|
def create(self, vals):
|
||||||
@ -355,14 +386,14 @@ class runbot_build(models.Model):
|
|||||||
for build in self:
|
for build in self:
|
||||||
if build.duplicate_id:
|
if build.duplicate_id:
|
||||||
build.job_time = build.duplicate_id.job_time
|
build.job_time = build.duplicate_id.job_time
|
||||||
elif build.job_end:
|
elif build.job_end and build.job_start:
|
||||||
build.job_time = int(dt2time(build.job_end) - dt2time(build.job_start))
|
build.job_time = int(dt2time(build.job_end) - dt2time(build.job_start))
|
||||||
elif build.job_start:
|
elif build.job_start:
|
||||||
build.job_time = int(time.time() - dt2time(build.job_start))
|
build.job_time = int(time.time() - dt2time(build.job_start))
|
||||||
else:
|
else:
|
||||||
build.job_time = 0
|
build.job_time = 0
|
||||||
|
|
||||||
@api.depends('build_start', 'build_end', 'duplicate_id.build_time')
|
@api.depends('build_start', 'build_end', 'global_state', 'duplicate_id.build_time')
|
||||||
def _compute_build_time(self):
|
def _compute_build_time(self):
|
||||||
for build in self:
|
for build in self:
|
||||||
if build.duplicate_id:
|
if build.duplicate_id:
|
||||||
|
Loading…
Reference in New Issue
Block a user