Report robot comments to gerrit
If there are line comments, we are supposed to always report them. However, when we added support for robot comments, we didn't update the check which determined whether to post a review. We do that if at least one of the following is true: there is a message, there is a label, there is a line comment. That should also be true if there is a robot comment (since that is a form of line comment). This updates that check and adds a test. Change-Id: Iebd6dafd9e040b6c443ebe1ed1e2702d37804399
This commit is contained in:
parent
d48be299ab
commit
d1b95639b9
|
@ -381,6 +381,46 @@ class TestChecksApi(ZuulTestCase):
|
|||
self.assertEqual(len(A.checks_history), 3)
|
||||
self.assertEqual(A.data['status'], 'NEW')
|
||||
|
||||
@simple_layout('layouts/gerrit-checks.yaml')
|
||||
def test_config_error(self):
|
||||
# Test that line comments are reported on config errors
|
||||
in_repo_conf = textwrap.dedent(
|
||||
"""
|
||||
- project:
|
||||
check:
|
||||
jobs:
|
||||
- bad-job
|
||||
""")
|
||||
file_dict = {'.zuul.yaml': in_repo_conf}
|
||||
A = self.fake_gerrit.addFakeChange('org/project', 'master', 'A',
|
||||
files=file_dict)
|
||||
A.setCheck('zuul:check', reset=True)
|
||||
self.waitForPoll('gerrit')
|
||||
self.waitUntilSettled()
|
||||
|
||||
self.assertEqual(A.checks_history[0]['zuul:check']['state'],
|
||||
'NOT_STARTED')
|
||||
self.assertEqual(A.checks_history[1]['zuul:check']['state'],
|
||||
'SCHEDULED')
|
||||
self.assertEqual(A.checks_history[2]['zuul:check']['state'],
|
||||
'FAILED')
|
||||
self.assertEqual(len(A.checks_history), 3)
|
||||
comments = sorted(A.comments, key=lambda x: x['line'])
|
||||
self.assertEqual(comments[0],
|
||||
{'file': '.zuul.yaml',
|
||||
'line': 5,
|
||||
'message': 'Job bad-job not defined',
|
||||
'range': {'end_character': 0,
|
||||
'end_line': 5,
|
||||
'start_character': 2,
|
||||
'start_line': 2},
|
||||
'reviewer': {'email': 'zuul@example.com',
|
||||
'name': 'Zuul',
|
||||
'username': 'jenkins'}}
|
||||
)
|
||||
self.assertEqual(A.reported, 0, "no messages should be reported")
|
||||
self.assertEqual(A.messages, [], "no messages should be reported")
|
||||
|
||||
|
||||
class TestPolling(ZuulTestCase):
|
||||
config_file = 'zuul-gerrit-no-stream.conf'
|
||||
|
|
|
@ -1100,7 +1100,8 @@ class GerritConnection(BaseConnection):
|
|||
change.id)
|
||||
if checks_api:
|
||||
self.report_checks(log, item, changeid, checks_api)
|
||||
if (message or data.get('labels') or data.get('comments')):
|
||||
if (message or data.get('labels') or data.get('comments')
|
||||
or data.get('robot_comments')):
|
||||
for x in range(1, 4):
|
||||
try:
|
||||
self.post('changes/%s/revisions/%s/review' %
|
||||
|
|
Loading…
Reference in New Issue