Simplify github status descriptions
Using the pipeline description as the status description seemed like a good idea at first, however some sites will make use of lengthy descriptions which can overflow GitHub's 1024 byte limit on the status description. To keep the description smaller, simplify by using a simple template of "{pipeline_name} status: {status}". This could still overflow if a site uses an unusually large name for a pipeline, so do some effort to prevent such an overflow. In testing, it seems anything over 140 characters seems to trip the size limit in GitHub, which doesn't make a lot of sense, but it's what we have to deal with. Change-Id: I5255f6cf307f54cd1366f6cb325ed66c1bc4bc27 Story: 2001138 Task: 4854
This commit is contained in:
parent
bb871ba814
commit
fb6cc99768
|
@ -34,6 +34,27 @@
|
|||
github:
|
||||
comment: false
|
||||
|
||||
- pipeline:
|
||||
name: this_is_a_really_stupid_long_name_for_a_pipeline_that_should_never_be_used_in_production_becuase_it_will_be_too_long_for_the_API_to_make_use_of_without_crashing
|
||||
description: Uncommon reporting
|
||||
manager: independent
|
||||
trigger:
|
||||
github:
|
||||
- event: pull_request
|
||||
action: comment
|
||||
comment: 'long pipeline'
|
||||
start:
|
||||
github:
|
||||
status: 'pending'
|
||||
success:
|
||||
github:
|
||||
comment: false
|
||||
status: 'success'
|
||||
status-url: http://logs.example.com/{tenant.name}/{pipeline.name}/{change.project}/{change.number}/{buildset.uuid}/
|
||||
failure:
|
||||
github:
|
||||
comment: false
|
||||
|
||||
- pipeline:
|
||||
name: push-reporting
|
||||
description: Uncommon reporting
|
||||
|
@ -68,6 +89,9 @@
|
|||
reporting:
|
||||
jobs:
|
||||
- project-test1
|
||||
this_is_a_really_stupid_long_name_for_a_pipeline_that_should_never_be_used_in_production_becuase_it_will_be_too_long_for_the_API_to_make_use_of_without_crashing:
|
||||
jobs:
|
||||
- project-test1
|
||||
|
||||
- project:
|
||||
name: org/project2
|
||||
|
|
|
@ -272,7 +272,8 @@ class TestGithubDriver(ZuulTestCase):
|
|||
check_url = ('http://zuul.example.com/status/#%s,%s' %
|
||||
(A.number, A.head_sha))
|
||||
self.assertEqual('tenant-one/check', check_status['context'])
|
||||
self.assertEqual('Standard check', check_status['description'])
|
||||
self.assertEqual('check status: pending',
|
||||
check_status['description'])
|
||||
self.assertEqual('pending', check_status['state'])
|
||||
self.assertEqual(check_url, check_status['url'])
|
||||
self.assertEqual(0, len(A.comments))
|
||||
|
@ -287,6 +288,8 @@ class TestGithubDriver(ZuulTestCase):
|
|||
check_url = ('http://zuul.example.com/status/#%s,%s' %
|
||||
(A.number, A.head_sha))
|
||||
self.assertEqual('tenant-one/check', check_status['context'])
|
||||
self.assertEqual('check status: success',
|
||||
check_status['description'])
|
||||
self.assertEqual('success', check_status['state'])
|
||||
self.assertEqual(check_url, check_status['url'])
|
||||
self.assertEqual(1, len(A.comments))
|
||||
|
@ -312,6 +315,8 @@ class TestGithubDriver(ZuulTestCase):
|
|||
self.assertEqual(3, len(statuses))
|
||||
report_status = statuses[0]
|
||||
self.assertEqual('tenant-one/reporting', report_status['context'])
|
||||
self.assertEqual('reporting status: success',
|
||||
report_status['description'])
|
||||
self.assertEqual('success', report_status['state'])
|
||||
self.assertEqual(2, len(A.comments))
|
||||
|
||||
|
@ -329,6 +334,33 @@ class TestGithubDriver(ZuulTestCase):
|
|||
self.assertThat(report_status['url'][len(base):],
|
||||
MatchesRegex('^[a-fA-F0-9]{32}\/$'))
|
||||
|
||||
@simple_layout('layouts/reporting-github.yaml', driver='github')
|
||||
def test_truncated_status_description(self):
|
||||
project = 'org/project'
|
||||
# pipeline reports pull status both on start and success
|
||||
self.executor_server.hold_jobs_in_build = True
|
||||
A = self.fake_github.openFakePullRequest(project, 'master', 'A')
|
||||
self.fake_github.emitEvent(
|
||||
A.getCommentAddedEvent('long pipeline'))
|
||||
self.waitUntilSettled()
|
||||
statuses = self.fake_github.statuses[project][A.head_sha]
|
||||
self.assertEqual(1, len(statuses))
|
||||
check_status = statuses[0]
|
||||
# Status is truncated due to long pipeline name
|
||||
self.assertEqual('status: pending',
|
||||
check_status['description'])
|
||||
|
||||
self.executor_server.hold_jobs_in_build = False
|
||||
self.executor_server.release()
|
||||
self.waitUntilSettled()
|
||||
# We should only have two statuses for the head sha
|
||||
statuses = self.fake_github.statuses[project][A.head_sha]
|
||||
self.assertEqual(2, len(statuses))
|
||||
check_status = statuses[0]
|
||||
# Status is truncated due to long pipeline name
|
||||
self.assertEqual('status: success',
|
||||
check_status['description'])
|
||||
|
||||
@simple_layout('layouts/reporting-github.yaml', driver='github')
|
||||
def test_push_reporting(self):
|
||||
project = 'org/project2'
|
||||
|
@ -427,7 +459,7 @@ class TestGithubDriver(ZuulTestCase):
|
|||
check_url = ('http://zuul.example.com/status/#%s,%s' %
|
||||
(A.number, A.head_sha))
|
||||
self.assertEqual('tenant-one/check', check_status['context'])
|
||||
self.assertEqual('Standard check', check_status['description'])
|
||||
self.assertEqual('check status: pending', check_status['description'])
|
||||
self.assertEqual('pending', check_status['state'])
|
||||
self.assertEqual(check_url, check_status['url'])
|
||||
self.assertEqual(0, len(A.comments))
|
||||
|
@ -443,6 +475,7 @@ class TestGithubDriver(ZuulTestCase):
|
|||
(A.number, A.head_sha))
|
||||
self.assertEqual('tenant-one/check', check_status['context'])
|
||||
self.assertEqual('success', check_status['state'])
|
||||
self.assertEqual('check status: success', check_status['description'])
|
||||
self.assertEqual(check_url, check_status['url'])
|
||||
self.assertEqual(1, len(A.comments))
|
||||
self.assertThat(A.comments[0],
|
||||
|
|
|
@ -101,9 +101,15 @@ class GithubReporter(BaseReporter):
|
|||
url_pattern = sched_config.get('webapp', 'status_url')
|
||||
url = item.formatUrlPattern(url_pattern) if url_pattern else ''
|
||||
|
||||
description = ''
|
||||
if item.pipeline.description:
|
||||
description = item.pipeline.description
|
||||
description = '%s status: %s' % (item.pipeline.name,
|
||||
self._commit_status)
|
||||
|
||||
if len(description) >= 140:
|
||||
# This pipeline is named with a long name and thus this
|
||||
# desciption would overflow the GitHub limit of 1024 bytes.
|
||||
# Truncate the description. In practice, anything over 140
|
||||
# characters seems to trip the limit.
|
||||
description = 'status: %s' % self._commit_status
|
||||
|
||||
self.log.debug(
|
||||
'Reporting change %s, params %s, status:\n'
|
||||
|
|
Loading…
Reference in New Issue