diff --git a/runbot/models/build.py b/runbot/models/build.py
index f3da3304..26d73a23 100644
--- a/runbot/models/build.py
+++ b/runbot/models/build.py
@@ -965,7 +965,7 @@ class runbot_build(models.Model):
_logger.error('None of %s found in commit, actual commit content:\n %s' % (commit.repo.server_files, os.listdir(commit._source_path())))
raise RunbotException('No server found in %s' % commit)
- def _cmd(self, python_params=None, py_version=None, local_only=True):
+ def _cmd(self, python_params=None, py_version=None, local_only=True, sub_command=None):
"""Return a list describing the command to start the build
"""
self.ensure_one()
@@ -984,7 +984,10 @@ class runbot_build(models.Model):
server_dir = self._docker_source_folder(server_commit)
# commandline
- cmd = ['python%s' % py_version] + python_params + [os.path.join(server_dir, server_file), '--addons-path', ",".join(addons_paths)]
+ cmd = ['python%s' % py_version] + python_params + [os.path.join(server_dir, server_file)]
+ if sub_command:
+ cmd += [sub_command]
+ cmd += ['--addons-path', ",".join(addons_paths)]
# options
config_path = build._server("tools/config.py")
if grep(config_path, "no-xmlrpcs"): # move that to configs ?
diff --git a/runbot/models/build_config.py b/runbot/models/build_config.py
index 11df9b23..c6fdb4a5 100644
--- a/runbot/models/build_config.py
+++ b/runbot/models/build_config.py
@@ -113,6 +113,7 @@ class ConfigStep(models.Model):
test_enable = fields.Boolean('Test enable', default=True, track_visibility='onchange')
test_tags = fields.Char('Test tags', help="comma separated list of test tags", track_visibility='onchange')
enable_auto_tags = fields.Boolean('Allow auto tag', default=False, track_visibility='onchange')
+ sub_command = fields.Char('Subcommand', track_visibility='onchange')
extra_params = fields.Char('Extra cmd args', track_visibility='onchange')
additionnal_env = fields.Char('Extra env', help='Example: foo="bar",bar="foo". Cannot contains \' ', track_visibility='onchange')
# python
@@ -149,6 +150,13 @@ class ConfigStep(models.Model):
else:
self.force_build = False
+ @api.onchange('sub_command')
+ def _onchange_number_builds(self):
+ if self.sub_command:
+ self.install_modules = '-*'
+ self.test_enable = False
+ self.create_db = False
+
@api.depends('name', 'custom_db_name')
def _compute_db_name(self):
for step in self:
@@ -334,7 +342,7 @@ class ConfigStep(models.Model):
python_params = ['-m', 'coverage', 'run', '--branch', '--source', '/data/build'] + coverage_extra_params
elif self.flamegraph:
python_params = ['-m', 'flamegraph', '-o', self._perfs_data_path()]
- cmd = build._cmd(python_params, py_version)
+ cmd = build._cmd(python_params, py_version, sub_command=self.sub_command)
# create db if needed
db_suffix = build.config_data.get('db_name') or self.db_name
db_name = "%s-%s" % (build.dest, db_suffix)
diff --git a/runbot/tests/test_build_config_step.py b/runbot/tests/test_build_config_step.py
index 5f511730..ad71d7a8 100644
--- a/runbot/tests/test_build_config_step.py
+++ b/runbot/tests/test_build_config_step.py
@@ -185,6 +185,27 @@ class TestBuildConfigStep(RunbotCase):
self.assertEqual(call_count, 3)
+
+ @patch('odoo.addons.runbot.models.build.runbot_build._checkout')
+ def test_sub_command(self, mock_checkout):
+ config_step = self.ConfigStep.create({
+ 'name': 'default',
+ 'job_type': 'install_odoo',
+ 'sub_command': 'subcommand',
+ })
+ call_count = 0
+ def docker_run(cmd, log_path, *args, **kwargs):
+ nonlocal call_count
+ sub_command = cmd.cmd[cmd.index('bar/server.py')+1]
+ self.assertEqual(sub_command, 'subcommand')
+ call_count += 1
+
+ self.patchers['docker_run'].side_effect = docker_run
+ config_step._run_odoo_install(self.parent_build, 'dev/null/logpath')
+
+ self.assertEqual(call_count, 1)
+
+
class TestMakeResult(RunbotCase):
def setUp(self):
diff --git a/runbot/views/config_views.xml b/runbot/views/config_views.xml
index 75b39b92..994fb93e 100644
--- a/runbot/views/config_views.xml
+++ b/runbot/views/config_views.xml
@@ -64,7 +64,8 @@
-
+
+