skia2/infra/bots/recipe_modules/upload_nano_results/api.py
Eric Boren e6b26add4d Roll recipe DEPS
Attempt 2. Lots of fixes due to upstream breaks.

BUG=skia:

Change-Id: Ie05b2da1790fbcce5c45ef09c4c832e09de6b5c5
Reviewed-on: https://skia-review.googlesource.com/8762
Reviewed-by: Eric Boren <borenet@google.com>
Commit-Queue: Eric Boren <borenet@google.com>
2017-02-21 14:01:36 +00:00

51 lines
1.6 KiB
Python

# 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 nanobench results.
from recipe_engine import recipe_api
class UploadNanoResultsApi(recipe_api.RecipeApi):
def run(self):
# Upload the nanobench resuls.
builder_name = self.m.properties['buildername']
now = self.m.time.utcnow()
src_path = self.m.path['start_dir'].join(
'perfdata', builder_name, 'data')
with self.m.step.context({'cwd': src_path}):
results = self.m.file.glob(
'find results',
src_path.join('*.json'),
test_data=[src_path.join('nanobench_abc123.json')],
infra_step=True)
if len(results) != 1: # pragma: nocover
raise Exception('Unable to find nanobench or skpbench JSON file!')
src = results[0]
basename = self.m.path.basename(src)
gs_path = '/'.join((
'nano-json-v1', str(now.year).zfill(4),
str(now.month).zfill(2), str(now.day).zfill(2), str(now.hour).zfill(2),
builder_name))
issue = str(self.m.properties.get('issue', ''))
patchset = str(self.m.properties.get('patchset', ''))
if self.m.properties.get('patch_storage', '') == 'gerrit':
issue = str(self.m.properties['patch_issue'])
patchset = str(self.m.properties['patch_set'])
if issue and patchset:
gs_path = '/'.join(('trybot', gs_path, issue, patchset))
dst = '/'.join((
'gs://%s' % self.m.properties['gs_bucket'], gs_path, basename))
self.m.step(
'upload',
cmd=['gsutil', 'cp', '-z', 'json', src, dst],
infra_step=True)