From 8a1b3466a77fde4ef347e4d2e4aa7ed0d0d16c6b Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Tue, 27 Nov 2018 11:53:10 +0100 Subject: [PATCH] [IMP] runbot_merge: send integratin failure comment via feedback queue If a transient github failure makes the integration fail but also makes the following reset fail the entire staging process would be cancelled (and operations so far rollbacked) except for the failure comment which would be effected, as in odoo/odoo#26380. By pushing the comment to the feedback queue, if the reset fails the comment is rollbacked and "unqueued". --- runbot_merge/models/pull_requests.py | 6 +++++- runbot_merge/tests/test_basic.py | 2 ++ runbot_merge/tests/test_multirepo.py | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/runbot_merge/models/pull_requests.py b/runbot_merge/models/pull_requests.py index aa3cd5d1..8640901b 100644 --- a/runbot_merge/models/pull_requests.py +++ b/runbot_merge/models/pull_requests.py @@ -1313,7 +1313,11 @@ class Batch(models.Model): except (exceptions.MergeError, AssertionError) as e: _logger.exception("Failed to merge %s:%s into staging branch (error: %s)", pr.repository.name, pr.number, e) pr.state = 'error' - gh.comment(pr.number, "Unable to stage PR (%s)" % e) + self.env['runbot_merge.pull_requests.feedback'].create({ + 'repository': pr.repository.id, + 'pull_request': pr.number, + 'message': "Unable to stage PR (%s)" % e, + }) # reset the head which failed, as rebase() may have partially # updated it (despite later steps failing) diff --git a/runbot_merge/tests/test_basic.py b/runbot_merge/tests/test_basic.py index 2286e2a3..9e13574f 100644 --- a/runbot_merge/tests/test_basic.py +++ b/runbot_merge/tests/test_basic.py @@ -652,6 +652,8 @@ def test_rebase_failure(env, repo, users, remote_p): with mock.patch.object(GH, 'set_ref', autospec=True, side_effect=wrapper) as m: env['runbot_merge.project']._check_progress() + env['runbot_merge.project']._send_feedback() + assert pr_a.comments == [ (users['reviewer'], 'hansen r+'), (users['user'], re_matches(r'^Unable to stage PR')), diff --git a/runbot_merge/tests/test_multirepo.py b/runbot_merge/tests/test_multirepo.py index 4cb6bf90..42109e94 100644 --- a/runbot_merge/tests/test_multirepo.py +++ b/runbot_merge/tests/test_multirepo.py @@ -188,7 +188,7 @@ def test_merge_fail(env, project, repo_a, repo_b, users): pr2a = make_pr(repo_a, 'A2', [{'b': 'ok'}], label='do-b-thing') pr2b = make_pr(repo_b, 'B2', [{'b': 'ok'}], label='do-b-thing') - env['runbot_merge.project']._check_progress() + run_crons(env) s2 = to_pr(env, pr2a) | to_pr(env, pr2b) st = env['runbot_merge.stagings'].search([])