| OLD | NEW |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 | 5 |
| 6 # Recipe for uploading nanobench results. | 6 # Recipe for uploading nanobench results. |
| 7 | 7 |
| 8 | 8 |
| 9 DEPS = [ | 9 DEPS = [ |
| 10 'build/file', | 10 'build/file', |
| 11 'recipe_engine/path', | 11 'recipe_engine/path', |
| 12 'recipe_engine/properties', | 12 'recipe_engine/properties', |
| 13 'recipe_engine/step', | 13 'recipe_engine/step', |
| 14 'recipe_engine/time', | 14 'recipe_engine/time', |
| 15 ] | 15 ] |
| 16 | 16 |
| 17 | 17 |
| 18 def RunSteps(api): | 18 def RunSteps(api): |
| 19 # Upload the nanobench resuls. | 19 # Upload the nanobench resuls. |
| 20 builder_name = api.properties['buildername'] | 20 builder_name = api.properties['buildername'] |
| 21 | 21 |
| 22 patch_storage = api.properties.get('patch_storage', 'rietveld') | |
| 23 issue = None | |
| 24 patchset = None | |
| 25 if builder_name.endswith('-Trybot'): | |
| 26 if patch_storage == 'gerrit': | |
| 27 issue = str(api.properties['event.change.number']) | |
| 28 patchset = str(api.properties['event.patchSet.ref'].split('/')[-1]) | |
| 29 else: | |
| 30 issue = str(api.properties['issue']) | |
| 31 patchset = str(api.properties['patchset']) | |
| 32 | |
| 33 now = api.time.utcnow() | 22 now = api.time.utcnow() |
| 34 | 23 |
| 35 src_path = api.path['cwd'].join( | 24 src_path = api.path['cwd'].join( |
| 36 'perfdata', builder_name, 'data') | 25 'perfdata', builder_name, 'data') |
| 37 results = api.file.glob( | 26 results = api.file.glob( |
| 38 'find results', | 27 'find results', |
| 39 'nanobench*.json', | 28 'nanobench*.json', |
| 40 cwd=src_path, | 29 cwd=src_path, |
| 41 test_data=['nanobench_abc123.json'], | 30 test_data=['nanobench_abc123.json'], |
| 42 infra_step=True) | 31 infra_step=True) |
| 43 if len(results) != 1: # pragma: nocover | 32 if len(results) != 1: # pragma: nocover |
| 44 raise Exception('Unable to find nanobench JSON file!') | 33 raise Exception('Unable to find nanobench JSON file!') |
| 45 | 34 |
| 46 src = src_path.join(results[0]) | 35 src = src_path.join(results[0]) |
| 47 basename = api.path.basename(src) | 36 basename = api.path.basename(src) |
| 48 gs_path = '/'.join(( | 37 gs_path = '/'.join(( |
| 49 'nano-json-v1', str(now.year).zfill(4), | 38 'nano-json-v1', str(now.year).zfill(4), |
| 50 str(now.month).zfill(2), str(now.day).zfill(2), str(now.hour).zfill(2), | 39 str(now.month).zfill(2), str(now.day).zfill(2), str(now.hour).zfill(2), |
| 51 builder_name)) | 40 builder_name)) |
| 52 | 41 |
| 53 if builder_name.endswith('-Trybot'): | 42 issue = str(api.properties.get('issue', '')) |
| 54 if not (issue and patchset): # pragma: nocover | 43 patchset = str(api.properties.get('patchset', '')) |
| 55 raise Exception('issue and patchset properties are required for trybots.') | 44 if (api.properties.get('patch_storage', '') == 'gerrit' and |
| 45 api.properties.get('nobuildbot', '') != 'True'): |
| 46 issue = str(api.properties['event.change.number']) |
| 47 patchset = str(api.properties['event.patchSet.ref']).split('/')[-1] |
| 48 if issue and patchset: |
| 56 gs_path = '/'.join(('trybot', gs_path, issue, patchset)) | 49 gs_path = '/'.join(('trybot', gs_path, issue, patchset)) |
| 57 | 50 |
| 58 dst = '/'.join(('gs://skia-perf', gs_path, basename)) | 51 dst = '/'.join(('gs://skia-perf', gs_path, basename)) |
| 59 | 52 |
| 60 api.step('upload', | 53 api.step('upload', |
| 61 cmd=['gsutil', 'cp', '-a', 'public-read', '-z', 'json', src, dst], | 54 cmd=['gsutil', 'cp', '-a', 'public-read', '-z', 'json', src, dst], |
| 62 infra_step=True) | 55 infra_step=True) |
| 63 | 56 |
| 64 | 57 |
| 65 def GenTests(api): | 58 def GenTests(api): |
| (...skipping 22 matching lines...) Expand all Loading... |
| 88 'event.change.number': '2100', | 81 'event.change.number': '2100', |
| 89 } | 82 } |
| 90 yield ( | 83 yield ( |
| 91 api.test('recipe_with_gerrit_patch') + | 84 api.test('recipe_with_gerrit_patch') + |
| 92 api.properties( | 85 api.properties( |
| 93 buildername=builder, | 86 buildername=builder, |
| 94 revision='abc123', | 87 revision='abc123', |
| 95 path_config='kitchen', | 88 path_config='kitchen', |
| 96 **gerrit_kwargs) | 89 **gerrit_kwargs) |
| 97 ) | 90 ) |
| OLD | NEW |