[FIX] runbot: update github status on duplicates too

Actually, when a build is a duplicate of another build, its github status is not updated.
e.g. a pull request may not have a github status but its corresponding
branch have a gtihub status.
With this commit, all builds will have their github status updated based
on the corresponding build status.

Thanks for your help @xmo-odoo 

closes: #3
This commit is contained in:
Christophe Monniez 2018-04-27 13:39:33 +02:00 committed by GitHub
parent d7f727a0d0
commit 9555370fa6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -88,6 +88,8 @@ class runbot_build(models.Model):
if duplicate_id and not context.get('force_rebuild'):
extra_info.update({'state': 'duplicate', 'duplicate_id': duplicate_id})
build_id.write(extra_info)
if build_id.state == 'duplicate' and build_id.duplicate_id.state in ('running', 'done'):
build_id._github_status()
return build_id
def _reset(self):
@ -699,16 +701,17 @@ class runbot_build(models.Model):
"""Notify github of failed/successful builds"""
runbot_domain = self.env['runbot.repo']._domain()
for build in self:
b = build.duplicate_id if build.state == 'duplicate' else build
desc = "runbot build %s" % (build.dest,)
if build.state == 'testing':
if b.state == 'testing':
state = 'pending'
elif build.state in ('running', 'done'):
elif b.state in ('running', 'done'):
state = 'error'
if build.result == 'ok':
if b.result == 'ok':
state = 'success'
if build.result == 'ko':
if b.result == 'ko':
state = 'failure'
desc += " (runtime %ss)" % (build.job_time,)
desc += " (runtime %ss)" % (b.job_time,)
else:
continue
status = {
@ -792,8 +795,9 @@ class runbot_build(models.Model):
else:
v['result'] = "ko"
build.write(v)
build._github_status()
# post statuses on duplicate too
for b in self.search([('name', '=', build.name)]):
b._github_status()
# run server
cmd, mods = build._cmd()
if os.path.exists(build._server('addons/im_livechat')):