mirror of
https://github.com/odoo/runbot.git
synced 2025-03-15 23:45:44 +07:00
[FIX] runbot: reduce the amount of github status
When commit is built serveral times, each time the status is updated, a request is sent to github for each build. As a side effect, if the first build is a failure and the last one a success, github is wrongly updated to failure. This bug is particulary annoying on PR in conjunction with the runbot_merge, preventing a the PR to be merged even after several rebuild. With this commit, only the latest build per repository is used to update the github status. The amount of github status updates is also reduced.
This commit is contained in:
parent
248d23c2d0
commit
4f1a55da9b
@ -722,27 +722,28 @@ class runbot_build(models.Model):
|
|||||||
"""Notify github of failed/successful builds"""
|
"""Notify github of failed/successful builds"""
|
||||||
runbot_domain = self.env['runbot.repo']._domain()
|
runbot_domain = self.env['runbot.repo']._domain()
|
||||||
for build in self:
|
for build in self:
|
||||||
b = build.duplicate_id if build.state == 'duplicate' else build
|
|
||||||
desc = "runbot build %s" % (build.dest,)
|
desc = "runbot build %s" % (build.dest,)
|
||||||
if b.state == 'testing':
|
if build.state == 'testing':
|
||||||
state = 'pending'
|
state = 'pending'
|
||||||
elif b.state in ('running', 'done'):
|
elif build.state in ('running', 'done'):
|
||||||
state = 'error'
|
state = 'error'
|
||||||
if b.result == 'ok':
|
if build.result == 'ok':
|
||||||
state = 'success'
|
state = 'success'
|
||||||
if b.result == 'ko':
|
if build.result == 'ko':
|
||||||
state = 'failure'
|
state = 'failure'
|
||||||
desc += " (runtime %ss)" % (b.job_time,)
|
desc += " (runtime %ss)" % (build.job_time,)
|
||||||
else:
|
else:
|
||||||
continue
|
continue
|
||||||
status = {
|
commits = {(b.repo_id, b.name) for b in self.search([('name', '=', build.name)])}
|
||||||
"state": state,
|
for repo, commit_hash in commits:
|
||||||
"target_url": "http://%s/runbot/build/%s" % (runbot_domain, build.id),
|
status = {
|
||||||
"description": desc,
|
"state": state,
|
||||||
"context": "ci/runbot"
|
"target_url": "http://%s/runbot/build/%s" % (runbot_domain, build.id),
|
||||||
}
|
"description": desc,
|
||||||
_logger.debug("github updating status %s to %s", build.name, state)
|
"context": "ci/runbot"
|
||||||
build.repo_id._github('/repos/:owner/:repo/statuses/%s' % build.name, status, ignore_errors=True)
|
}
|
||||||
|
_logger.debug("github updating status %s to %s", build.name, state)
|
||||||
|
repo._github('/repos/:owner/:repo/statuses/%s' % commit_hash, status, ignore_errors=True)
|
||||||
|
|
||||||
# Jobs definitions
|
# Jobs definitions
|
||||||
# They all need "build, lock_pathn log_path" parameters
|
# They all need "build, lock_pathn log_path" parameters
|
||||||
@ -837,9 +838,7 @@ class runbot_build(models.Model):
|
|||||||
else:
|
else:
|
||||||
v['result'] = "ko"
|
v['result'] = "ko"
|
||||||
build.write(v)
|
build.write(v)
|
||||||
# post statuses on duplicate too
|
build._github_status()
|
||||||
for b in self.search([('name', '=', build.name)]):
|
|
||||||
b._github_status()
|
|
||||||
# run server
|
# run server
|
||||||
cmd, mods = build._cmd()
|
cmd, mods = build._cmd()
|
||||||
if os.path.exists(build._server('addons/im_livechat')):
|
if os.path.exists(build._server('addons/im_livechat')):
|
||||||
|
Loading…
Reference in New Issue
Block a user