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: use a wizard to test filters #854

Open
wants to merge 1 commit into
base: 17.0
Choose a base branch
from
Open
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
54 changes: 48 additions & 6 deletions runbot/models/repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,24 +141,66 @@ def _filter_patterns(patterns_list, default, all):
return sorted(modules_to_install)

def action_test_modules_filters(self):
output = markupsafe.Markup()
sticky_bundles = self.env['runbot.bundle'].search([('project_id', '=', self.project_id.id), ('sticky', '=', True)])
sticky_bundles = sticky_bundles.sorted(lambda b: b.version_id.number, reverse=True)
for sticky_bundle in sticky_bundles:
commits = sticky_bundle.last_batch.commit_ids
#if not commits:
# continue
output += markupsafe.Markup(f'''<h2>%s</h2>''') % sticky_bundle.name
error_messages = []
module_ids = self.env['runbot.odoo.module']
for commit in commits:
if commit.repo_id in (self.repo_ids + self.dependency_ids).sorted('id'):
try:
module_list = [module for _addons_path, module, _manifest in commit._list_available_modules()]
filtered_modules = self._filter_modules_to_test({commit.repo_id: module_list})
output += markupsafe.Markup(f'''<h4>%s (%s/%s)</h4>''') % (commit.repo_id.name, len(filtered_modules), len(module_list))
output += ','.join(filtered_modules)
module_ids |= self.env['runbot.odoo.module'].create([{'name': m, 'repo_id': commit.repo_id.id} for m in filtered_modules])
except subprocess.CalledProcessError as e:
output += markupsafe.Markup(f'''<h4>{commit.repo_id.name}</h4> Failed to get modules for {commit.repo_id.name}:{commit.name} {e}''')
self.message_post(body=output)
error_messages.append(f'{commit.repo_id.name}: Failed to get modules for {commit.repo_id.name}:{commit.name} "{e}"')

wizard = self.env['runbot.modules.wizard'].create({
'module_ids':module_ids,
'error_messages': ''.join(error_messages),
})

return {
'name': 'Modules',
'type': 'ir.actions.act_window',
'view_mode': 'form',
'res_model': 'runbot.modules.wizard',
'res_id': wizard.id,
'target': 'new',
}

class OdooModule(models.TransientModel):
"""For use by the ModuleListWizard"""
_name = 'runbot.odoo.module'
_description = "module to use in filter wizard"
_order = "repo_id, name"

name = fields.Char('Module Name')
repo_id = fields.Many2one('runbot.repo')


class ModuleListWizard(models.TransientModel):
"""Conveniant Wizard just to display result of Trigger Module Filters"""
_name = 'runbot.modules.wizard'
_description = "Trigger modules filter wizard"

module_ids = fields.Many2many('runbot.odoo.module', readonly=True)
filtered_module_ids = fields.Many2many('runbot.odoo.module', compute="_compute_filtered_modules", readonly=True)
filtered_module_list = fields.Text('Module list', compute="_compute_filtered_modules", readonly=True)
error_messages = fields.Text('Error Messages', readonly=True)
search_pattern = fields.Char('Search term')

@api.depends('search_pattern')
def _compute_filtered_modules(self):
for wizard in self:
if wizard.search_pattern:
wizard.filtered_module_ids = wizard.module_ids.filtered_domain([('name', 'ilike', self.search_pattern)])
else:
wizard.filtered_module_ids = wizard.module_ids
wizard.filtered_module_list = ','.join(wizard.filtered_module_ids.mapped('name'))


class Remote(models.Model):
Expand Down
4 changes: 4 additions & 0 deletions runbot/security/ir.model.access.csv
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,7 @@ access_runbot_trigger_custom_wizard,access_runbot_trigger_custom_wizard,model_ru
access_runbot_build_stat_regex_wizard,access_runbot_build_stat_regex_wizard,model_runbot_build_stat_regex_wizard,runbot.group_runbot_admin,1,1,1,1

access_runbot_host_message,access_runbot_host_message,runbot.model_runbot_host_message,runbot.group_runbot_admin,1,0,0,0

access_runbot_modules_wizard,access_runbot_modules_wizard,model_runbot_modules_wizard,runbot.group_runbot_admin,1,1,1,1
access_runbot_odoo_module,access_runbot_odoo_module,model_runbot_odoo_module,runbot.group_runbot_admin,1,1,1,1

124 changes: 88 additions & 36 deletions runbot/views/repo_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,44 +26,57 @@
<field name="version_domain" widget="domain" options="{'model': 'runbot.version', 'in_dialog': True}"/>
</group>
</group>
<group>
<group string="Repositories">
<field name="repo_ids" nolabel="1" colspan="2"/>
</group>
<group string="Dependencies">
<field name="dependency_ids" nolabel="1" colspan="2"/>
</group>
<group string="Module filters">
<field name="module_filters" nolabel="1" colspan="4">
<tree string="Module filters" editable="bottom">
<field name="repo_id" domain="['|', ('id', 'in', parent.repo_ids), ('id', 'in', parent.dependency_ids)]"/>
<field name="modules"/>
<field name="description"/>
<notebook>
<page name="repo_dep" string="Repositories and Dependencies">
<group>
<group string="Repositories">
<field name="repo_ids" nolabel="1" colspan="2"/>
</group>
<group string="Dependencies">
<field name="dependency_ids" nolabel="1" colspan="2"/>
</group>
</group>
</page>
<page name="module_filters" string="Module Filters">
<group>
<group name="module_filters">
<field name="module_filters" nolabel="1" colspan="4">
<tree string="Module filters" editable="bottom">
<field name="repo_id" domain="['|', ('id', 'in', parent.repo_ids), ('id', 'in', parent.dependency_ids)]"/>
<field name="modules"/>
<field name="description"/>
</tree>
</field>
</group>
</group>
<button class="btn btn-sm btn-info" style="width: 100%;" type="object" name="action_test_modules_filters" title="Test filters">Test Filters</button>
</page>
</notebook>
<notebook>
<page name="other" string="Other infos">
<group>
<group>
<field name="hide"/>
<field name="manual"/>
<field name="restore_trigger_id"/>
</group>
<group>
<field name="ci_context"/>
<field name="ci_url"/>
<field name="ci_description"/>
</group>
</group>
</page>
<page name="teams" string="Teams">
<field name="team_ids">
<tree>
<field name="name"/>
<field name="github_team"/>
<field name="user_ids" widget="many2many_tags"/>
</tree>
</field>
</group>
<button class="btn btn-sm btn-primary" type="object" name="action_test_modules_filters" title="Test filters">List modules</button>
</group>
<group>
<group>
<field name="hide"/>
<field name="manual"/>
<field name="restore_trigger_id"/>
</group>
<group>
<field name="ci_context"/>
<field name="ci_url"/>
<field name="ci_description"/>
</group>
</group>
<group string="Managing Team (nightly failure, manual start, ...)"></group>
<field name="team_ids">
<tree>
<field name="name"/>
<field name="github_team"/>
<field name="user_ids" widget="many2many_tags"/>
</tree>
</field>
</page>
</notebook>
</sheet>
<div class="oe_chatter">
<field name="message_follower_ids"/>
Expand All @@ -90,6 +103,45 @@
</field>
</record>

<record id="odoo_module_view_tree" model="ir.ui.view">
<field name="name">runbot.odoo.module.tree</field>
<field name="model">runbot.odoo.module</field>
<field name="arch" type="xml">
<tree string="Repositories">
<field name="repo_id"/>
<field name="name"/>
</tree>
</field>
</record>

<record model="ir.ui.view" id="runbot_modules_wizard_form">
<field name="name">runbot_modules_wizard</field>
<field name="model">runbot.modules.wizard</field>
<field name="arch" type="xml">
<form string="Module Filter Test Wizard">
<div class="alert alert-danger" role="alert" invisible="not error_messages">
<field name="error_messages"/>
</div>
<field name="search_pattern" string="Filter" placeholder="filter module list"/>
<notebook>
<page name="modules" string="Modules">
<group>
<field name="filtered_module_ids"/>
</group>
</page>
<page name="module_list" string="Comma Separated">
<group>
<field name="filtered_module_list"/>
</group>
</page>
</notebook>
<footer>
<button string="Close" special="cancel" class="btn-default"/>
</footer>
</form>
</field>
</record>

<record id="repo_trigger_catgory_form" model="ir.ui.view">
<field name="name">runbot.category.form</field>
<field name="model">runbot.category</field>
Expand Down