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 DM results. | 6 # Recipe for uploading DM results. |
7 | 7 |
8 | 8 |
9 DEPS = [ | 9 DEPS = [ |
10 'build/file', | 10 'build/file', |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 break | 42 break |
43 except api.step.StepFailure: | 43 except api.step.StepFailure: |
44 if i == UPLOAD_ATTEMPTS - 1: | 44 if i == UPLOAD_ATTEMPTS - 1: |
45 raise | 45 raise |
46 | 46 |
47 | 47 |
48 def RunSteps(api): | 48 def RunSteps(api): |
49 builder_name = api.properties['buildername'] | 49 builder_name = api.properties['buildername'] |
50 revision = api.properties['revision'] | 50 revision = api.properties['revision'] |
51 | 51 |
52 patch_storage = api.properties.get('patch_storage', 'rietveld') | |
53 issue = None | |
54 patchset = None | |
55 if builder_name.endswith('-Trybot'): | |
56 if patch_storage == 'gerrit': | |
57 issue = str(api.properties['event.change.number']) | |
58 patchset = str(api.properties['event.patchSet.ref'].split('/')[-1]) | |
59 else: | |
60 issue = str(api.properties['issue']) | |
61 patchset = str(api.properties['patchset']) | |
62 | |
63 results_dir = api.path['cwd'].join('dm') | 52 results_dir = api.path['cwd'].join('dm') |
64 | 53 |
65 # Move dm.json and verbose.log to their own directory. | 54 # Move dm.json and verbose.log to their own directory. |
66 json_file = results_dir.join(DM_JSON) | 55 json_file = results_dir.join(DM_JSON) |
67 log_file = results_dir.join(VERBOSE_LOG) | 56 log_file = results_dir.join(VERBOSE_LOG) |
68 tmp_dir = api.path['cwd'].join('tmp_upload') | 57 tmp_dir = api.path['cwd'].join('tmp_upload') |
69 api.shutil.makedirs('tmp dir', tmp_dir, infra_step=True) | 58 api.shutil.makedirs('tmp dir', tmp_dir, infra_step=True) |
70 api.shutil.copy('copy dm.json', json_file, tmp_dir) | 59 api.shutil.copy('copy dm.json', json_file, tmp_dir) |
71 api.shutil.copy('copy verbose.log', log_file, tmp_dir) | 60 api.shutil.copy('copy verbose.log', log_file, tmp_dir) |
72 api.shutil.remove('rm old dm.json', json_file) | 61 api.shutil.remove('rm old dm.json', json_file) |
(...skipping 15 matching lines...) Expand all Loading... |
88 'dm-json-v1', | 77 'dm-json-v1', |
89 str(now.year ).zfill(4), | 78 str(now.year ).zfill(4), |
90 str(now.month).zfill(2), | 79 str(now.month).zfill(2), |
91 str(now.day ).zfill(2), | 80 str(now.day ).zfill(2), |
92 str(now.hour ).zfill(2), | 81 str(now.hour ).zfill(2), |
93 revision, | 82 revision, |
94 builder_name, | 83 builder_name, |
95 str(int(calendar.timegm(now.utctimetuple())))]) | 84 str(int(calendar.timegm(now.utctimetuple())))]) |
96 | 85 |
97 # Trybot results are further siloed by issue/patchset. | 86 # Trybot results are further siloed by issue/patchset. |
98 if builder_name.endswith('-Trybot'): | 87 issue = str(api.properties.get('issue', '')) |
99 if not (issue and patchset): # pragma: nocover | 88 patchset = str(api.properties.get('patchset', '')) |
100 raise Exception('issue and patchset properties are required for trybots.') | 89 if (api.properties.get('patch_storage', '') == 'gerrit' and |
101 summary_dest_path = '/'.join(('trybot', summary_dest_path, issue, patchset)) | 90 api.properties.get('nobuildbot', '') != 'True'): |
| 91 issue = str(api.properties['event.change.number']) |
| 92 patchset = str(api.properties['event.patchSet.ref']).split('/')[-1] |
| 93 if issue and patchset: |
| 94 summary_dest_path = '/'.join(( |
| 95 'trybot', summary_dest_path, issue, patchset)) |
102 | 96 |
103 summary_dest_path = '/'.join((GS_BUCKET, summary_dest_path)) | 97 summary_dest_path = '/'.join((GS_BUCKET, summary_dest_path)) |
104 | 98 |
105 cp(api, 'JSON and logs', tmp_dir.join('*'), summary_dest_path, | 99 cp(api, 'JSON and logs', tmp_dir.join('*'), summary_dest_path, |
106 ['-z', 'json,log']) | 100 ['-z', 'json,log']) |
107 | 101 |
108 | 102 |
109 def GenTests(api): | 103 def GenTests(api): |
110 builder = 'Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug' | 104 builder = 'Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug' |
111 yield ( | 105 yield ( |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 'event.change.number': '2100', | 146 'event.change.number': '2100', |
153 } | 147 } |
154 yield ( | 148 yield ( |
155 api.test('recipe_with_gerrit_patch') + | 149 api.test('recipe_with_gerrit_patch') + |
156 api.properties( | 150 api.properties( |
157 buildername=builder, | 151 buildername=builder, |
158 revision='abc123', | 152 revision='abc123', |
159 path_config='kitchen', | 153 path_config='kitchen', |
160 **gerrit_kwargs) | 154 **gerrit_kwargs) |
161 ) | 155 ) |
OLD | NEW |