From 6e7d8d57f84a3396ff9862afdf00ec22f14d8209 Mon Sep 17 00:00:00 2001 From: Christophe Monniez Date: Sat, 19 Oct 2019 13:10:40 +0200 Subject: [PATCH] [IMP] runbot: add a multibuild wizard Creating multi builds configs can be tedious. One must create 2 build configs and 2 build config steps in the right order. With this commit, a simple wizard is added that creates those 4 configurations by simply filling 4 fields. Also, a new field, group, is added in order to be able to gather config's and config steps into groups. The group is a Many2one on a config. While at it, the runbot menu has been a bit rearranged with everything about config's in a parent menu named Configs. Config's and config's steps tree views have been enhanced to show the config group and add some filters in the search views. --- runbot/__init__.py | 1 + runbot/__manifest__.py | 3 +- runbot/models/build_config.py | 5 ++ runbot/views/config_views.xml | 78 +++++++++++++++++++-- runbot/wizards/__init__.py | 3 + runbot/wizards/multi_build_wizard.py | 71 +++++++++++++++++++ runbot/wizards/mutli_build_wizard_views.xml | 46 ++++++++++++ 7 files changed, 199 insertions(+), 8 deletions(-) create mode 100644 runbot/wizards/__init__.py create mode 100644 runbot/wizards/multi_build_wizard.py create mode 100644 runbot/wizards/mutli_build_wizard_views.xml diff --git a/runbot/__init__.py b/runbot/__init__.py index dabdb4e2..718604bc 100644 --- a/runbot/__init__.py +++ b/runbot/__init__.py @@ -4,3 +4,4 @@ from . import controllers from . import models from . import common from . import container +from . import wizards diff --git a/runbot/__manifest__.py b/runbot/__manifest__.py index 37f00984..1583afd0 100644 --- a/runbot/__manifest__.py +++ b/runbot/__manifest__.py @@ -6,7 +6,7 @@ 'author': "Odoo SA", 'website': "http://runbot.odoo.com", 'category': 'Website', - 'version': '4.5', + 'version': '4.6', 'depends': ['website', 'base'], 'data': [ 'security/runbot_security.xml', @@ -21,6 +21,7 @@ 'views/error_log_views.xml', 'views/config_views.xml', 'views/res_config_settings_views.xml', + 'wizards/mutli_build_wizard_views.xml', 'templates/frontend.xml', 'templates/build.xml', 'templates/assets.xml', diff --git a/runbot/models/build_config.py b/runbot/models/build_config.py index 2abbbda4..2dc4db27 100644 --- a/runbot/models/build_config.py +++ b/runbot/models/build_config.py @@ -28,6 +28,8 @@ class Config(models.Model): step_order_ids = fields.One2many('runbot.build.config.step.order', 'config_id') update_github_state = fields.Boolean('Notify build state to github', default=False, track_visibility='onchange') protected = fields.Boolean('Protected', default=False, track_visibility='onchange') + group = fields.Many2one('runbot.build.config', 'Configuration group', help="Group of config's and config steps") + group_name = fields.Char(related='group.name') @api.model def create(self, values): @@ -94,6 +96,9 @@ class ConfigStep(models.Model): ], default='install_odoo', required=True, track_visibility='onchange') protected = fields.Boolean('Protected', default=False, track_visibility='onchange') default_sequence = fields.Integer('Sequence', default=100, track_visibility='onchange') # or run after? # or in many2many rel? + step_order_ids = fields.One2many('runbot.build.config.step.order', 'step_id') + group = fields.Many2one('runbot.build.config', 'Configuration group', help="Group of config's and config steps") + group_name = fields.Char('Group name', related='group.name') # install_odoo create_db = fields.Boolean('Create Db', default=True, track_visibility='onchange') # future custom_db_name = fields.Char('Custom Db Name', track_visibility='onchange') # future diff --git a/runbot/views/config_views.xml b/runbot/views/config_views.xml index 95b75910..2a8adc17 100644 --- a/runbot/views/config_views.xml +++ b/runbot/views/config_views.xml @@ -8,7 +8,7 @@
This record is protected and can only be edited by config administrator. -
+ @@ -22,6 +22,7 @@ +
@@ -45,6 +46,7 @@ + @@ -76,6 +78,62 @@ + + Runbot Config tree view + runbot.build.config + + + + + + + + + + + Runbot Config Step tree view + runbot.build.config.step + + + + + + + + + + + runbot.build.config.filter + runbot.build.config + + + + + + + + + + + + runbot.build.config.step.filter + runbot.build.config.step + + + + + + + + + + + + + + + + Build Configs runbot.build.config @@ -88,20 +146,26 @@ tree,form - + + diff --git a/runbot/wizards/__init__.py b/runbot/wizards/__init__.py new file mode 100644 index 00000000..8b3f3120 --- /dev/null +++ b/runbot/wizards/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +from . import multi_build_wizard diff --git a/runbot/wizards/multi_build_wizard.py b/runbot/wizards/multi_build_wizard.py new file mode 100644 index 00000000..6b99bc3d --- /dev/null +++ b/runbot/wizards/multi_build_wizard.py @@ -0,0 +1,71 @@ +# -*- coding: utf-8 -*- + +from odoo import fields, models, api + + +class MultiBuildWizard(models.TransientModel): + + _name = 'runbot.build.config.multi.wizard' + + base_name = fields.Char('Generic name', required=True) + config_multi_name = fields.Char('Config name') + step_create_multi_name = fields.Char('Create multi step name') + config_single_name = fields.Char('Config only name') + config_single_extra_params = fields.Char('Extra cmd args') + config_single_test_tags = fields.Char('Test tags', default='') + config_single_test_enable = fields.Boolean('Enable tests', default=True) + step_single_name = fields.Char('Only step name') + number_builds = fields.Integer('Number of multi builds', default=10) + modules = fields.Char('Modules to install', default='') + + @api.onchange('base_name') + def _onchange_name(self): + if self.base_name: + name = '%s %s' % (self.env.user.login.split('@')[0], self.base_name.capitalize()) + step_name = name.replace(' ', '_').lower() + + self.config_multi_name = '%s Multi' % name + self.step_create_multi_name = '%s_create_multi' % step_name + self.config_single_name = '%s Single' % name + self.step_single_name = '%s_single' % step_name + + def generate(self): + if self.base_name: + # Create the "only" step and config + step_single = self.env['runbot.build.config.step'].create({ + 'name': self.step_single_name, + 'job_type': 'install_odoo', + 'test_tags': self.config_single_test_tags, + 'extra_params': self.config_single_extra_params, + 'test_enable': self.config_single_test_enable, + }) + config_single = self.env['runbot.build.config'].create({'name': self.config_single_name}) + + self.env['runbot.build.config.step.order'].create({ + 'sequence': 10, + 'config_id': config_single.id, + 'step_id': step_single.id + }) + + # Create the multiple builds step and config + step_create_multi = self.env['runbot.build.config.step'].create({ + 'name': self.step_create_multi_name, + 'job_type': 'create_build', + 'create_config_ids': [(4, config_single.id)], + 'number_builds': self.number_builds, + 'hide_build': True, + 'force_build': True + }) + + config_multi = self.env['runbot.build.config'].create({'name': self.config_multi_name}) + + config_multi.group = config_multi + step_create_multi.group = config_multi + config_single.group = config_multi + step_single.group = config_multi + + self.env['runbot.build.config.step.order'].create({ + 'sequence': 10, + 'config_id': config_multi.id, + 'step_id': step_create_multi.id + }) diff --git a/runbot/wizards/mutli_build_wizard_views.xml b/runbot/wizards/mutli_build_wizard_views.xml new file mode 100644 index 00000000..ea29be41 --- /dev/null +++ b/runbot/wizards/mutli_build_wizard_views.xml @@ -0,0 +1,46 @@ + + + + runbot_multi_build_wizard + runbot.build.config.multi.wizard + +
+ + + + + + + + + + + + +
+
+
+
+
+ + + Generate Multi Build Config + ir.actions.act_window + runbot.build.config.multi.wizard + form + form + + new + + + + +