OLD | NEW |
(Empty) | |
| 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 |
| 3 # found in the LICENSE file. |
| 4 |
| 5 |
| 6 # Recipe for uploading DM results. |
| 7 |
| 8 |
| 9 DEPS = [ |
| 10 'build/file', |
| 11 'recipe_engine/json', |
| 12 'recipe_engine/path', |
| 13 'recipe_engine/properties', |
| 14 'recipe_engine/shutil', |
| 15 'recipe_engine/step', |
| 16 'recipe_engine/time', |
| 17 ] |
| 18 |
| 19 |
| 20 import time |
| 21 |
| 22 |
| 23 DM_JSON = 'dm.json' |
| 24 GS_BUCKET = 'gs://skia-infra-gm' |
| 25 VERBOSE_LOG = 'verbose.log' |
| 26 |
| 27 |
| 28 def RunSteps(api): |
| 29 builder_name = api.properties['buildername'] |
| 30 revision = api.properties['revision'] |
| 31 issue = str(api.properties.get('issue', '')) |
| 32 patchset = str(api.properties.get('patchset', '')) |
| 33 |
| 34 results_dir = api.path['cwd'].join('dm') |
| 35 |
| 36 # Validate the JSON file. |
| 37 json_file = results_dir.join(DM_JSON) |
| 38 api.json.read('validate dm.json', json_file) |
| 39 |
| 40 # Move dm.json and verbose.log to their own directory. |
| 41 log_file = results_dir.join(VERBOSE_LOG) |
| 42 tmp_dir = api.path['cwd'].join('tmp_upload') |
| 43 api.shutil.makedirs('tmp dir', tmp_dir, infra_step=True) |
| 44 api.shutil.copy('copy dm.json', json_file, tmp_dir) |
| 45 api.shutil.copy('copy verbose.log', log_file, tmp_dir) |
| 46 api.shutil.remove('rm old dm.json', json_file) |
| 47 api.shutil.remove('rm old verbose.log', log_file) |
| 48 |
| 49 # Upload the images. |
| 50 image_dest_path = '/'.join((GS_BUCKET, 'dm-images-v1')) |
| 51 files_to_upload = api.file.glob( |
| 52 'find images', |
| 53 results_dir.join('*'), |
| 54 test_data=['someimage.png'], |
| 55 infra_step=True) |
| 56 if len(files_to_upload) > 0: |
| 57 api.step( |
| 58 'upload images', |
| 59 cmd=['gsutil', 'cp', results_dir.join('*'), image_dest_path], |
| 60 ) |
| 61 |
| 62 # Upload the JSON summary and verbose.log. |
| 63 now = api.time.utcnow() |
| 64 summary_dest_path = '/'.join([ |
| 65 'dm-json-v1', |
| 66 str(now.year ).zfill(4), |
| 67 str(now.month).zfill(2), |
| 68 str(now.day ).zfill(2), |
| 69 str(now.hour ).zfill(2), |
| 70 revision, |
| 71 builder_name, |
| 72 str(int(time.mktime(now.utctimetuple())))]) |
| 73 |
| 74 # Trybot results are further siloed by issue/patchset. |
| 75 if builder_name.endswith('-Trybot'): |
| 76 if not (issue and patchset): # pragma: nocover |
| 77 raise Exception('issue and patchset properties are required for trybots.') |
| 78 summary_dest_path = '/'.join(('trybot', summary_dest_path, issue, patchset)) |
| 79 |
| 80 summary_dest_path = '/'.join((GS_BUCKET, summary_dest_path)) |
| 81 |
| 82 api.step( |
| 83 'upload JSON and logs', |
| 84 cmd=['gsutil', 'cp', '-z', 'json,log', tmp_dir.join('*'), |
| 85 summary_dest_path], |
| 86 ) |
| 87 |
| 88 |
| 89 def GenTests(api): |
| 90 builder = 'Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug' |
| 91 yield ( |
| 92 api.test('normal_bot') + |
| 93 api.properties(buildername=builder, |
| 94 revision='abc123', |
| 95 path_config='kitchen') |
| 96 ) |
| 97 |
| 98 builder = 'Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-Trybot' |
| 99 yield ( |
| 100 api.test('trybot') + |
| 101 api.properties(buildername=builder, |
| 102 revision='abc123', |
| 103 path_config='kitchen', |
| 104 issue='12345', |
| 105 patchset='1002') |
| 106 ) |
OLD | NEW |