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 buildstats results to Perf. 7 8 9DEPS = [ 10 'recipe_engine/context', 11 'recipe_engine/file', 12 'recipe_engine/path', 13 'recipe_engine/properties', 14 'recipe_engine/step', 15 'recipe_engine/time', 16] 17 18 19def RunSteps(api): 20 # Upload the buildstats results. 21 builder_name = api.properties['buildername'] 22 23 now = api.time.utcnow() 24 src_path = api.path['start_dir'].join('perf') 25 with api.context(cwd=src_path): 26 results = api.file.glob_paths( 27 'find results', 28 src_path, 29 '*.json', 30 test_data=['buildstats_abc123.json', 'buildstats_def.json']) 31 if not len(results): # pragma: nocover 32 raise Exception('Unable to find buildstats JSON file!') 33 34 for src in results: 35 basename = api.path.basename(src) 36 basename = api.properties['revision'] + '_' + basename 37 gs_path = '/'.join(( 38 'buildstats-json-v1', str(now.year).zfill(4), 39 str(now.month).zfill(2), str(now.day).zfill(2), str(now.hour).zfill(2), 40 builder_name)) 41 42 issue = api.properties.get('patch_issue') 43 patchset = api.properties.get('patch_set') 44 if issue and patchset: 45 gs_path = '/'.join(('trybot', gs_path, str(issue), str(patchset))) 46 47 dst = '/'.join(( 48 'gs://%s' % api.properties['gs_bucket'], gs_path, basename)) 49 50 api.step( 51 'upload %s' % src, 52 cmd=['gsutil', 'cp', '-z', 'json', src, dst], 53 infra_step=True) 54 55 56def GenTests(api): 57 builder = 'BuildStats-Debian9-EMCC-wasm-Release-PathKit' 58 yield ( 59 api.test('normal_bot') + 60 api.properties(buildername=builder, 61 gs_bucket='skia-perf', 62 revision='abc123', 63 path_config='kitchen') 64 ) 65 66 yield ( 67 api.test('trybot') + 68 api.properties(buildername=builder, 69 gs_bucket='skia-perf', 70 revision='abc123', 71 path_config='kitchen', 72 patch_storage='gerrit') + 73 api.properties.tryserver( 74 buildername=builder, 75 gerrit_project='skia', 76 gerrit_url='https://skia-review.googlesource.com/', 77 ) 78 ) 79