[IMP] runbot: support environment variables in config data

This commit is contained in:
Christophe Monniez 2025-02-07 16:18:06 +01:00 committed by xdo
parent 344792a191
commit f7003fb964
2 changed files with 16 additions and 0 deletions

View File

@ -509,6 +509,8 @@ class ConfigStep(models.Model):
cmd.finals.append(['flamegraph.pl', '--title', 'Flamegraph %s for build %s' % (self.name, build.id), self._perfs_data_path(), '>', self._perfs_data_path(ext='svg')]) cmd.finals.append(['flamegraph.pl', '--title', 'Flamegraph %s for build %s' % (self.name, build.id), self._perfs_data_path(), '>', self._perfs_data_path(ext='svg')])
cmd.finals.append(['gzip', '-f', self._perfs_data_path()]) # keep data but gz them to save disc space cmd.finals.append(['gzip', '-f', self._perfs_data_path()]) # keep data but gz them to save disc space
env_variables = self.additionnal_env.split(';') if self.additionnal_env else [] env_variables = self.additionnal_env.split(';') if self.additionnal_env else []
if config_env_variables := build.params_id.config_data.get('env_variables', False):
env_variables += config_env_variables.split(';')
return dict(cmd=cmd, ro_volumes=exports, env_variables=env_variables) return dict(cmd=cmd, ro_volumes=exports, env_variables=env_variables)
def _upgrade_create_childs(self): def _upgrade_create_childs(self):

View File

@ -537,6 +537,20 @@ class TestBuildConfigStep(TestBuildConfigStepCommon):
tags = self.get_test_tags(params) tags = self.get_test_tags(params)
self.assertEqual(tags, '-at_install,/module1,/module2,-:otherclass.othertest') self.assertEqual(tags, '-at_install,/module1,/module2,-:otherclass.othertest')
@patch('odoo.addons.runbot.models.build.BuildResult._parse_config')
@patch('odoo.addons.runbot.models.build.BuildResult._checkout')
def test_install_custom_env_variables(self, mock_checkout, parse_config):
parse_config.return_value = {'--test-enable', '--test-tags'}
config_step = self.ConfigStep.create({
'name': 'all',
'job_type': 'install_odoo'
})
child = self.parent_build._add_child({'config_data': {'env_variables': 'CHROME_CPU_THROTTLE=10'}})
params = config_step._run_install_odoo(child)
env_variables = params.get('env_variables', [])
self.assertEqual(env_variables, ['CHROME_CPU_THROTTLE=10'])
@patch('odoo.addons.runbot.models.build.BuildResult._checkout') @patch('odoo.addons.runbot.models.build.BuildResult._checkout')
def test_db_name(self, mock_checkout): def test_db_name(self, mock_checkout):