Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Side by Side Diff: scripts/slave/annotated_run.py

Issue 1178733003: Modify annotated_run to read factory configs from the slave checkout. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2013 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2013 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 import json
6 import optparse 7 import optparse
7 import os 8 import os
8 import subprocess 9 import subprocess
9 import sys 10 import sys
10 11
11 BUILD_ROOT = os.path.dirname(os.path.dirname(os.path.dirname( 12 BUILD_ROOT = os.path.dirname(os.path.dirname(os.path.dirname(
12 os.path.abspath(__file__)))) 13 os.path.abspath(__file__))))
13 sys.path.append(os.path.join(BUILD_ROOT, 'scripts')) 14 sys.path.append(os.path.join(BUILD_ROOT, 'scripts'))
14 sys.path.append(os.path.join(BUILD_ROOT, 'third_party')) 15 sys.path.append(os.path.join(BUILD_ROOT, 'third_party'))
15 16
16 from common import annotator 17 from common import annotator
17 from common import chromium_utils 18 from common import chromium_utils
18 from slave import recipe_universe 19 from slave import recipe_universe
19 20
20 from recipe_engine import main as recipe_main 21 from recipe_engine import main as recipe_main
21 22
22 23
23 def get_recipe_properties(factory_properties, build_properties): 24 def get_recipe_properties(factory_properties, build_properties):
24 """Constructs the recipe's properties from buildbot's properties. 25 """Constructs the recipe's properties from buildbot's properties.
25 26
26 This merges factory_properties and build_properties. Furthermore, it 27 This retrieves the current factory properties from the master_config
27 tries to reconstruct the 'recipe' property from builders.pyl if it isn't 28 in the slave's checkout (the factory properties handed to us from the
28 already there, and in that case merges in properties form builders.pyl. 29 master might be out of date), and merges in the build properties.
30
31 Using the values from the checkout allows us to do things like change
32 the recipe and other factory properties for a builder without needing
33 a master restart.
29 """ 34 """
30 properties = factory_properties.copy() 35 mastername = factory_properties['mastername']
36 buildername = factory_properties['buildername']
Paweł Hajdan Jr. 2015/06/11 08:38:19 How does this interact with e.g. running a recipe
37
38 # Get the recipe and otherfactory properties from the current
39 # checked-out copies of the master.cfg on the slave, rather than taking what
40 # was handed to us from the master. The latter might be out-of-date.
41 script_path = os.path.join(BUILD_ROOT, 'scripts', 'slave',
42 'dump_factory_properties.py')
43 dump_cmd = [sys.executable,
44 script_path,
45 mastername,
46 buildername]
47 proc = subprocess.Popen(dump_cmd, cwd=BUILD_ROOT, stdout=subprocess.PIPE)
48 out, _ = proc.communicate()
49 output_obj = json.loads(out)
50
51 if output_obj['result']:
52 raise LookupError('Failed to get the current factory properties for '
53 '%s on %s: %s' % (buildername, mastername,
54 output_obj['message']))
55
56 if 'recipe' not in output_obj['factory_properties']:
57 raise LookupError('Cannot find recipe for %s on %s' %
58 (buildername, mastername))
59
60 properties = output_obj['factory_properties'].copy()
31 properties.update(build_properties) 61 properties.update(build_properties)
32
33 # Try to reconstruct the recipe from builders.pyl if not given.
34 if 'recipe' not in properties:
35 mastername = properties['mastername']
36 buildername = properties['buildername']
37
38 master_path = chromium_utils.MasterPath(mastername)
39 builders_file = os.path.join(master_path, 'builders.pyl')
40 if os.path.isfile(builders_file):
41 builders = chromium_utils.ReadBuildersFile(builders_file)
42 assert buildername in builders['builders'], (
43 'buildername %s is not listed in %s' % (buildername, builders_file))
44 builder = builders['builders'][buildername]
45
46 # Update properties with builders.pyl data.
47 properties['recipe'] = builder['recipe']
48 properties.update(builder.get('properties', {}))
49 else:
50 raise LookupError('Cannot find recipe for %s on %s' %
51 (build_properties['buildername'],
52 build_properties['mastername']))
53 return properties 62 return properties
54 63
55 64
56 def get_args(argv): 65 def get_args(argv):
57 """Process command-line arguments.""" 66 """Process command-line arguments."""
58 67
59 parser = optparse.OptionParser( 68 parser = optparse.OptionParser(
60 description='Entry point for annotated builds.') 69 description='Entry point for annotated builds.')
61 parser.add_option('--build-properties', 70 parser.add_option('--build-properties',
62 action='callback', callback=chromium_utils.convert_json, 71 action='callback', callback=chromium_utils.convert_json,
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 130
122 131
123 def shell_main(argv): 132 def shell_main(argv):
124 if update_scripts(): 133 if update_scripts():
125 return subprocess.call([sys.executable] + argv) 134 return subprocess.call([sys.executable] + argv)
126 else: 135 else:
127 return main(argv) 136 return main(argv)
128 137
129 if __name__ == '__main__': 138 if __name__ == '__main__':
130 sys.exit(shell_main(sys.argv)) 139 sys.exit(shell_main(sys.argv))
OLDNEW
« no previous file with comments | « no previous file | scripts/slave/dump_factory_properties.py » ('j') | scripts/slave/dump_factory_properties.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698