diff options
author | 2016-09-27 06:52:26 -0700 | |
---|---|---|
committer | 2016-09-27 06:52:26 -0700 | |
commit | 9766f0016669029fcdc49f00ceaaf66b01b03f4a (patch) | |
tree | 3a7c334621e1cfd2d177b258a473cea398e4a3f2 /infra/bots/recipes/upload_dm_results.py | |
parent | 7bfc08b9fb4289381609cee1deb0dc6325f878e1 (diff) |
Add swarming task for upload_dm_results
BUG=skia:5719
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2360203004
Review-Url: https://codereview.chromium.org/2360203004
Diffstat (limited to 'infra/bots/recipes/upload_dm_results.py')
-rw-r--r-- | infra/bots/recipes/upload_dm_results.py | 106 |
1 files changed, 106 insertions, 0 deletions
diff --git a/infra/bots/recipes/upload_dm_results.py b/infra/bots/recipes/upload_dm_results.py new file mode 100644 index 0000000000..20d2c064c3 --- /dev/null +++ b/infra/bots/recipes/upload_dm_results.py @@ -0,0 +1,106 @@ +# Copyright 2016 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + + +# Recipe for uploading DM results. + + +DEPS = [ + 'build/file', + 'recipe_engine/json', + 'recipe_engine/path', + 'recipe_engine/properties', + 'recipe_engine/shutil', + 'recipe_engine/step', + 'recipe_engine/time', +] + + +import time + + +DM_JSON = 'dm.json' +GS_BUCKET = 'gs://skia-infra-gm' +VERBOSE_LOG = 'verbose.log' + + +def RunSteps(api): + builder_name = api.properties['buildername'] + revision = api.properties['revision'] + issue = str(api.properties.get('issue', '')) + patchset = str(api.properties.get('patchset', '')) + + results_dir = api.path['cwd'].join('dm') + + # Validate the JSON file. + json_file = results_dir.join(DM_JSON) + api.json.read('validate dm.json', json_file) + + # Move dm.json and verbose.log to their own directory. + log_file = results_dir.join(VERBOSE_LOG) + tmp_dir = api.path['cwd'].join('tmp_upload') + api.shutil.makedirs('tmp dir', tmp_dir, infra_step=True) + api.shutil.copy('copy dm.json', json_file, tmp_dir) + api.shutil.copy('copy verbose.log', log_file, tmp_dir) + api.shutil.remove('rm old dm.json', json_file) + api.shutil.remove('rm old verbose.log', log_file) + + # Upload the images. + image_dest_path = '/'.join((GS_BUCKET, 'dm-images-v1')) + files_to_upload = api.file.glob( + 'find images', + results_dir.join('*'), + test_data=['someimage.png'], + infra_step=True) + if len(files_to_upload) > 0: + api.step( + 'upload images', + cmd=['gsutil', 'cp', results_dir.join('*'), image_dest_path], + ) + + # Upload the JSON summary and verbose.log. + now = api.time.utcnow() + summary_dest_path = '/'.join([ + 'dm-json-v1', + str(now.year ).zfill(4), + str(now.month).zfill(2), + str(now.day ).zfill(2), + str(now.hour ).zfill(2), + revision, + builder_name, + str(int(time.mktime(now.utctimetuple())))]) + + # Trybot results are further siloed by issue/patchset. + if builder_name.endswith('-Trybot'): + if not (issue and patchset): # pragma: nocover + raise Exception('issue and patchset properties are required for trybots.') + summary_dest_path = '/'.join(('trybot', summary_dest_path, issue, patchset)) + + summary_dest_path = '/'.join((GS_BUCKET, summary_dest_path)) + + api.step( + 'upload JSON and logs', + cmd=['gsutil', 'cp', '-z', 'json,log', tmp_dir.join('*'), + summary_dest_path], + ) + + +def GenTests(api): + builder = 'Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug' + yield ( + api.test('normal_bot') + + api.properties(buildername=builder, + revision='abc123', + path_config='kitchen') + ) + + builder = 'Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-Trybot' + yield ( + api.test('trybot') + + api.properties(buildername=builder, + revision='abc123', + path_config='kitchen', + issue='12345', + patchset='1002') + ) |