From 7d1283492bb3e6124a7a9f40ad8558ae35cde9c1 Mon Sep 17 00:00:00 2001 From: Xavier-Do Date: Fri, 29 Nov 2019 17:08:40 +0100 Subject: [PATCH] [IMP] runbot: dynamic requirements --- requirements.txt | 1 + runbot/models/build.py | 15 ++++++++++----- runbot/tests/test_build.py | 15 +++++++++++++-- 3 files changed, 24 insertions(+), 7 deletions(-) create mode 100644 requirements.txt diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 00000000..17a870b4 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +matplotlib==3.0.2 \ No newline at end of file diff --git a/runbot/models/build.py b/runbot/models/build.py index 97dafdfb..69cb8bb5 100644 --- a/runbot/models/build.py +++ b/runbot/models/build.py @@ -691,7 +691,7 @@ class runbot_build(models.Model): def _get_available_modules(self, commit): for manifest_file_name in commit.repo.manifest_files.split(','): # '__manifest__.py' '__openerp__.py' - for addons_path in commit.repo.addons_paths.split(','): # '' 'addons' 'odoo/addons' + for addons_path in (commit.repo.addons_paths or '').split(','): # '' 'addons' 'odoo/addons' sep = os.path.join(addons_path, '*') for manifest_path in glob.glob(commit._source_path(sep, manifest_file_name)): module = os.path.basename(os.path.dirname(manifest_path)) @@ -866,7 +866,7 @@ class runbot_build(models.Model): def _get_addons_path(self, commits=None): for commit in (commits or self._get_all_commit()): source_path = self._docker_source_folder(commit) - for addons_path in commit.repo.addons_paths.split(','): + for addons_path in (commit.repo.addons_paths or '').split(','): if os.path.isdir(commit._source_path(addons_path)): yield os.path.join(source_path, addons_path).strip(os.sep) @@ -887,11 +887,16 @@ class runbot_build(models.Model): build = self python_params = python_params or [] py_version = py_version if py_version is not None else build._get_py_version() + pres = [] + for commit in self._get_all_commit(): + if os.path.isfile(commit._source_path('requirements.txt')): + repo_dir = self._docker_source_folder(commit) + requirement_path = os.path.join(repo_dir, 'requirements.txt') + pres.append(['sudo', 'pip%s' % py_version, 'install', '-r', '%s' % requirement_path]) + + addons_paths = self._get_addons_path() (server_commit, server_file) = self._get_server_info() server_dir = self._docker_source_folder(server_commit) - addons_paths = self._get_addons_path() - requirement_path = os.path.join(server_dir, 'requirements.txt') - pres = [['sudo', 'pip%s' % py_version, 'install', '-r', '%s' % requirement_path]] # commandline cmd = ['python%s' % py_version] + python_params + [os.path.join(server_dir, server_file), '--addons-path', ",".join(addons_paths)] diff --git a/runbot/tests/test_build.py b/runbot/tests/test_build.py index cf934aeb..bbeafb48 100644 --- a/runbot/tests/test_build.py +++ b/runbot/tests/test_build.py @@ -144,7 +144,13 @@ class Test_Build(common.TransactionCase): """ test that the server path and addons path """ def is_file(file): - self.assertIn('sources/bar/dfdfcfcf0000ffffffffffffffffffffffffffff/server.py', file) + self.assertIn(file, [ + '/tmp/runbot_test/static/sources/bar-ent/d0d0caca0000ffffffffffffffffffffffffffff/requirements.txt', + '/tmp/runbot_test/static/sources/bar/dfdfcfcf0000ffffffffffffffffffffffffffff/requirements.txt', + '/tmp/runbot_test/static/sources/bar/dfdfcfcf0000ffffffffffffffffffffffffffff/server.py' + ]) + if file == '/tmp/runbot_test/static/sources/bar-ent/d0d0caca0000ffffffffffffffffffffffffffff/requirements.txt': + return False return True def is_dir(file): @@ -196,7 +202,12 @@ class Test_Build(common.TransactionCase): """ test that the server path and addons path """ def is_file(file): - self.assertIn('sources/bar/dfdfcfcf0000ffffffffffffffffffffffffffff/server.py', file) + self.assertIn(file, [ + '/tmp/runbot_test/static/sources/bar/dfdfcfcf0000ffffffffffffffffffffffffffff/requirements.txt', + '/tmp/runbot_test/static/sources/bar/d0d0caca0000ffffffffffffffffffffffffffff/requirements.txt', + '/tmp/runbot_test/static/sources/bar/dfdfcfcf0000ffffffffffffffffffffffffffff/server.py']) + if file == '/tmp/runbot_test/static/sources/bar/dfdfcfcf0000ffffffffffffffffffffffffffff/requirements.txt': + return False return True mock_is_file.side_effect = is_file