diff --git a/lintipy.py b/lintipy.py index 64c540e..c4c81c4 100644 --- a/lintipy.py +++ b/lintipy.py @@ -185,7 +185,12 @@ def __call__(self, event, context): version = self.get_cmd_version() code, log = self.run_process(code_path) - output = "```\n%s\n%s\n```" % (version, log) + if len(log) > 9000: + output = "```\n%s\n%s\nFull output truncated. Please run locally see full output.\n```" % ( + version, log[:9000] + ) + else: + output = "```\n%s\n%s\n```" % (version, log) if code == 0: self.update_check_run( diff --git a/tests/test_lintipy.py b/tests/test_lintipy.py index ae96f9b..7d8b285 100644 --- a/tests/test_lintipy.py +++ b/tests/test_lintipy.py @@ -8,7 +8,7 @@ import pytest from botocore.vendored import requests -from lintipy import CheckRun, TIMED_OUT +from lintipy import CheckRun, TIMED_OUT, FAILURE BASE_DIR = Path(os.path.dirname(__file__)) @@ -111,7 +111,7 @@ def test_timeout(self, handler, caplog): handler.download_code = lambda: '.' with pytest.raises(subprocess.TimeoutExpired) as e: handler(handler.event, {}) - assert "timed out after 1 seconds" in str(e) + assert "timed out after 1 seconds" in str(e.value) def test_installation_id(self, handler): assert handler.installation_id == 234 @@ -138,6 +138,29 @@ def update_check_run(status, summary, conclusion=None): assert data['conclusion'] == TIMED_OUT assert data['summary'] == 'Downloading code timed out after 1e-10s' + def test_summary_cut(self, handler): + httpretty.register_uri( + httpretty.PATCH, handler.check_run_url, + data='', + status=200, + content_type='application/json', + ) + + + data = {} + + def update_check_run(status, summary, conclusion=None): + data['status'] = status + data['summary'] = summary + data['conclusion'] = conclusion + + handler.update_check_run = update_check_run + handler.download_code = lambda: '.' + handler.run_process = lambda x: (1, str(list(range(9999)))) + handler(handler.event, {}) + assert data['conclusion'] == FAILURE + assert data['summary'][9889:] == '\nFull output truncated. Please run locally see full output.\n```' + def test_get_cmd_version(self, handler): handler.cmd = 'pytest' version_log = handler.get_cmd_version()