From f7003fb96405c29525ebe1bde0be97f26e2f3a05 Mon Sep 17 00:00:00 2001 From: Christophe Monniez Date: Fri, 7 Feb 2025 16:18:06 +0100 Subject: [PATCH] [IMP] runbot: support environment variables in config data --- runbot/models/build_config.py | 2 ++ runbot/tests/test_build_config_step.py | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/runbot/models/build_config.py b/runbot/models/build_config.py index 6ea35a25..ead44db4 100644 --- a/runbot/models/build_config.py +++ b/runbot/models/build_config.py @@ -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(['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 [] + 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) def _upgrade_create_childs(self): diff --git a/runbot/tests/test_build_config_step.py b/runbot/tests/test_build_config_step.py index a5e29b01..8d961bfa 100644 --- a/runbot/tests/test_build_config_step.py +++ b/runbot/tests/test_build_config_step.py @@ -537,6 +537,20 @@ class TestBuildConfigStep(TestBuildConfigStepCommon): tags = self.get_test_tags(params) 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') def test_db_name(self, mock_checkout):