blob: ef71575b2d399c7b54c21d8553ae23f2a4e13c6b [file] [log] [blame]
Yuqian Li2ebf3d12017-10-24 09:43:21 -04001# 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
9import calendar
10
11
12DEPS = [
Eric Borenb7023162018-05-04 13:46:15 -040013 'flavor',
Yuqian Li2ebf3d12017-10-24 09:43:21 -040014 'recipe_engine/context',
15 'recipe_engine/file',
16 'recipe_engine/path',
17 'recipe_engine/properties',
18 'recipe_engine/step',
19 'recipe_engine/time',
Eric Borenb7023162018-05-04 13:46:15 -040020 'run',
Yuqian Li2ebf3d12017-10-24 09:43:21 -040021 'vars',
22]
23
24
25def FindFile(api, suffix):
26 with api.context(cwd=api.path['start_dir']):
27 results = api.file.glob_paths(
28 'find %s results' % suffix,
Eric Boren72f66682018-05-18 07:36:55 -040029 api.path['start_dir'].join('perf'),
Yuqian Li2ebf3d12017-10-24 09:43:21 -040030 '*.%s' % suffix,
31 test_data=['bench_modified_master.%s' % suffix])
32 if len(results) != 1: # pragma: nocover
33 raise Exception('Unable to find the %s file!' % suffix)
34 return results[0]
35
36
37def RunSteps(api):
Eric Borenb7023162018-05-04 13:46:15 -040038 api.vars.setup()
39 api.file.ensure_directory('makedirs tmp_dir', api.vars.tmp_dir)
40 api.flavor.setup()
Yuqian Li2ebf3d12017-10-24 09:43:21 -040041
42 builder_name = api.properties['buildername']
43
44 now = api.time.utcnow()
45
46 json_src = FindFile(api, "json")
47 csv_src = FindFile(api, "csv")
48
49 ts = int(calendar.timegm(now.utctimetuple()))
Eric Boren72f66682018-05-18 07:36:55 -040050 basename = "bench_modified_master_%s_%d" % (api.properties['revision'], ts)
Yuqian Li2ebf3d12017-10-24 09:43:21 -040051
52 gs_path = '/'.join((
53 'calmbench-v1', str(now.year).zfill(4),
54 str(now.month).zfill(2), str(now.day).zfill(2), str(now.hour).zfill(2),
55 builder_name))
56
57 issue = api.properties.get('patch_issue')
58 patchset = api.properties.get('patch_set')
59 if issue and patchset:
60 gs_path = '/'.join(('trybot', gs_path, str(issue), str(patchset)))
61
62 dst = '/'.join((
63 'gs://%s' % api.properties['gs_bucket'], gs_path, basename))
64
65 json_dst = dst + ".json"
66 csv_dst = dst + ".csv"
67
68 api.step(
69 'upload json',
70 cmd=['gsutil', 'cp', '-z', 'json', json_src, json_dst],
71 infra_step=True)
72 api.step(
73 'upload csv',
74 cmd=['gsutil', 'cp', '-z', 'csv', csv_src, csv_dst],
75 infra_step=True)
76
77
78def GenTests(api):
Yuqian Liab246cb2017-11-02 13:48:23 -040079 builder = 'Calmbench-Debian9-Clang-GCE-CPU-AVX2-x86_64-Release-All'
Yuqian Li2ebf3d12017-10-24 09:43:21 -040080 yield (
81 api.test('normal_bot') +
82 api.properties(buildername=builder,
83 repository='https://skia.googlesource.com/skia.git',
84 gs_bucket='skia-calmbench',
85 swarm_out_dir='[SWARM_OUT_DIR]',
86 revision='abc123',
87 path_config='kitchen')
88 )
89
90 yield (
91 api.test('trybot') +
92 api.properties(buildername=builder,
93 repository='https://skia.googlesource.com/skia.git',
94 gs_bucket='skia-calmbench',
95 swarm_out_dir='[SWARM_OUT_DIR]',
96 revision='abc123',
97 path_config='kitchen',
98 patch_storage='gerrit') +
99 api.properties.tryserver(
100 buildername=builder,
101 gerrit_project='skia',
102 gerrit_url='https://skia-review.googlesource.com/',
103 )
104 )