[IMP] runbot: better support of canonical tags

This commit is contained in:
Xavier-Do 2025-03-07 13:24:07 +01:00 committed by xdo
parent f37bb26a78
commit 26bd94170a
2 changed files with 40 additions and 13 deletions

View File

@ -100,6 +100,7 @@ class BuildError(models.Model):
fixing_pr_url = fields.Char('Fixing PR url', related='fixing_pr_id.branch_url')
test_tags = fields.Char(string='Test tags', help="Comma separated list of test_tags to use to reproduce/remove this error", tracking=True)
canonical_tags = fields.Char('Canonical tag', compute='_compute_canonical_tags', store=True)
tags_min_version_excluded_id = fields.Many2one('runbot.version', 'Tag min version (excluded)')
tags_min_version_id = fields.Many2one('runbot.version', 'Tags Min version', compute="_compute_tags_min_version_id", inverse="_inverse_tags_min_version_id", help="Minimal version where the test tags will be applied.", tracking=True)
tags_max_version_id = fields.Many2one('runbot.version', 'Tags Max version', help="Maximal version where the test tags will be applied.", tracking=True)
@ -135,6 +136,11 @@ class BuildError(models.Model):
if records.tags_min_version_id:
records.tags_min_version_excluded_id = next((version for version in all_versions if version.number < records.tags_min_version_id.number), False)
@api.depends('error_content_ids.canonical_tag')
def _compute_canonical_tags(self):
for record in self:
record.canonical_tags = ','.join(record.error_content_ids.filtered('canonical_tag').mapped('canonical_tag'))
@api.depends('tags_min_version_id')
def _compute_tags_min_version_id(self):
all_versions = self.env['runbot.version'].search([]).sorted(lambda rec: (rec.sequence, rec.number))
@ -423,6 +429,12 @@ class BuildError(models.Model):
record.team_id = team
break
def action_copy_canonical_tag(self):
for record in self:
if record.canonical_tags:
record.test_tags = record.canonical_tags
record._onchange_test_tags()
@api.model
def _parse_logs(self, ir_logs):
if not ir_logs:
@ -506,6 +518,7 @@ class BuildErrorContent(models.Model):
content = fields.Text('Error message', required=True)
cleaned_content = fields.Text('Cleaned error message')
metadata = JsonDictField('Metadata')
canonical_tag = fields.Char('Canonical tag', compute='_compute_canonical_tag', store=True)
summary = fields.Char('Content summary', compute='_compute_summary', store=False)
module_name = fields.Char('Module name') # name in ir_logging
file_path = fields.Char('File Path') # path in ir logging
@ -579,6 +592,11 @@ class BuildErrorContent(models.Model):
build_error.error_id._merge(previous_error)
return result
@api.depends('metadata')
def _compute_canonical_tag(self):
for record in self:
record.canonical_tag = record.metadata.get('test', {}).get('canonical_tag')
@api.depends('build_error_link_ids')
def _compute_build_ids(self):
for record in self:
@ -835,10 +853,11 @@ class ErrorQualifyRegex(models.Model):
active = fields.Boolean('Active', default=True, tracking=True)
regex = fields.Char('Regular expression', required=True, tracking=True)
check_canonical_tag = fields.Boolean('Check canonical tag', default=False, help='Apply regex on canonical tag')
check_module_name = fields.Boolean('Check Module Name', default=False, help='Apply regex on Error Module Name')
check_file_path = fields.Boolean('Check File Path', default=False, help='Apply regex on Error Module Name')
check_function = fields.Boolean('Check Function name', default=False, help='Apply regex on Error Function Name')
check_content = fields.Boolean('Check content', default=True, help='Apply regex on Error Csontent')
check_content = fields.Boolean('Check content', default=True, help='Apply regex on Error Content')
check_fields = fields.Char('Checked Fields', compute='_compute_check_fields', help='Fields on which regex is applied')
@ -879,11 +898,11 @@ for error_content in self:
"The regular expresion should contain at least one named group pattern e.g: '(?P<module>.+)'"
)
@api.depends('check_module_name', 'check_file_path', 'check_function', 'check_content')
@api.depends('check_module_name', 'check_file_path', 'check_function', 'check_content', 'check_canonical_tag')
def _compute_check_fields(self):
for record in self:
res = []
for cf in ['module_name', 'file_path', 'function', 'content']:
for cf in ['canonical_tag', 'module_name', 'file_path', 'function', 'content']:
if record[f'check_{cf}']:
res.append(cf)
record.check_fields = ','.join(res)

View File

@ -32,20 +32,16 @@
</list>
</field>
</group>
<group name="fixer_info" string="Fixing" col="2">
<group>
<group>
<group name="fixer_info" string="Fixing" col="2">
<field name="responsible"/>
<field name="customer"/>
<field name="team_id"/>
<field name="fixing_pr_id"/>
<field name="fixing_pr_url" widget="pull_request_url"/>
<field name="active"/>
<field name="test_tags" decoration-danger="True" readonly="1" groups="!runbot.group_runbot_admin"/>
<field name="test_tags" decoration-danger="True" groups="runbot.group_runbot_admin"/>
<field name="tags_min_version_id" invisible="not test_tags"/>
<field name="tags_max_version_id" invisible="not test_tags"/>
</group>
<group>
<group name="appearance_info" string="Appearance" col="2">
<field name="version_ids" widget="many2many_tags"/>
<field name="trigger_ids" widget="many2many_tags"/>
<field name="tag_ids" widget="many2many_tags"/>
@ -56,6 +52,14 @@
<field name="last_seen_build_id" invisible="True"/>
</group>
</group>
<group name="test_tags_group" string="Disabling">
<field name="canonical_tags"/>
<button name="action_copy_canonical_tag" type="object" groups="runbot.group_runbot_admin">Disable test using canonical tag</button>
<field name="test_tags" decoration-danger="True" readonly="1" groups="!runbot.group_runbot_admin"/>
<field name="test_tags" decoration-danger="True" groups="runbot.group_runbot_admin"/>
<field name="tags_min_version_id" invisible="not test_tags"/>
<field name="tags_max_version_id" invisible="not test_tags" />
</group>
<group>
<field name="previous_error_id" readonly="1" invisible="not previous_error_id" text-decoration-danger="True"/>
</group>
@ -205,7 +209,8 @@
</group>
<group name="build_error_group" string="Base info" col="2">
<field name="content" readonly="1"/>
<field name="metadata" readonly="1"/>
<field name="canonical_tag"/>
<field name="metadata" readonly="0" widget="runbotjsonb"/>
<field name="module_name" readonly="1"/>
<field name="function" readonly="1"/>
<field name="file_path" readonly="1"/>
@ -325,6 +330,7 @@
<button name="%(runbot.runbot_open_bulk_wizard)d" string="Bulk Update" type="action" groups="runbot.group_runbot_admin,runbot.group_runbot_error_manager"/>
</header>
<field name="name" optional="show" readonly="1"/>
<field name="canonical_tags" optional="hide" readonly="1"/>
<field name="description" optional="hide" readonly="1"/>
<field name="random" string="Random"/>
<field name="first_seen_date" string="First Seen" optional="hide" readonly="1"/>
@ -360,7 +366,8 @@
<button name="action_qualify" string="Qualify" type="object" groups="runbot.group_runbot_admin,runbot.group_runbot_error_manager"/>
</header>
<field name="error_display_id" optional="show"/>
<field name="module_name" optional="show" readonly="1"/>
<field name="canonical_tag" optional="show" readonly="1"/>
<field name="module_name" optional="hide" readonly="1"/>
<field name="summary" optional="show" readonly="1"/>
<field name="random" string="Random"/>
<field name="first_seen_date" string="First Seen" optional="hide" readonly="1"/>
@ -384,7 +391,7 @@
<field name="arch" type="xml">
<search string="Search errors">
<field name="content"/>
<field name="description"/>
<field name="canonical_tags"/>
<field name="version_ids"/>
<field name="responsible"/>
<field name="team_id"/>
@ -548,6 +555,7 @@
<sheet>
<group name="Regex And Source">
<field name="regex"/>
<field name="check_canonical_tag"/>
<field name="check_module_name"/>
<field name="check_file_path"/>
<field name="check_function"/>