Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IMP] runbot: qualify errors on selected field #1007

Open
wants to merge 1 commit into
base: 18.0
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions runbot/models/build_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ def _qualify(self):
for record in self:
all_qualifiers = {}
for qualify_regex in qualify_regexes:
res = qualify_regex._qualify(record.content) # TODO, MAYBE choose the source field
res = qualify_regex._qualify(record[qualify_regex.source_field])
if res:
# res.update({'qualifier_id': qualify_regex.id}) Probably not a good idea
all_qualifiers.update(res)
Expand Down Expand Up @@ -671,7 +671,7 @@ class ErrorQualifyRegex(models.Model):
source_field = fields.Selection(
[
("content", "Content"),
("module", "Module Name"),
("module_name", "Module Name"),
("function", "Function Name"),
("file_path", "File Path"),
],
Expand Down Expand Up @@ -739,8 +739,8 @@ class QualifyErrorTest(models.Model):

qualify_regex_id = fields.Many2one('runbot.error.qualify.regex', required=True)
error_content_id = fields.Many2one('runbot.build.error.content', string='Build Error', required=True)
build_error_summary = fields.Char(related='error_content_id.summary')
build_error_content = fields.Text(related='error_content_id.content')
build_error_summary = fields.Char(compute='_compute_summary')
build_error_content = fields.Text(compute='_compute_content')
expected_result = JsonDictField('Expected Qualifiers')
result = JsonDictField('Result', compute='_compute_result')
is_matching = fields.Boolean(compute='_compute_result', default=False)
Expand All @@ -750,3 +750,14 @@ def _compute_result(self):
for record in self:
record.result = record.qualify_regex_id._qualify(record.build_error_content)
record.is_matching = record.result == record.expected_result and record.result != {}

@api.depends('qualify_regex_id', 'error_content_id')
def _compute_summary(self):
for record in self:
content = record.error_content_id[record.qualify_regex_id.source_field]
record.build_error_summary = content[:70] if content else False

@api.depends('qualify_regex_id', 'error_content_id')
def _compute_content(self):
for record in self:
record.build_error_content = record.error_content_id[record.qualify_regex_id.source_field]