mirror of
https://github.com/odoo/runbot.git
synced 2025-03-15 23:45:44 +07:00
[FIX] runbot_merge: point to the right status on staging failure
On staging failure, the 'bot would point to the first error or failure status it found on the commit. This turns out not to be correct as we (now) have various statuses which are optional, and may fail without blocking stagings (either because they're solely informational or because they're blocking & overridable on PRs). Fix this so the 'bot points to the first *required* failure. Fixes #517
This commit is contained in:
parent
678d2216b8
commit
bef6a8e2d0
@ -1847,12 +1847,18 @@ class Stagings(models.Model):
|
||||
if repo.endswith('^'):
|
||||
continue
|
||||
|
||||
commit = self.env['runbot_merge.commit'].search([
|
||||
('sha', '=', head)
|
||||
])
|
||||
required_statuses = set(
|
||||
self.env['runbot_merge.repository']
|
||||
.search([('name', '=', repo)])
|
||||
.status_ids
|
||||
._for_staging(self)
|
||||
.mapped('context'))
|
||||
|
||||
commit = self.env['runbot_merge.commit'].search([('sha', '=', head)])
|
||||
statuses = json.loads(commit.statuses or '{}')
|
||||
reason = next((
|
||||
ctx for ctx, result in statuses.items()
|
||||
if ctx in required_statuses
|
||||
if to_status(result).get('state') in ('error', 'failure')
|
||||
), None)
|
||||
if not reason:
|
||||
|
@ -560,6 +560,7 @@ def test_staging_ci_failure_single(env, repo, users, config):
|
||||
|
||||
staging_head = repo.commit('heads/staging.master')
|
||||
with repo:
|
||||
repo.post_status(staging_head.id, 'failure', 'a/b')
|
||||
repo.post_status(staging_head.id, 'success', 'legal/cla')
|
||||
repo.post_status(staging_head.id, 'failure', 'ci/runbot') # stable genius
|
||||
env.run_crons()
|
||||
|
Loading…
Reference in New Issue
Block a user