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

Side by Side Diff: master/skia_master_scripts/factory.py

Issue 14081044: Add Validation for BuildFactory Configuration (Closed) Base URL: http://skia.googlecode.com/svn/buildbot/
Patch Set: Created 7 years, 8 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
« no previous file with comments | « no previous file | master/skia_master_scripts/utils.py » ('j') | master/skia_master_scripts/utils.py » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 5
6 """Utility class to build the Skia master BuildFactory's. 6 """Utility class to build the Skia master BuildFactory's.
7 7
8 Based on gclient_factory.py and adds Skia-specific steps.""" 8 Based on gclient_factory.py and adds Skia-specific steps."""
9 9
10 10
11 from buildbot.process.properties import WithProperties 11 from buildbot.process.properties import WithProperties
12 from config_private import AUTOGEN_SVN_BASEURL, SKIA_SVN_BASEURL 12 from config_private import AUTOGEN_SVN_BASEURL, SKIA_SVN_BASEURL
13 from master.factory import gclient_factory 13 from master.factory import gclient_factory
14 from master.factory.build_factory import BuildFactory 14 from master.factory.build_factory import BuildFactory
15 from skia_master_scripts import commands as skia_commands 15 from skia_master_scripts import commands as skia_commands
16 import config 16 import config
17 import config_private 17 import config_private
18 import ntpath 18 import ntpath
19 import os
19 import posixpath 20 import posixpath
21 import utils
20 22
21 23
22 # TODO(epoger): My intent is to make the build steps identical on all platforms 24 # TODO(epoger): My intent is to make the build steps identical on all platforms
23 # and thus remove the need for the whole target_platform parameter. 25 # and thus remove the need for the whole target_platform parameter.
24 # For now, these must match the target_platform values used in 26 # For now, these must match the target_platform values used in
25 # third_party/chromium_buildbot/scripts/master/factory/gclient_factory.py , 27 # third_party/chromium_buildbot/scripts/master/factory/gclient_factory.py ,
26 # because we pass these values into GClientFactory.__init__() . 28 # because we pass these values into GClientFactory.__init__() .
27 TARGET_PLATFORM_LINUX = 'linux' 29 TARGET_PLATFORM_LINUX = 'linux'
28 TARGET_PLATFORM_MAC = 'mac' 30 TARGET_PLATFORM_MAC = 'mac'
29 TARGET_PLATFORM_WIN32 = 'win32' 31 TARGET_PLATFORM_WIN32 = 'win32'
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 108
107 # Set _default_clobber based on config.Master 109 # Set _default_clobber based on config.Master
108 self._default_clobber = getattr(config.Master, 'default_clobber', False) 110 self._default_clobber = getattr(config.Master, 'default_clobber', False)
109 111
110 self._do_upload_results = do_upload_results 112 self._do_upload_results = do_upload_results
111 self._do_upload_bench_results = do_upload_results and \ 113 self._do_upload_bench_results = do_upload_results and \
112 perf_output_basedir != None 114 perf_output_basedir != None
113 self._do_patch_step = do_patch_step 115 self._do_patch_step = do_patch_step
114 116
115 if not environment_variables: 117 if not environment_variables:
116 my_env_vars = {} 118 self._env_vars = {}
borenet 2013/04/25 15:50:28 Adding this to self so that it gets recorded.
117 else: 119 else:
118 my_env_vars = dict(environment_variables) 120 self._env_vars = dict(environment_variables)
119 gyp_defines = my_env_vars.get('GYP_DEFINES', '') 121 gyp_defines = self._env_vars.get('GYP_DEFINES', '')
120 my_env_vars['GYP_DEFINES'] = gyp_defines + \ 122 self._env_vars['GYP_DEFINES'] = gyp_defines + \
121 ' skia_warnings_as_errors=%d' % int(compile_warnings_as_errors) 123 ' skia_warnings_as_errors=%d' % int(compile_warnings_as_errors)
122 124
123 # Get an implementation of SkiaCommands as appropriate for 125 # Get an implementation of SkiaCommands as appropriate for
124 # this target_platform. 126 # this target_platform.
125 workdir = self.TargetPathJoin('build', build_subdir) 127 workdir = self.TargetPathJoin('build', build_subdir)
126 self._skia_cmd_obj = skia_commands.SkiaCommands( 128 self._skia_cmd_obj = skia_commands.SkiaCommands(
127 target_platform=target_platform, factory=self, 129 target_platform=target_platform, factory=self,
128 configuration=configuration, workdir=workdir, 130 configuration=configuration, workdir=workdir,
129 target_arch=None, default_timeout=default_timeout, 131 target_arch=None, default_timeout=default_timeout,
130 environment_variables=my_env_vars) 132 environment_variables=self._env_vars)
131 133
132 self._perf_output_basedir = perf_output_basedir 134 self._perf_output_basedir = perf_output_basedir
133 135
134 self._configuration = configuration 136 self._configuration = configuration
135 if self._configuration not in CONFIGURATIONS: 137 if self._configuration not in CONFIGURATIONS:
136 raise ValueError('Invalid configuration %s. Must be one of: %s' % ( 138 raise ValueError('Invalid configuration %s. Must be one of: %s' % (
137 self._configuration, CONFIGURATIONS)) 139 self._configuration, CONFIGURATIONS))
138 140
139 self._skia_svn_username_file = '.skia_svn_username' 141 self._skia_svn_username_file = '.skia_svn_username'
140 self._skia_svn_password_file = '.skia_svn_password' 142 self._skia_svn_password_file = '.skia_svn_password'
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 '--make_flags', '"%s"' % ' '.join(self._make_flags), 179 '--make_flags', '"%s"' % ' '.join(self._make_flags),
178 '--test_args', '"%s"' % ' '.join(test_args), 180 '--test_args', '"%s"' % ' '.join(test_args),
179 '--gm_args', '"%s"' % ' '.join(gm_args), 181 '--gm_args', '"%s"' % ' '.join(gm_args),
180 '--bench_args', '"%s"' % ' '.join(bench_args), 182 '--bench_args', '"%s"' % ' '.join(bench_args),
181 '--num_cores', WithProperties('%(num_cores:-None)s'), 183 '--num_cores', WithProperties('%(num_cores:-None)s'),
182 '--is_try', str(self._do_patch_step), 184 '--is_try', str(self._do_patch_step),
183 '--bench_pictures_cfg', bench_pictures_cfg, 185 '--bench_pictures_cfg', bench_pictures_cfg,
184 ] 186 ]
185 BuildFactory.__init__(self, build_factory_properties=properties) 187 BuildFactory.__init__(self, build_factory_properties=properties)
186 188
189 def Validate(self):
190 """ Validate the Factory against the known good configuration. """
191 test_dir = os.path.join(os.path.dirname(__file__), os.pardir, os.pardir,
192 'tools', 'tests', 'factory_configuration')
193 expected_dir = os.path.join(test_dir, 'expected')
194 if not os.path.exists(expected_dir):
rmistry 2013/04/25 17:31:50 I think we can assume that the expected dir always
borenet 2013/04/25 18:28:09 Done.
195 os.makedirs(expected_dir)
196 actual_dir = os.path.join(test_dir, 'actual')
197 if not os.path.exists(actual_dir):
198 os.makedirs(actual_dir)
199 expectation = None
200 try:
201 expectation = open(os.path.join(expected_dir, self._builder_name)).read()
202 except IOError:
203 # Should we error out here? We really want to have expectations...
borenet 2013/04/25 15:50:28 I'm in favor of throwing an error. That way, we a
rmistry 2013/04/25 17:31:50 Yes lets throw an error, else we will never be abl
204 print 'Warning: No expected factory configuration for %s.' % \
205 self._builder_name
206 as_string = utils.ToString(self.__dict__)
rmistry 2013/04/25 17:31:50 as_string -> vars_as_string or attr_as_string ?
borenet 2013/04/25 18:28:09 Changed to self_as_string, since it really is a re
207 with open(os.path.join(actual_dir, self._builder_name), 'w') as f:
208 f.write(as_string)
209 if expectation and as_string != expectation:
rmistry 2013/04/25 17:31:50 if we throw an error above then expecation should
210 raise ValueError('Factory configuration for %s does not match '
211 'expectation!' % self._builder_name)
212
187 def AddSlaveScript(self, script, description, args=None, timeout=None, 213 def AddSlaveScript(self, script, description, args=None, timeout=None,
188 halt_on_failure=False, is_upload_step=False, 214 halt_on_failure=False, is_upload_step=False,
189 is_rebaseline_step=False, get_props_from_stdout=None, 215 is_rebaseline_step=False, get_props_from_stdout=None,
190 workdir=None): 216 workdir=None):
191 """ Add a BuildStep consisting of a python script. 217 """ Add a BuildStep consisting of a python script.
192 218
193 script: which slave-side python script to run. 219 script: which slave-side python script to run.
194 description: string briefly describing the BuildStep. 220 description: string briefly describing the BuildStep.
195 args: optional list of strings; arguments to pass to the script. 221 args: optional list of strings; arguments to pass to the script.
196 timeout: optional integer; maximum time for the BuildStep to complete. 222 timeout: optional integer; maximum time for the BuildStep to complete.
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 self.UploadBenchGraphs() 516 self.UploadBenchGraphs()
491 517
492 def Build(self, clobber=None): 518 def Build(self, clobber=None):
493 """Build and return the complete BuildFactory. 519 """Build and return the complete BuildFactory.
494 520
495 clobber: boolean indicating whether we should clean before building 521 clobber: boolean indicating whether we should clean before building
496 """ 522 """
497 self.CommonSteps(clobber) 523 self.CommonSteps(clobber)
498 self.NonPerfSteps() 524 self.NonPerfSteps()
499 self.PerfSteps() 525 self.PerfSteps()
526 self.Validate()
borenet 2013/04/25 15:50:28 Each builder only uses one of these Build function
500 return self 527 return self
501 528
502 def BuildCompileOnly(self, clobber=None): 529 def BuildCompileOnly(self, clobber=None):
503 """Build and return the complete BuildFactory, with only the compile step. 530 """Build and return the complete BuildFactory, with only the compile step.
504 Does not build in one step; the assumption is that if we're only performing 531 Does not build in one step; the assumption is that if we're only performing
505 the compile, we want as much information as possible about *which* compile 532 the compile, we want as much information as possible about *which* compile
506 steps are passing and failing. 533 steps are passing and failing.
507 534
508 clobber: boolean indicating whether we should clean before building 535 clobber: boolean indicating whether we should clean before building
509 """ 536 """
510 self.UpdateSteps() 537 self.UpdateSteps()
511 self.Compile(clobber=clobber, build_in_one_step=False) 538 self.Compile(clobber=clobber, build_in_one_step=False)
539 self.Validate()
512 return self 540 return self
513 541
514 def BuildNoPerf(self, clobber=None): 542 def BuildNoPerf(self, clobber=None):
515 """Build and return the complete BuildFactory, without the benchmarking 543 """Build and return the complete BuildFactory, without the benchmarking
516 steps. 544 steps.
517 545
518 clobber: boolean indicating whether we should clean before building 546 clobber: boolean indicating whether we should clean before building
519 """ 547 """
520 self.CommonSteps(clobber) 548 self.CommonSteps(clobber)
521 self.NonPerfSteps() 549 self.NonPerfSteps()
550 self.Validate()
522 return self 551 return self
523 552
524 def BuildPerfOnly(self, clobber=None): 553 def BuildPerfOnly(self, clobber=None):
525 """Build and return the complete BuildFactory, with only the benchmarking 554 """Build and return the complete BuildFactory, with only the benchmarking
526 steps. 555 steps.
527 556
528 clobber: boolean indicating whether we should clean before building 557 clobber: boolean indicating whether we should clean before building
529 """ 558 """
530 if not self._perf_output_basedir: 559 if not self._perf_output_basedir:
531 raise ValueError( 560 raise ValueError(
532 'BuildPerfOnly requires perf_output_basedir to be defined.') 561 'BuildPerfOnly requires perf_output_basedir to be defined.')
533 if self._configuration != CONFIG_RELEASE: 562 if self._configuration != CONFIG_RELEASE:
534 raise ValueError('BuildPerfOnly should run in %s configuration.' % 563 raise ValueError('BuildPerfOnly should run in %s configuration.' %
535 CONFIG_RELEASE) 564 CONFIG_RELEASE)
536 self.CommonSteps(clobber) 565 self.CommonSteps(clobber)
537 self.PerfSteps() 566 self.PerfSteps()
567 self.Validate()
538 return self 568 return self
OLDNEW
« no previous file with comments | « no previous file | master/skia_master_scripts/utils.py » ('j') | master/skia_master_scripts/utils.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698