diff --git a/forwardport/tests/test_simple.py b/forwardport/tests/test_simple.py index f5e6de14..e09053b0 100644 --- a/forwardport/tests/test_simple.py +++ b/forwardport/tests/test_simple.py @@ -261,6 +261,9 @@ More info at https://github.com/odoo/odoo/wiki/Mergebot#forward-port with prod: prod.post_status(pr1.head, st, ctx) env.run_crons() + with prod: # should be ignored because the description doesn't matter + prod.post_status(pr1.head, 'failure', 'ci/runbot', description="HAHAHAHAHA") + env.run_crons() # check that FP did not resume & we have a ping on the PR assert env['runbot_merge.pull_requests'].search([], order='number') == pr0 | pr1,\ "forward port should not continue on CI failure" diff --git a/runbot_merge/controllers/__init__.py b/runbot_merge/controllers/__init__.py index 05e34870..d17c12b5 100644 --- a/runbot_merge/controllers/__init__.py +++ b/runbot_merge/controllers/__init__.py @@ -207,7 +207,7 @@ def handle_pr(env, event): def handle_status(env, event): _logger.info( - 'status %(context)s:%(state)s on commit %(sha)s (%(target_url)s)', + 'status on %(sha)s %(context)s:%(state)s (%(target_url)s) [%(description)r]', event ) Commits = env['runbot_merge.commit'] diff --git a/runbot_merge/models/pull_requests.py b/runbot_merge/models/pull_requests.py index 66f6d635..316882d1 100644 --- a/runbot_merge/models/pull_requests.py +++ b/runbot_merge/models/pull_requests.py @@ -879,10 +879,19 @@ class PullRequests(models.Model): # only sending notification if the newly failed status is different than # the old one prev = json.loads(self.previous_failure) - if st != prev: + if not self._statuses_equivalent(st, prev): self.previous_failure = json.dumps(st) self._notify_ci_failed(ci) + def _statuses_equivalent(self, a, b): + """ Check if two statuses are *equivalent* meaning the description field + is ignored (check only state and target_url). This is because the + description seems to vary even if the rest does not, and generates + unnecessary notififcations as a result + """ + return a.get('state') == b.get('state') \ + and a.get('target_url') == b.get('target_url') + def _notify_ci_failed(self, ci): # only report an issue of the PR is already approved (r+'d) if self.state == 'approved':