mirror of
https://github.com/odoo/runbot.git
synced 2025-03-27 05:15:45 +07:00
[FIX] runbot: various fixes (data improvement, python step, logs, ...)
This commit is contained in:
parent
8a7e0b20aa
commit
427639b77a
@ -54,7 +54,7 @@
|
|||||||
<record id="runbot_build_config_step_test_coverage" model="runbot.build.config.step">
|
<record id="runbot_build_config_step_test_coverage" model="runbot.build.config.step">
|
||||||
<field name="name">coverage</field>
|
<field name="name">coverage</field>
|
||||||
<field name="install_modules">*</field>
|
<field name="install_modules">*</field>
|
||||||
<field name="cpu_limit">5400</field>
|
<field name="cpu_limit">7000</field>
|
||||||
<field name="test_enable" eval="True"/>
|
<field name="test_enable" eval="True"/>
|
||||||
<field name="coverage" eval="True"/>
|
<field name="coverage" eval="True"/>
|
||||||
<field name="protected" eval="True"/>
|
<field name="protected" eval="True"/>
|
||||||
@ -74,6 +74,7 @@
|
|||||||
<field name="create_config_ids" eval="[(4, ref('runbot_build_config_light_test'))]"/>
|
<field name="create_config_ids" eval="[(4, ref('runbot_build_config_light_test'))]"/>
|
||||||
<field name="number_builds">10</field>
|
<field name="number_builds">10</field>
|
||||||
<field name="protected" eval="True"/>
|
<field name="protected" eval="True"/>
|
||||||
|
<field name="force_build" eval="True"/>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record id="runbot_build_config_multibuild" model="runbot.build.config">
|
<record id="runbot_build_config_multibuild" model="runbot.build.config">
|
||||||
|
@ -121,7 +121,7 @@ class runbot_build(models.Model):
|
|||||||
else:
|
else:
|
||||||
record.global_state = record.local_state
|
record.global_state = record.local_state
|
||||||
|
|
||||||
def _get_youngest_state(self, states, max=False):
|
def _get_youngest_state(self, states):
|
||||||
index = min([self._get_state_score(state) for state in states])
|
index = min([self._get_state_score(state) for state in states])
|
||||||
return state_order[index]
|
return state_order[index]
|
||||||
|
|
||||||
@ -288,10 +288,12 @@ class runbot_build(models.Model):
|
|||||||
|
|
||||||
def _end_test(self):
|
def _end_test(self):
|
||||||
for build in self:
|
for build in self:
|
||||||
if build.parent_id:
|
if build.parent_id and build.global_state in ('running', 'done'):
|
||||||
global_result = build.global_result
|
global_result = build.global_result
|
||||||
loglevel = 'OK' if global_result == 'ok' else 'WARNING' if global_result == 'warn' else 'ERROR'
|
loglevel = 'OK' if global_result == 'ok' else 'WARNING' if global_result == 'warn' else 'ERROR'
|
||||||
build.parent_id._log('children_build', 'returned a "%s" result ' % (global_result), level=loglevel, log_type='subbuild', path=self.id)
|
build.parent_id._log('children_build', 'returned a "%s" result ' % (global_result), level=loglevel, log_type='subbuild', path=self.id)
|
||||||
|
if build.parent_id.local_state in ('running', 'done'):
|
||||||
|
build.parent_id._end_test()
|
||||||
|
|
||||||
@api.depends('name', 'branch_id.name')
|
@api.depends('name', 'branch_id.name')
|
||||||
def _compute_dest(self):
|
def _compute_dest(self):
|
||||||
@ -499,19 +501,19 @@ class runbot_build(models.Model):
|
|||||||
values.update(build._next_job_values())
|
values.update(build._next_job_values())
|
||||||
build.write(values)
|
build.write(values)
|
||||||
if not build.active_step:
|
if not build.active_step:
|
||||||
build._log('schedule', 'No job in config, doing nothing')
|
build._log('_schedule', 'No job in config, doing nothing')
|
||||||
build._end_test()
|
#build._end_test()
|
||||||
continue
|
continue
|
||||||
try:
|
try:
|
||||||
build._log('init', 'Init build environment with config %s ' % build.config_id.name)
|
build._log('_schedule', 'Init build environment with config %s ' % build.config_id.name)
|
||||||
# notify pending build - avoid confusing users by saying nothing
|
# notify pending build - avoid confusing users by saying nothing
|
||||||
build._github_status()
|
build._github_status()
|
||||||
build._checkout()
|
build._checkout()
|
||||||
build._log('docker_build', 'Building docker image')
|
build._log('_schedule', 'Building docker image')
|
||||||
docker_build(build._path('logs', 'docker_build.txt'), build._path())
|
docker_build(build._path('logs', 'docker_build.txt'), build._path())
|
||||||
except Exception:
|
except Exception:
|
||||||
_logger.exception('Failed initiating build %s', build.dest)
|
_logger.exception('Failed initiating build %s', build.dest)
|
||||||
build._log('Failed initiating build')
|
build._log('_schedule', 'Failed initiating build')
|
||||||
build._kill(result='ko')
|
build._kill(result='ko')
|
||||||
continue
|
continue
|
||||||
else: # testing/running build
|
else: # testing/running build
|
||||||
@ -524,7 +526,7 @@ class runbot_build(models.Model):
|
|||||||
if docker_is_running(build._get_docker_name()):
|
if docker_is_running(build._get_docker_name()):
|
||||||
timeout = min(build.active_step.cpu_limit, int(icp.get_param('runbot.runbot_timeout', default=10000)))
|
timeout = min(build.active_step.cpu_limit, int(icp.get_param('runbot.runbot_timeout', default=10000)))
|
||||||
if build.local_state != 'running' and build.job_time > timeout:
|
if build.local_state != 'running' and build.job_time > timeout:
|
||||||
build._logger('%s time exceded (%ss)', build.active_step.name if build.active_step else "?", build.job_time)
|
build._log('_schedule', '%s time exceeded (%ss)', build.active_step.name if build.active_step else "?", build.job_time)
|
||||||
build.write({'job_end': now()})
|
build.write({'job_end': now()})
|
||||||
build._kill(result='killed')
|
build._kill(result='killed')
|
||||||
continue
|
continue
|
||||||
@ -554,7 +556,7 @@ class runbot_build(models.Model):
|
|||||||
|
|
||||||
if ending_build:
|
if ending_build:
|
||||||
build._github_status()
|
build._github_status()
|
||||||
build._end_test() # notify parent of build end
|
# build._end_test()
|
||||||
if not build.local_result: # Set 'ok' result if no result set (no tests job on build)
|
if not build.local_result: # Set 'ok' result if no result set (no tests job on build)
|
||||||
build.local_result = 'ok'
|
build.local_result = 'ok'
|
||||||
build._logger("No result set, setting ok by default")
|
build._logger("No result set, setting ok by default")
|
||||||
|
@ -15,6 +15,7 @@ _logger = logging.getLogger(__name__)
|
|||||||
_re_error = r'^(?:\d{4}-\d\d-\d\d \d\d:\d\d:\d\d,\d{3} \d+ (?:ERROR|CRITICAL) )|(?:Traceback \(most recent call last\):)$'
|
_re_error = r'^(?:\d{4}-\d\d-\d\d \d\d:\d\d:\d\d,\d{3} \d+ (?:ERROR|CRITICAL) )|(?:Traceback \(most recent call last\):)$'
|
||||||
_re_warning = r'^\d{4}-\d\d-\d\d \d\d:\d\d:\d\d,\d{3} \d+ WARNING '
|
_re_warning = r'^\d{4}-\d\d-\d\d \d\d:\d\d:\d\d,\d{3} \d+ WARNING '
|
||||||
|
|
||||||
|
PYTHON_DEFAULT = "# type python code here\n\n\n\n\n\n"
|
||||||
|
|
||||||
class Config(models.Model):
|
class Config(models.Model):
|
||||||
_name = "runbot.build.config"
|
_name = "runbot.build.config"
|
||||||
@ -94,7 +95,7 @@ class ConfigStep(models.Model):
|
|||||||
# install_odoo
|
# install_odoo
|
||||||
create_db = fields.Boolean('Create Db', default=True, tracking=True) # future
|
create_db = fields.Boolean('Create Db', default=True, tracking=True) # future
|
||||||
custom_db_name = fields.Char('Custom Db Name', tracking=True) # future
|
custom_db_name = fields.Char('Custom Db Name', tracking=True) # future
|
||||||
install_modules = fields.Char('Modules to install', help="List of module to install, use * for all modules")
|
install_modules = fields.Char('Modules to install', help="List of module to install, use * for all modules", default='*')
|
||||||
db_name = fields.Char('Db Name', compute='_compute_db_name', inverse='_inverse_db_name', tracking=True)
|
db_name = fields.Char('Db Name', compute='_compute_db_name', inverse='_inverse_db_name', tracking=True)
|
||||||
cpu_limit = fields.Integer('Cpu limit', default=3600, tracking=True)
|
cpu_limit = fields.Integer('Cpu limit', default=3600, tracking=True)
|
||||||
coverage = fields.Boolean('Coverage', dafault=False, tracking=True)
|
coverage = fields.Boolean('Coverage', dafault=False, tracking=True)
|
||||||
@ -102,7 +103,7 @@ class ConfigStep(models.Model):
|
|||||||
test_tags = fields.Char('Test tags', help="comma separated list of test tags")
|
test_tags = fields.Char('Test tags', help="comma separated list of test tags")
|
||||||
extra_params = fields.Char('Extra cmd args', tracking=True)
|
extra_params = fields.Char('Extra cmd args', tracking=True)
|
||||||
# python
|
# python
|
||||||
python_code = fields.Text('Python code', tracking=True, default="# type python code here\n\n\n\n\n\n")
|
python_code = fields.Text('Python code', tracking=True, default=PYTHON_DEFAULT)
|
||||||
running_job = fields.Boolean('Job final state is running', default=False, help="Docker won't be killed if checked")
|
running_job = fields.Boolean('Job final state is running', default=False, help="Docker won't be killed if checked")
|
||||||
# create_build
|
# create_build
|
||||||
create_config_ids = fields.Many2many('runbot.build.config', 'runbot_build_config_step_ids_create_config_ids_rel', string='New Build Configs', tracking=True, index=True)
|
create_config_ids = fields.Many2many('runbot.build.config', 'runbot_build_config_step_ids_create_config_ids_rel', string='New Build Configs', tracking=True, index=True)
|
||||||
@ -153,7 +154,7 @@ class ConfigStep(models.Model):
|
|||||||
if not re.match(name_reg, values.get('name')):
|
if not re.match(name_reg, values.get('name')):
|
||||||
raise UserError('Name cannot contain special char or spaces exepts "_" and "-"')
|
raise UserError('Name cannot contain special char or spaces exepts "_" and "-"')
|
||||||
if not self.env.user.has_group('runbot.group_build_config_administrator'):
|
if not self.env.user.has_group('runbot.group_build_config_administrator'):
|
||||||
if (values.get('job_type') == 'python' or ('python_code' in values and values['python_code'] and values['python_code'] != "# type python code here\n\n\n\n\n\n")):
|
if (values.get('job_type') == 'python' or ('python_code' in values and values['python_code'] and values['python_code'] != PYTHON_DEFAULT)):
|
||||||
raise UserError('cannot create or edit config step of type python code')
|
raise UserError('cannot create or edit config step of type python code')
|
||||||
if (values.get('extra_params')):
|
if (values.get('extra_params')):
|
||||||
reg = r'^[a-zA-Z0-9\-_ "]*$'
|
reg = r'^[a-zA-Z0-9\-_ "]*$'
|
||||||
|
@ -281,7 +281,9 @@ class runbot_repo(models.Model):
|
|||||||
ref_branches = {}
|
ref_branches = {}
|
||||||
for repo in self:
|
for repo in self:
|
||||||
try:
|
try:
|
||||||
refs[repo] = repo._get_refs()
|
ref = repo._get_refs()
|
||||||
|
if ref:
|
||||||
|
refs[repo] = ref
|
||||||
except Exception:
|
except Exception:
|
||||||
_logger.exception('Fail to get refs for repo %s', repo.name)
|
_logger.exception('Fail to get refs for repo %s', repo.name)
|
||||||
if repo in refs:
|
if repo in refs:
|
||||||
|
@ -86,7 +86,7 @@
|
|||||||
<field name="name">All config step can be edited by config admin</field>
|
<field name="name">All config step can be edited by config admin</field>
|
||||||
<field name="groups" eval="[(4, ref('group_build_config_administrator'))]"/>
|
<field name="groups" eval="[(4, ref('group_build_config_administrator'))]"/>
|
||||||
<field name="model_id" ref="model_runbot_build_config_step"/>
|
<field name="model_id" ref="model_runbot_build_config_step"/>
|
||||||
<field name="domain_force">[('1', '=', '1')]</field>
|
<field name="domain_force">[(1, '=', 1)]</field>
|
||||||
<field name="perm_read" eval="False"/>
|
<field name="perm_read" eval="False"/>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
@ -39,7 +39,8 @@ class Test_Repo(common.TransactionCase):
|
|||||||
self.assertEqual(local_repo.short_name, 'somewhere/rep')
|
self.assertEqual(local_repo.short_name, 'somewhere/rep')
|
||||||
|
|
||||||
@patch('odoo.addons.runbot.models.repo.runbot_repo._root')
|
@patch('odoo.addons.runbot.models.repo.runbot_repo._root')
|
||||||
def test_repo_create_pending_builds(self, mock_root):
|
@patch('odoo.addons.runbot.models.repo.runbot_repo._get_fetch_head_time')
|
||||||
|
def test_repo_create_pending_builds(self, mock_fetch_head_time, mock_root):
|
||||||
""" Test that when finding new refs in a repo, the missing branches
|
""" Test that when finding new refs in a repo, the missing branches
|
||||||
are created and new builds are created in pending state
|
are created and new builds are created in pending state
|
||||||
"""
|
"""
|
||||||
@ -61,6 +62,7 @@ class Test_Repo(common.TransactionCase):
|
|||||||
'A nice subject',
|
'A nice subject',
|
||||||
'Marc Bidule',
|
'Marc Bidule',
|
||||||
'<marc.bidule@somewhere.com>')]
|
'<marc.bidule@somewhere.com>')]
|
||||||
|
mock_fetch_head_time.side_effect = [100000.0, 100001.0, 100002.0]
|
||||||
|
|
||||||
with patch('odoo.addons.runbot.models.repo.runbot_repo._git', new=self.mock_git_helper()):
|
with patch('odoo.addons.runbot.models.repo.runbot_repo._git', new=self.mock_git_helper()):
|
||||||
repo._create_pending_builds()
|
repo._create_pending_builds()
|
||||||
|
Loading…
Reference in New Issue
Block a user