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
diff --git a/tests/fixtures/layouts/reporting-github.yaml b/tests/fixtures/layouts/reporting-github.yaml
index 0fdec85..ddb0588 100644
--- a/tests/fixtures/layouts/reporting-github.yaml
+++ b/tests/fixtures/layouts/reporting-github.yaml
@@ -35,6 +35,27 @@
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
manager: independent
@@ -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
diff --git a/tests/unit/test_github_driver.py b/tests/unit/test_github_driver.py
index 1ae36aa..0e199df 100644
--- a/tests/unit/test_github_driver.py
+++ b/tests/unit/test_github_driver.py
@@ -272,7 +272,8 @@
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 @@
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 @@
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))
@@ -330,6 +335,33 @@
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'
# pipeline reports pull status both on start and success
@@ -427,7 +459,7 @@
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 @@
(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],