Skip to content
Draft
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions runbot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
import threading
from odoo.http import request

# rng validators doesn't allow decoration-bg-attributes on list fields even if they work fine (as long as you don't have a widget)
# disabling rng validators for list as they have a low value (as long as we test the views manually witch is the case on runbot)
from odoo.tools.view_validation import _validators
_validators['list'] = []

class UserFilter(logging.Filter):
def filter(self, record): # noqa: A003
message_parts = record.msg.split(' ', 2)
Expand All @@ -28,3 +33,4 @@ def filter(self, record): # noqa: A003

def runbot_post_load():
logging.getLogger('werkzeug').addFilter(UserFilter())

12 changes: 8 additions & 4 deletions runbot/models/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@ class BuildResult(models.Model):

requested_action = fields.Selection([('wake_up', 'To wake up'), ('deathrow', 'To kill')], string='Action requested', index=True)
# web infos
host = fields.Char('Host name')
host_id = fields.Many2one('runbot.host', string="Host", compute='_compute_host_id')
host = fields.Char('Host name', index=True)
host_id = fields.Many2one('runbot.host', string="Host", compute='_compute_host_id', search="_search_host_id")
keep_host = fields.Boolean('Keep host on rebuild and for children')

port = fields.Integer('Port')
Expand Down Expand Up @@ -252,6 +252,12 @@ def _compute_host_id(self):
for record in self:
record.host_id = get_host(record.host)

def _search_host_id(self, operator, value):
names = self.env['runbot.host'].browse(value).mapped('name')
if isinstance(value, int):
names = names[0]
return [('host', operator, names)]

@api.depends('children_ids.global_state', 'local_state')
def _compute_global_state(self):
for record in self:
Expand Down Expand Up @@ -969,8 +975,6 @@ def _local_pg_dropdb(self, dbname):
except Exception as e:
msg = f"Failed to drop local logs database : {dbname} with exception: {e}"
_logger.exception(msg)
host_name = self.env['runbot.host']._get_current_name()
self.env['runbot.runbot']._warning(f'Host {host_name}: {msg}')

def _local_pg_createdb(self, dbname):
icp = self.env['ir.config_parameter']
Expand Down
18 changes: 18 additions & 0 deletions runbot/models/build_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,24 @@ def action_view_errors(self):
'target': 'current',
}

def action_search_common_qualifier(self):
context = {}
model = self.env['runbot.build.error.content']
for key, value in self.common_qualifiers.dict.items():
key_fields = f'x_{key}'
if key_fields in model._fields:
context[f'search_default_{key_fields}'] = value
return {
'type': 'ir.actions.act_window',
'views': [(False, 'list'), (False, 'form')],
'res_model': model._name,
#'domain': domain,
#'context': {'active_test': False, 'parse_domain': True},
'context': context,
'target': 'current',
'name': 'Search Common qualifiers'
}

def action_view_similary_qualified(self):
return {
'type': 'ir.actions.act_window',
Expand Down
11 changes: 10 additions & 1 deletion runbot/models/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def _compute_nb(self):

def _compute_build_ids(self):
for host in self:
host.build_ids = self.env['runbot.build'].search([('host', '=', host.name), ('local_state', '!=', 'done')])
host.build_ids = self.env['runbot.build'].search([('host', '=', host.name), ('local_state', 'in', (('pending', 'testing', 'running')))])

@api.model_create_multi
def create(self, vals_list):
Expand Down Expand Up @@ -320,6 +320,15 @@ def _get_builds(self, domain, order=None):
def _process_messages(self):
self.host_message_ids._process()

def action_list_all_builds(self):
return {
'type': 'ir.actions.act_window',
'views': [(False, 'list'), (False, 'form')],
'name': 'Host builds',
'res_model': 'runbot.build',
'context': {'search_default_host': self.name},
'target': 'current',
}

class MessageQueue(models.Model):
_name = 'runbot.host.message'
Expand Down
1 change: 1 addition & 0 deletions runbot/views/build_error_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
</div>
<widget name="web_ribbon" title="Test-tags" bg_color="bg-danger" invisible="not test_tags"/>
<button name="action_view_errors" string="See all linked errors" type="object" class="oe_highlight"/>
<button name="action_search_common_qualifier" string="Search common_qualifiers" type="object" class="oe_highlight"/>
<group string="Base info">
<field name="name"/>
<field name="error_content_ids" readonly="1">
Expand Down
16 changes: 11 additions & 5 deletions runbot/views/build_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,12 @@
<field name="arch" type="xml">
<list string="Builds">
<field name="dest"/>
<field name="global_state"/>
<field name="global_state"
decoration-bg-danger="global_result == 'ko'"
decoration-bg-warning="global_result == 'warn'"
decoration-bg-success="global_result == 'ok' and global_state == 'done'"
decoration-bg-info="global_result == 'ok' and global_state != 'done'"
/>
<field name="global_result"/>
<field name="job"/>
<field name="host"/>
Expand All @@ -119,16 +124,17 @@
<field name="id"/>
<field name="global_state"/>
<field name="dest"/>
<field name="host" operator="="/>
<filter string="Pending" name='pending' domain="[('global_state','=', 'pending')]"/>
<filter string="Testing" name='testing' domain="[('global_state','in', ('testing', 'waiting'))]"/>
<filter string="Running" name='running' domain="[('global_state','=', 'running')]"/>
<filter string="Done" name='done' domain="[('global_state','=','done')]"/>
<filter string="Duplicate" name='duplicate' domain="[('local_state','=', 'duplicate')]"/>
<group expand="0" string="Group By...">
<filter string="Status" name='status' domain="[]" context="{'group_by':'global_state'}"/>
<filter string="Result" name='result' domain="[]" context="{'group_by':'global_result'}"/>
<filter string="Start" name='start' domain="[]" context="{'group_by':'job_start'}"/>
<filter string="Host" name='host' domain="[]" context="{'group_by':'host'}"/>
<filter string="Status" name='group_status' domain="[]" context="{'group_by':'global_state'}"/>
<filter string="Result" name='group_result' domain="[]" context="{'group_by':'global_result'}"/>
<filter string="Start" name='group_start' domain="[]" context="{'group_by':'job_start'}"/>
<filter string="Host" name='group_host' domain="[]" context="{'group_by':'host'}"/>
<filter string="Create Date" name='create_date' domain="[]" context="{'group_by':'create_date'}"/>
</group>
</search>
Expand Down
9 changes: 5 additions & 4 deletions runbot/views/host_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,10 @@
<field name="nb_run_slot"/>
<field name="last_exception" readonly='1'/>
<field name="exception_count" readonly='1'/>
<button type="object" name="action_list_all_builds">See all host builds</button>
</group>
<notebook>
<page string="Messages">
<field name="host_message_ids" readonly='1'/>
</page>
<page string="Builds">
<page string="Current Builds">
<field name="build_ids" widget="many2many" options="{'not_delete': True, 'no_create_edit': True}" readonly='1'>
<list string="Builds">
<field name="create_date"/>
Expand All @@ -37,6 +35,9 @@
</list>
</field>
</page>
<page string="Messages">
<field name="host_message_ids" readonly='1'/>
</page>
</notebook>
</sheet>
<chatter/>
Expand Down