mirror of
https://github.com/odoo/runbot.git
synced 2025-03-15 15:35:46 +07:00
[IMP] runbot: automatic error management
Add an action to post the message for exceptions automatically as well as rebuilding the templates.
This commit is contained in:
parent
92e5b6c4e5
commit
6d9bdeaaa4
@ -1,5 +1,5 @@
|
||||
import re
|
||||
from odoo import models, fields
|
||||
from odoo import models, fields, api
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
|
||||
@ -11,10 +11,25 @@ class UpgradeExceptions(models.Model):
|
||||
active = fields.Boolean('Active', default=True, tracking=True)
|
||||
elements = fields.Text('Elements', required=True)
|
||||
bundle_id = fields.Many2one('runbot.bundle', index=True)
|
||||
create_build_id = fields.Many2one('runbot.build', 'Build')
|
||||
pr_ids = fields.Many2many('runbot.branch', string='Pull requests', default=lambda self: self.default_pr_ids())
|
||||
info = fields.Text('Info')
|
||||
team_id = fields.Many2one('runbot.team', 'Assigned team', index=True)
|
||||
message = fields.Text('Upgrade exception message', compute="_compute_message")
|
||||
message = fields.Text('Upgrade exception message', compute="_compute_message", store=True)
|
||||
|
||||
def action_post_message(self):
|
||||
if not self.env.user.has_group('runbot.group_runbot_admin'):
|
||||
raise UserError('You are not allowed to send messages')
|
||||
for pr in self.pr_ids:
|
||||
pr.remote_id._github('/repos/:owner/:repo/issues/%s/comments' % pr.name, {'body': self.message})
|
||||
|
||||
def action_auto_rebuild(self):
|
||||
builds = self.create_build_id.parent_id.children_ids if self.create_build_id.parent_id else self.create_build_id
|
||||
for build in builds:
|
||||
if not build.orphan_result and build.local_result == 'ko':
|
||||
build._rebuild()
|
||||
|
||||
@api.depends('create_date')
|
||||
def _compute_message(self):
|
||||
message_layout = self.env['ir.config_parameter'].sudo().get_param('runbot.runbot_upgrade_exception_message')
|
||||
for exception in self:
|
||||
@ -25,6 +40,11 @@ class UpgradeExceptions(models.Model):
|
||||
if exceptions:
|
||||
return 'suppress_upgrade_warnings=%s' % (','.join(exceptions.mapped('elements'))).replace(' ', '').replace('\n', ',')
|
||||
return False
|
||||
|
||||
def default_pr_ids(self):
|
||||
bundle_id = self.env.context.get('default_bundle_id')
|
||||
if bundle_id:
|
||||
return self.env['runbot.branch'].search([('bundle_id', '=', bundle_id), ('is_pr', '=', True), ('alive', '=', True)])
|
||||
|
||||
|
||||
class UpgradeRegex(models.Model):
|
||||
@ -63,6 +83,7 @@ class BuildResult(models.Model):
|
||||
'context': {
|
||||
'default_elements': '\n'.join(exception),
|
||||
'default_bundle_id': bundle,
|
||||
'default_create_build_id': self.id,
|
||||
'default_info': 'Automatically generated from build %s' % self.id
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,6 @@
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
<record id="upgrade_exception_form" model="ir.ui.view">
|
||||
<field name="name">runbot.upgrade.exception</field>
|
||||
<field name="model">runbot.upgrade.exception</field>
|
||||
@ -36,12 +35,20 @@
|
||||
<group>
|
||||
<field name="active"/>
|
||||
<field name="bundle_id" widget="frontend_url"/>
|
||||
<field name="pr_ids">
|
||||
<list>
|
||||
<field name="branch_url" widget="url"/>
|
||||
<field name="alive"/>
|
||||
</list>
|
||||
</field>
|
||||
<field name="elements"/>
|
||||
<field name="info"/>
|
||||
<field name="create_date"/>
|
||||
<field name="create_uid"/>
|
||||
<field name="team_id"/>
|
||||
<field name="message"/>
|
||||
<field name="message" readonly="0"/>
|
||||
<button name="action_post_message" string="Post message on all pull requests" type="object" invisible="not create_date"/>
|
||||
<button name="action_auto_rebuild" string="rebuild templates" type="object" invisible="not create_date"/>
|
||||
</group>
|
||||
</sheet>
|
||||
<chatter/>
|
||||
|
Loading…
Reference in New Issue
Block a user