Commit 736e1af8 authored by Mohamed Heikal's avatar Mohamed Heikal Committed by Commit Bot

trybot_commit_size_checker.py now outputs metadata in json

trybot_commit_size_checker.py is used by the binary size trybot to do
the heavy lifting with regards to checking regressions. This cl adds
some extra metadata to the json output of the script that would allow a
gerrit plugin to display said metadata directly on the gerrit cl page.

Bug: 921090
Change-Id: I75486a3548931dae5a0bf5cd76c287023dc8da2d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1795633
Commit-Queue: Mohamed Heikal <mheikal@chromium.org>
Reviewed-by: default avatarAndrew Grieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/master@{#695781}
parent 362f8e0c
...@@ -21,6 +21,7 @@ import html_report ...@@ -21,6 +21,7 @@ import html_report
import models import models
_NDJSON_FILENAME = 'supersize_diff.ndjson' _NDJSON_FILENAME = 'supersize_diff.ndjson'
_TEXT_FILENAME = 'supersize_diff.txt'
_HTML_REPORT_BASE_URL = ( _HTML_REPORT_BASE_URL = (
'https://storage.googleapis.com/chrome-supersize/viewer.html?load_url=') 'https://storage.googleapis.com/chrome-supersize/viewer.html?load_url=')
_MAX_DEX_METHOD_COUNT_INCREASE = 50 _MAX_DEX_METHOD_COUNT_INCREASE = 50
...@@ -187,6 +188,9 @@ def main(): ...@@ -187,6 +188,9 @@ def main():
logging.info('Creating Supersize diff') logging.info('Creating Supersize diff')
supersize_diff_lines, delta_size_info = _CreateSupersizeDiff( supersize_diff_lines, delta_size_info = _CreateSupersizeDiff(
args.apk_name, args.before_dir, args.after_dir) args.apk_name, args.before_dir, args.after_dir)
supersize_text_path = os.path.join(args.staging_dir, _TEXT_FILENAME)
with open(supersize_text_path, 'w') as f:
describe.WriteLines(supersize_diff_lines, f.write)
changed_symbols = delta_size_info.raw_symbols.WhereDiffStatusIs( changed_symbols = delta_size_info.raw_symbols.WhereDiffStatusIs(
models.DIFF_STATUS_UNCHANGED).Inverted() models.DIFF_STATUS_UNCHANGED).Inverted()
...@@ -268,7 +272,7 @@ PASSING: ...@@ -268,7 +272,7 @@ PASSING:
}, },
{ {
'name': '>>> SuperSize Text Diff <<<', 'name': '>>> SuperSize Text Diff <<<',
'lines': supersize_diff_lines, 'url': '{{' + _TEXT_FILENAME + '}}',
}, },
{ {
'name': '>>> Supersize HTML Diff <<<', 'name': '>>> Supersize HTML Diff <<<',
...@@ -278,11 +282,39 @@ PASSING: ...@@ -278,11 +282,39 @@ PASSING:
# Remove empty diffs (Mutable Constants or Dex Method). # Remove empty diffs (Mutable Constants or Dex Method).
links_json = [o for o in links_json if o.get('lines') or o.get('url')] links_json = [o for o in links_json if o.get('lines') or o.get('url')]
binary_size_listings = []
for delta in size_deltas:
if delta.actual == 0:
continue
listing = {
'name': delta.name,
'delta': '{} {}'.format(delta.actual, delta.units),
'allowed': delta.IsAllowable(),
}
binary_size_listings.append(listing)
binary_size_extras = [
{
'text': 'Supersize HTML Diff',
'url': _HTML_REPORT_BASE_URL + '{{' + _NDJSON_FILENAME + '}}',
},
{
'text': 'SuperSize Text Diff',
'url': '{{' + _TEXT_FILENAME + '}}',
},
]
binary_size_plugin_json = {
'listings': binary_size_listings,
'extras': binary_size_extras,
}
results_json = { results_json = {
'status_code': status_code, 'status_code': status_code,
'summary': summary, 'summary': summary,
'archive_filenames': [_NDJSON_FILENAME], 'archive_filenames': [_NDJSON_FILENAME, _TEXT_FILENAME],
'links': links_json, 'links': links_json,
'gerrit_plugin_details': binary_size_plugin_json,
} }
with open(args.results_path, 'w') as f: with open(args.results_path, 'w') as f:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment