[IMP] runbot: manual host

This commit is contained in:
Xavier-Do 2020-09-11 15:00:54 +02:00 committed by XavierDo
parent 45721cdf6c
commit 675e2f1688
3 changed files with 45 additions and 0 deletions

View File

@ -115,6 +115,9 @@ class Batch(models.Model):
'build_type': 'normal' if self.category_id == self.env.ref('runbot.default_category') else 'scheduled',
'no_auto_run': self.bundle_id.no_auto_run,
})
if self.bundle_id.host_id:
build.host = self.bundle_id.host_id.name
build._github_status(post_commit=False)
return link_type, build

View File

@ -45,6 +45,25 @@ class Bundle(models.Model):
trigger_custom_ids = fields.One2many('runbot.bundle.trigger.custom', 'bundle_id')
auto_rebase = fields.Boolean('Auto rebase', default=False)
host_id = fields.Many2one('runbot.host', compute="_compute_host_id", store=True)
@api.depends('name')
def _compute_host_id(self):
assigned_only = None
runbots = {}
for bundle in self:
elems = bundle.name.split('-')
for elem in elems:
if elem.startswith('runbot'):
if elem.replace('runbot', '') == '_x':
if assigned_only is None:
assigned_only = self.env['runbot.host'].search([('assigned_only', '=', True)], limit=1)
bundle.host_id = assigned_only or False
elif elem.replace('runbot', '').isdigit():
if elem not in runbots:
runbots[elem] = self.env['runbot.host'].search([('name', 'like', '%s%%' % elem)], limit=1)
bundle.host_id = runbots[elem] or False
@api.depends('sticky')
def _compute_make_stats(self):
for bundle in self:

View File

@ -169,6 +169,29 @@ class TestBranchIsBase(RunbotCaseMinimalSetup):
self.assertTrue(branch.bundle_id.is_base, "A branch matching the is_base_regex parameter should create is_base bundle")
self.assertTrue(branch.bundle_id.sticky, "A branch matching the is_base_regex parameter should create sticky bundle")
def test_host(self):
r10 = self.env['runbot.host'].create({'name': 'runbot10.odoo.com'})
r12 = self.env['runbot.host'].create({'name': 'runbot12.odoo.com', 'assigned_only': True})
branch = self.Branch.create({
'remote_id': self.remote_server.id,
'name': 'saas-13.4-runbotinexist-test',
'is_pr': False,
})
self.assertFalse(branch.bundle_id.host_id)
branch = self.Branch.create({
'remote_id': self.remote_server.id,
'name': 'saas-13.4-runbot10-test',
'is_pr': False,
})
self.assertEqual(branch.bundle_id.host_id, r10)
branch = self.Branch.create({
'remote_id': self.remote_server.id,
'name': 'saas-13.4-runbot_x-test',
'is_pr': False,
})
self.assertEqual(branch.bundle_id.host_id, r12)
@mute_logger("odoo.addons.runbot.models.branch")
def test_is_base_regex_on_dev_remote(self):
"""Test that a branch matching the is_base regex on a secondary remote goes to the dummy bundles."""