OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # | 2 # |
3 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2013 The Chromium Authors. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 import collections | 7 import collections |
8 import copy | 8 import copy |
9 import json | 9 import json |
10 import optparse | 10 import optparse |
11 import os | 11 import os |
12 import pipes | 12 import pipes |
13 import subprocess | 13 import subprocess |
14 import sys | 14 import sys |
15 | 15 |
16 sys.path.append(os.path.join(os.path.dirname(__file__), '..')) | |
17 from pylib import buildbot_report | |
18 | |
19 CHROME_SRC = os.path.abspath( | 16 CHROME_SRC = os.path.abspath( |
20 os.path.join(os.path.dirname(__file__), '..', '..', '..')) | 17 os.path.join(os.path.dirname(__file__), '..', '..', '..')) |
21 | 18 |
22 GLOBAL_SLAVE_PROPS = {} | 19 GLOBAL_SLAVE_PROPS = {} |
23 | 20 |
24 BotConfig = collections.namedtuple( | 21 BotConfig = collections.namedtuple( |
25 'BotConfig', ['bot_id', 'bash_funs', 'test_obj', 'slave_props']) | 22 'BotConfig', ['bot_id', 'host_opts', 'test_obj', 'slave_props']) |
26 TestConfig = collections.namedtuple('Tests', ['tests', 'extra_args']) | 23 TestConfig = collections.namedtuple('Tests', ['tests', 'extra_args']) |
27 Command = collections.namedtuple( | 24 Command = collections.namedtuple( |
28 'Command', ['step_name', 'command', 'testing_cmd']) | 25 'Command', ['step_name', 'command', 'testing_cmd']) |
29 | 26 |
30 | 27 |
31 def GetCommands(options, bot_config): | 28 def GetCommands(options, bot_config): |
32 """Get a formatted list of commands. | 29 """Get a formatted list of commands. |
33 | 30 |
34 Args: | 31 Args: |
35 options: Options object. | 32 options: Options object. |
36 bot_config: A BotConfig named tuple. | 33 bot_config: A BotConfig named tuple. |
37 Returns: | 34 Returns: |
38 list of Command objects. | 35 list of Command objects. |
39 """ | 36 """ |
40 slave_props = dict(GLOBAL_SLAVE_PROPS) | 37 slave_props = dict(GLOBAL_SLAVE_PROPS) |
41 if bot_config.slave_props: | 38 if bot_config.slave_props: |
42 slave_props.update(bot_config.slave_props) | 39 slave_props.update(bot_config.slave_props) |
43 | 40 |
44 property_args = [ | 41 property_args = [ |
45 '--factory-properties=%s' % json.dumps(options.factory_properties), | 42 '--factory-properties=%s' % json.dumps(options.factory_properties), |
46 '--build-properties=%s' % json.dumps(options.build_properties), | 43 '--build-properties=%s' % json.dumps(options.build_properties), |
47 '--slave-properties=%s' % json.dumps(slave_props)] | 44 '--slave-properties=%s' % json.dumps(slave_props)] |
48 | 45 |
49 commands = [] | 46 common_cmd = ['; '.join(['. build/android/buildbot/buildbot_functions.sh', |
50 def WrapWithBash(command): | 47 'bb_baseline_setup %s %s' % ( |
51 """Wrap a bash command string with envsetup scripts.""" | 48 CHROME_SRC, |
52 return ['bash', '-exc', '; '.join([ | 49 ' '.join(map(pipes.quote, property_args)))])] |
53 '. build/android/buildbot/buildbot_functions.sh', | |
54 'bb_baseline_setup %s %s' % ( | |
55 CHROME_SRC, | |
56 ' '.join(map(pipes.quote, property_args))), | |
57 command]) | |
58 ] | |
59 | 50 |
60 if bot_config.bash_funs: | 51 commands = [Command('Preparation', common_cmd, None)] |
61 # bash_funs command does not have a testing mode. | 52 |
62 commands.append( | 53 host_opts = bot_config.host_opts |
63 Command(None, WrapWithBash('; '.join(bot_config.bash_funs)), None)) | 54 if host_opts: |
| 55 host_script = 'build/android/buildbot/bb_host_steps.py' |
| 56 host_cmd = [host_script] + host_opts + property_args[0:2] |
| 57 cmd = ' '.join(map(pipes.quote, host_cmd)) |
| 58 commands.append(Command('Host steps', [cmd], [cmd])) |
64 | 59 |
65 test_obj = bot_config.test_obj | 60 test_obj = bot_config.test_obj |
66 if test_obj: | 61 if test_obj: |
67 run_test_cmd = [ | 62 run_test_cmd = [ |
68 'build/android/buildbot/bb_device_steps.py', '--reboot'] + property_args | 63 'build/android/buildbot/bb_device_steps.py', '--reboot'] + property_args |
69 for test in test_obj.tests: | 64 for test in test_obj.tests: |
70 run_test_cmd.extend(['-f', test]) | 65 run_test_cmd.extend(['-f', test]) |
71 if test_obj.extra_args: | 66 if test_obj.extra_args: |
72 run_test_cmd.extend(test_obj.extra_args) | 67 run_test_cmd.extend(test_obj.extra_args) |
73 commands.append(Command( | 68 cmd = ' '.join(map(pipes.quote, run_test_cmd)) |
74 'Run tests', | 69 commands.append(Command('Run tests', [cmd], [cmd])) |
75 WrapWithBash(' '.join(map(pipes.quote, run_test_cmd))), run_test_cmd)) | |
76 | 70 |
77 return commands | 71 return commands |
78 | 72 |
79 | 73 |
80 def GetBotStepMap(): | 74 def GetBotStepMap(): |
81 compile_step = ['bb_compile'] | 75 compile_opt = ['--compile'] |
82 std_build_steps = ['bb_compile', 'bb_zip_build'] | 76 std_host_tests = ['--host-tests=check_webview_licenses,findbugs'] |
83 std_test_steps = ['bb_extract_build'] | 77 std_build_opts = ['--compile', '--zipbuild'] |
| 78 std_test_opts = ['--extract-build'] |
84 std_tests = ['ui', 'unit'] | 79 std_tests = ['ui', 'unit'] |
85 flakiness_server = '--upload-to-flakiness-server' | 80 flakiness_server = '--upload-to-flakiness-server' |
86 | 81 |
87 B = BotConfig | 82 B = BotConfig |
88 def T(tests, extra_args=None): | 83 def T(tests, extra_args=None): |
89 return TestConfig(tests, extra_args) | 84 return TestConfig(tests, extra_args) |
90 | 85 |
91 bot_configs = [ | 86 bot_configs = [ |
92 # Main builders | 87 # Main builders |
93 B('main-builder-dbg', | 88 B('main-builder-dbg', std_build_opts + std_host_tests, None, None), |
94 ['bb_check_webview_licenses', 'bb_compile', 'bb_run_findbugs', | 89 B('main-builder-rel', std_build_opts, None, None), |
95 'bb_zip_build'], None, None), | 90 B('main-clang-builder', compile_opt, None, None), |
96 B('main-builder-rel', | 91 B('main-clobber', compile_opt, None, None), |
97 ['bb_compile', 'bb_zip_build'], None, None), | 92 B('main-tests', std_test_opts, T(std_tests, [flakiness_server]), None), |
98 B('main-clang-builder', compile_step, None, None), | |
99 B('main-clobber', compile_step, None, None), | |
100 B('main-tests', std_test_steps, T(std_tests, [flakiness_server]), | |
101 None), | |
102 | 93 |
103 # Other waterfalls | 94 # Other waterfalls |
104 B('asan-builder-tests', compile_step + ['bb_asan_tests_setup'], | 95 B('asan-builder-tests', compile_opt + ['--asan-tests-setup'], |
105 T(std_tests, ['--asan']), {'extra_gyp_defines': 'asan=1'}), | 96 T(std_tests, ['--asan']), {'extra_gyp_defines': 'asan=1'}), |
106 B('chromedriver-fyi-tests-dbg', std_test_steps, | 97 B('chromedriver-fyi-tests-dbg', std_test_opts, |
107 T(['chromedriver'], ['--install=ChromiumTestShell']), None), | 98 T(['chromedriver'], ['--install=ChromiumTestShell']), None), |
108 B('fyi-builder-dbg', | 99 B('fyi-builder-dbg', std_build_opts + std_host_tests + ['--experimental'], |
109 ['bb_check_webview_licenses', 'bb_compile', 'bb_compile_experimental', | 100 None, None), |
110 'bb_run_findbugs', 'bb_zip_build'], None, None), | 101 B('fyi-builder-rel', std_build_opts + ['--experimental'], None, None), |
111 B('fyi-builder-rel', | 102 B('fyi-tests-dbg-ics-gn', compile_opt + [ '--experimental'], |
112 ['bb_compile', 'bb_compile_experimental', 'bb_zip_build'], None, None), | |
113 B('fyi-tests-dbg-ics-gn', ['bb_compile', 'bb_compile_experimental'], | |
114 T(std_tests, ['--experimental', flakiness_server]), None), | 103 T(std_tests, ['--experimental', flakiness_server]), None), |
115 B('fyi-tests', std_test_steps, | 104 B('fyi-tests', std_test_opts, |
116 T(std_tests, ['--experimental', flakiness_server]), None), | 105 T(std_tests, ['--experimental', flakiness_server]), None), |
117 B('fyi-component-builder-tests-dbg', compile_step, | 106 B('fyi-component-builder-tests-dbg', compile_opt, |
118 T(std_tests, ['--experimental', flakiness_server]), None), | 107 T(std_tests, ['--experimental', flakiness_server]), None), |
119 B('perf-tests-rel', std_test_steps, | 108 B('perf-tests-rel', std_test_opts, T([], ['--install=ContentShell']), |
120 T([], ['--install=ContentShell']), | |
121 None), | 109 None), |
122 B('webkit-latest-webkit-tests', std_test_steps, | 110 B('webkit-latest-webkit-tests', std_test_opts, |
123 T(['webkit_layout', 'webkit']), None), | 111 T(['webkit_layout', 'webkit']), None), |
124 B('webkit-latest-contentshell', compile_step, T(['webkit_layout']), None), | 112 B('webkit-latest-contentshell', compile_opt, T(['webkit_layout']), None), |
125 | 113 |
126 # Generic builder config (for substring match). | 114 # Generic builder config (for substring match). |
127 B('builder', std_build_steps, None, None), | 115 B('builder', std_build_opts, None, None), |
128 ] | 116 ] |
129 | 117 |
130 bot_map = dict((config.bot_id, config) for config in bot_configs) | 118 bot_map = dict((config.bot_id, config) for config in bot_configs) |
131 | 119 |
132 # These bots have identical configuration to ones defined earlier. | 120 # These bots have identical configuration to ones defined earlier. |
133 copy_map = [ | 121 copy_map = [ |
134 ('lkgr-clobber', 'main-clobber'), | 122 ('lkgr-clobber', 'main-clobber'), |
135 ('try-builder-dbg', 'main-builder-dbg'), | 123 ('try-builder-dbg', 'main-builder-dbg'), |
136 ('try-builder-rel', 'main-builder-rel'), | 124 ('try-builder-rel', 'main-builder-rel'), |
137 ('try-clang-builder', 'main-clang-builder'), | 125 ('try-clang-builder', 'main-clang-builder'), |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 return 1 | 183 return 1 |
196 | 184 |
197 print 'Using config:', bot_config | 185 print 'Using config:', bot_config |
198 | 186 |
199 def CommandToString(command): | 187 def CommandToString(command): |
200 """Returns quoted command that can be run in bash shell.""" | 188 """Returns quoted command that can be run in bash shell.""" |
201 return ' '.join(map(pipes.quote, command)) | 189 return ' '.join(map(pipes.quote, command)) |
202 | 190 |
203 command_objs = GetCommands(options, bot_config) | 191 command_objs = GetCommands(options, bot_config) |
204 for command_obj in command_objs: | 192 for command_obj in command_objs: |
205 print 'Will run:', CommandToString(command_obj.command) | 193 print 'Will run "%s" step: %s' % (command_obj.step_name, |
| 194 CommandToString(command_obj.command)) |
206 | 195 |
| 196 commands = [] |
207 for command_obj in command_objs: | 197 for command_obj in command_objs: |
208 if command_obj.step_name: | |
209 buildbot_report.PrintNamedStep(command_obj.step_name) | |
210 command = command_obj.command | |
211 print CommandToString(command) | |
212 sys.stdout.flush() | |
213 env = None | |
214 if options.TESTING: | 198 if options.TESTING: |
215 if not command_obj.testing_cmd: | 199 if command_obj.testing_cmd: |
216 continue | 200 commands += command_obj.testing_cmd |
217 return_code = subprocess.call( | |
218 command_obj.testing_cmd, | |
219 cwd=CHROME_SRC, | |
220 env=dict(os.environ, BUILDBOT_TESTING='1')) | |
221 else: | 201 else: |
222 return_code = subprocess.call(command, cwd=CHROME_SRC, env=env) | 202 commands += command_obj.command |
223 if return_code != 0: | 203 if options.TESTING: |
224 return return_code | 204 return_code = subprocess.call( |
| 205 ['bash', '-exc', '; '.join(commands)], cwd=CHROME_SRC, |
| 206 env=dict(os.environ, BUILDBOT_TESTING='1')) |
| 207 else: |
| 208 return_code = subprocess.call( |
| 209 ['bash', '-exc', '; '.join(commands)], cwd=CHROME_SRC) |
| 210 |
| 211 if return_code != 0: |
| 212 return return_code |
225 | 213 |
226 | 214 |
227 if __name__ == '__main__': | 215 if __name__ == '__main__': |
228 sys.exit(main(sys.argv)) | 216 sys.exit(main(sys.argv)) |
OLD | NEW |