mirror of
https://github.com/odoo/runbot.git
synced 2025-03-16 07:55:45 +07:00
[IMP] runbot: choose the python version for coverage
When code coverage was processed the 'coverage' utility was called the same way regardless of the Odoo version. That was the cause of two problems: 1) In some OS packages, the 'coverage' executable was renamed to 'python-coverage' and 'python3-coverage' 2) Since version 11.0, Odoo needs python3 With this commit, the coverage module is called from python '-m' argument and the python version is chosen from the Odoo executable shebang. closes: #12
This commit is contained in:
parent
12542808a9
commit
efbce41e2e
@ -98,3 +98,14 @@ def local_pgadmin_cursor():
|
||||
finally:
|
||||
if cnx:
|
||||
cnx.close()
|
||||
|
||||
def get_py_version(build):
|
||||
"""return the python name to use from build instance"""
|
||||
executables = [ 'odoo-bin', 'openerp-server' ]
|
||||
for server_path in map(build._path, executables):
|
||||
if os.path.exists(server_path):
|
||||
with open(server_path, 'r') as f:
|
||||
if f.readline().strip().endswith('python3'):
|
||||
return 'python3'
|
||||
return 'python'
|
||||
|
||||
|
@ -10,7 +10,7 @@ import signal
|
||||
import subprocess
|
||||
import time
|
||||
from subprocess import CalledProcessError
|
||||
from ..common import dt2time, fqdn, now, locked, grep, time2str, rfind, uniq_list, local_pgadmin_cursor, lock
|
||||
from ..common import dt2time, fqdn, now, locked, grep, time2str, rfind, uniq_list, local_pgadmin_cursor, lock, get_py_version
|
||||
from odoo import models, fields, api
|
||||
from odoo.exceptions import UserError
|
||||
from odoo.http import request
|
||||
@ -748,6 +748,7 @@ class runbot_build(models.Model):
|
||||
cmd += ['-d', '%s-all' % build.dest, '-i', mods, '--stop-after-init', '--log-level=test', '--max-cron-threads=0']
|
||||
env = None
|
||||
if build.branch_id.coverage:
|
||||
pyversion = get_py_version(build)
|
||||
env = self._coverage_env(build)
|
||||
available_modules = [
|
||||
os.path.basename(os.path.dirname(a))
|
||||
@ -756,7 +757,7 @@ class runbot_build(models.Model):
|
||||
]
|
||||
bad_modules = set(available_modules) - set((mods or '').split(','))
|
||||
omit = ['--omit', ','.join(build._server('addons', m) for m in bad_modules)] if bad_modules else []
|
||||
cmd = ['coverage', 'run', '--branch', '--source', build._server()] + omit + cmd[:]
|
||||
cmd = [pyversion, '-m', 'coverage', 'run', '--branch', '--source', build._server()] + omit + cmd[:]
|
||||
# reset job_start to an accurate job_20 job_time
|
||||
build.write({'job_start': now()})
|
||||
return self._spawn(cmd, lock_path, log_path, cpu_limit=2100, env=env)
|
||||
@ -767,9 +768,10 @@ class runbot_build(models.Model):
|
||||
def _job_21_coverage(self, build, lock_path, log_path):
|
||||
if not build.branch_id.coverage:
|
||||
return -2
|
||||
pyversion = get_py_version(build)
|
||||
cov_path = build._path('coverage')
|
||||
os.makedirs(cov_path, exist_ok=True)
|
||||
cmd = ["coverage", "html", "-d", cov_path, "--ignore-errors"]
|
||||
cmd = [pyversion, "-m", "coverage", "html", "-d", cov_path, "--ignore-errors"]
|
||||
return self._spawn(cmd, lock_path, log_path, env=self._coverage_env(build))
|
||||
|
||||
def _job_30_run(self, build, lock_path, log_path):
|
||||
|
Loading…
Reference in New Issue
Block a user