Home | History | Annotate | Download | only in recipes
      1 # Copyright 2017 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 calmbench results.
      7 
      8 
      9 import calendar
     10 
     11 
     12 DEPS = [
     13   'core',
     14   'recipe_engine/context',
     15   'recipe_engine/file',
     16   'recipe_engine/path',
     17   'recipe_engine/properties',
     18   'recipe_engine/step',
     19   'recipe_engine/time',
     20   'vars',
     21 ]
     22 
     23 
     24 def FindFile(api, suffix):
     25   with api.context(cwd=api.path['start_dir']):
     26     results = api.file.glob_paths(
     27         'find %s results' % suffix,
     28         api.path['start_dir'],
     29         '*.%s' % suffix,
     30         test_data=['bench_modified_master.%s' % suffix])
     31   if len(results) != 1:  # pragma: nocover
     32     raise Exception('Unable to find the %s file!' % suffix)
     33   return results[0]
     34 
     35 
     36 def RunSteps(api):
     37   api.core.setup()
     38 
     39   builder_name = api.properties['buildername']
     40 
     41   now = api.time.utcnow()
     42 
     43   json_src = FindFile(api, "json")
     44   csv_src = FindFile(api, "csv")
     45 
     46   ts = int(calendar.timegm(now.utctimetuple()))
     47   basename = "bench_modified_master_%s_%d" % (api.vars.got_revision, ts)
     48 
     49   gs_path = '/'.join((
     50       'calmbench-v1', str(now.year).zfill(4),
     51       str(now.month).zfill(2), str(now.day).zfill(2), str(now.hour).zfill(2),
     52       builder_name))
     53 
     54   issue = api.properties.get('patch_issue')
     55   patchset = api.properties.get('patch_set')
     56   if issue and patchset:
     57     gs_path = '/'.join(('trybot', gs_path, str(issue), str(patchset)))
     58 
     59   dst = '/'.join((
     60       'gs://%s' % api.properties['gs_bucket'], gs_path, basename))
     61 
     62   json_dst = dst + ".json"
     63   csv_dst = dst + ".csv"
     64 
     65   api.step(
     66       'upload json',
     67       cmd=['gsutil', 'cp', '-z', 'json', json_src, json_dst],
     68       infra_step=True)
     69   api.step(
     70       'upload csv',
     71       cmd=['gsutil', 'cp', '-z', 'csv', csv_src, csv_dst],
     72       infra_step=True)
     73 
     74 
     75 def GenTests(api):
     76   builder = 'Calmbench-Debian9-Clang-GCE-CPU-AVX2-x86_64-Release-All'
     77   yield (
     78     api.test('normal_bot') +
     79     api.properties(buildername=builder,
     80                    repository='https://skia.googlesource.com/skia.git',
     81                    gs_bucket='skia-calmbench',
     82                    swarm_out_dir='[SWARM_OUT_DIR]',
     83                    revision='abc123',
     84                    path_config='kitchen')
     85   )
     86 
     87   yield (
     88     api.test('trybot') +
     89     api.properties(buildername=builder,
     90                    repository='https://skia.googlesource.com/skia.git',
     91                    gs_bucket='skia-calmbench',
     92                    swarm_out_dir='[SWARM_OUT_DIR]',
     93                    revision='abc123',
     94                    path_config='kitchen',
     95                    patch_storage='gerrit') +
     96     api.properties.tryserver(
     97         buildername=builder,
     98         gerrit_project='skia',
     99         gerrit_url='https://skia-review.googlesource.com/',
    100     )
    101   )
    102