| OLD | NEW |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 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 """Utility classes to define and coordinate CrOS Chromite builder display. | 5 """Utility classes to define and coordinate CrOS Chromite builder display. |
| 6 """ | 6 """ |
| 7 | 7 |
| 8 import re | 8 import re |
| 9 | 9 |
| 10 from collections import OrderedDict, namedtuple | 10 from collections import OrderedDict, namedtuple |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 configuration. Information stored in this class should be examined in detail | 41 configuration. Information stored in this class should be examined in detail |
| 42 and, as appropriate, moved into Chromite. | 42 and, as appropriate, moved into Chromite. |
| 43 """ | 43 """ |
| 44 | 44 |
| 45 # Default set of class base properties. Subclasses can override these to | 45 # Default set of class base properties. Subclasses can override these to |
| 46 # affect behavior. | 46 # affect behavior. |
| 47 CLOSER = False | 47 CLOSER = False |
| 48 FLOATING = None | 48 FLOATING = None |
| 49 UNIQUE = False | 49 UNIQUE = False |
| 50 COLLAPSE = True | 50 COLLAPSE = True |
| 51 CONFIG_BUILDERNAME_MAP = {} | |
| 52 SLAVE_TYPE = SlaveType.BAREMETAL | 51 SLAVE_TYPE = SlaveType.BAREMETAL |
| 53 SLAVE_CLASS = None | 52 SLAVE_CLASS = None |
| 54 CBB_VARIANT = None | 53 CBB_VARIANT = None |
| 55 TIMEOUT = None | 54 TIMEOUT = None |
| 56 | 55 |
| 57 def __init__(self, config, branch=None): | 56 def __init__(self, config, branch=None): |
| 58 """Initializes a new configuration. | 57 """Initializes a new configuration. |
| 59 | 58 |
| 60 Args: | 59 Args: |
| 61 config (ChromiteTarget): The underlying Chromite configuration object. | 60 config (ChromiteTarget): The underlying Chromite configuration object. |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 result = ORDINALS.get(self.config.category) | 135 result = ORDINALS.get(self.config.category) |
| 137 if result is None: | 136 if result is None: |
| 138 return ORDINALS.get(None) | 137 return ORDINALS.get(None) |
| 139 return result | 138 return result |
| 140 | 139 |
| 141 @property | 140 @property |
| 142 def builder_name(self): | 141 def builder_name(self): |
| 143 """Returns (str): The waterfall builder name for this configuration.""" | 142 """Returns (str): The waterfall builder name for this configuration.""" |
| 144 if self.config.get('buildbot_waterfall_name'): | 143 if self.config.get('buildbot_waterfall_name'): |
| 145 return self.config['buildbot_waterfall_name'] | 144 return self.config['buildbot_waterfall_name'] |
| 146 return str(self.CONFIG_BUILDERNAME_MAP.get(self.config.name) or | 145 return str(self._GetBuilderName()) |
| 147 self._GetBuilderName()) | |
| 148 | 146 |
| 149 @property | 147 @property |
| 150 def is_experimental(self): | 148 def is_experimental(self): |
| 151 """Returns (bool): If this builder is experimental.""" | 149 """Returns (bool): If this builder is experimental.""" |
| 152 return self._IsExperimental() | 150 return self._IsExperimental() |
| 153 | 151 |
| 154 def _GetBuilderName(self): | 152 def _GetBuilderName(self): |
| 155 """Returns (str): Returns the generated builder name. | 153 """Returns (str): Returns the generated builder name. |
| 156 | 154 |
| 157 Unless overloaded, the builder name will default to the target configuration | 155 Unless overloaded, the builder name will default to the target configuration |
| (...skipping 21 matching lines...) Expand all Loading... |
| 179 return not (self.config.is_master or self.config.get('important')) | 177 return not (self.config.is_master or self.config.get('important')) |
| 180 | 178 |
| 181 | 179 |
| 182 class PreCqLauncherBuilderConfig(BuilderConfig): | 180 class PreCqLauncherBuilderConfig(BuilderConfig): |
| 183 """BuilderConfig for the Pre-CQ launcher target.""" | 181 """BuilderConfig for the Pre-CQ launcher target.""" |
| 184 | 182 |
| 185 UNIQUE = True | 183 UNIQUE = True |
| 186 CLOSER = True | 184 CLOSER = True |
| 187 SLAVE_TYPE = SlaveType.GCE_WIMPY | 185 SLAVE_TYPE = SlaveType.GCE_WIMPY |
| 188 | 186 |
| 189 def _GetBuilderName(self): | |
| 190 return 'Pre-CQ Launcher' | |
| 191 | |
| 192 | 187 |
| 193 class PaladinBuilderConfig(BuilderConfig): | 188 class PaladinBuilderConfig(BuilderConfig): |
| 194 """BuilderConfig for Paladin launcher targets.""" | 189 """BuilderConfig for Paladin launcher targets.""" |
| 195 | 190 |
| 196 UNIQUE = True | 191 UNIQUE = True |
| 197 FLOATING = 'paladin' | 192 FLOATING = 'paladin' |
| 198 CONFIG_BUILDERNAME_MAP = { | |
| 199 'master-paladin': 'CQ master', | |
| 200 } | |
| 201 | |
| 202 def _GetBuilderName(self): | |
| 203 return '%s paladin' % (self.config.base,) | |
| 204 | 193 |
| 205 | 194 |
| 206 class IncrementalBuilderConfig(BuilderConfig): | 195 class IncrementalBuilderConfig(BuilderConfig): |
| 207 """BuilderConfig for Incremental launcher targets.""" | 196 """BuilderConfig for Incremental launcher targets.""" |
| 208 | 197 |
| 209 CLOSER = True | 198 CLOSER = True |
| 210 COLLAPSE = AlwaysCollapseFunc | 199 COLLAPSE = AlwaysCollapseFunc |
| 211 | 200 |
| 212 def _GetBuilderName(self): | |
| 213 return '%s incremental' % (self.config.base,) | |
| 214 | |
| 215 def _IsExperimental(self): | 201 def _IsExperimental(self): |
| 216 return False | 202 return False |
| 217 | 203 |
| 218 | 204 |
| 219 class FullBuilderConfig(BuilderConfig): | 205 class FullBuilderConfig(BuilderConfig): |
| 220 """BuilderConfig for Full launcher targets.""" | 206 """BuilderConfig for Full launcher targets.""" |
| 221 | 207 |
| 222 CLOSER = True | 208 CLOSER = True |
| 223 COLLAPSE = AlwaysCollapseFunc | 209 COLLAPSE = AlwaysCollapseFunc |
| 224 | 210 |
| 225 def _GetBuilderName(self): | |
| 226 return '%s full' % (self.config.base,) | |
| 227 | |
| 228 def _IsExperimental(self): | 211 def _IsExperimental(self): |
| 229 return False | 212 return False |
| 230 | 213 |
| 231 | 214 |
| 232 class AsanBuilderConfig(BuilderConfig): | 215 class AsanBuilderConfig(BuilderConfig): |
| 233 """BuilderConfig for ASAN launcher targets.""" | 216 """BuilderConfig for ASAN launcher targets.""" |
| 234 | 217 |
| 235 CLOSER = True | 218 CLOSER = True |
| 236 COLLAPSE = AlwaysCollapseFunc | 219 COLLAPSE = AlwaysCollapseFunc |
| 237 | 220 |
| 238 def _GetBuilderName(self): | |
| 239 return '%s ASAN' % (self.config.base,) | |
| 240 | |
| 241 def _IsExperimental(self): | 221 def _IsExperimental(self): |
| 242 return False | 222 return False |
| 243 | 223 |
| 244 | 224 |
| 245 class FirmwareBuilderConfig(BuilderConfig): | |
| 246 """BuilderConfig for Firmware launcher targets.""" | |
| 247 | |
| 248 def _GetBuilderName(self): | |
| 249 return '%s firmware' % (self.config.base,) | |
| 250 | |
| 251 | |
| 252 class PfqBuilderConfig(BuilderConfig): | |
| 253 """BuilderConfig for PFQ launcher targets.""" | |
| 254 | |
| 255 CONFIG_BUILDERNAME_MAP = { | |
| 256 'master-chromium-pfq': 'Chrome PFQ master', | |
| 257 'master-android-pfq': 'Android PFQ master', | |
| 258 } | |
| 259 | |
| 260 def _GetBuilderName(self): | |
| 261 project = self.config.suffix | |
| 262 if project.endswith('-pfq'): | |
| 263 project = project[:-4] | |
| 264 return '%s %s PFQ' % (self.config.base, project) | |
| 265 | |
| 266 | |
| 267 class PreFlightBranchBuilderConfig(BuilderConfig): | |
| 268 """BuilderConfig for pre-flight branch targets.""" | |
| 269 | |
| 270 def _GetBuilderName(self): | |
| 271 return '%s pre-flight' % (self.config.base,) | |
| 272 | |
| 273 | |
| 274 class CanaryBuilderConfig(BuilderConfig): | 225 class CanaryBuilderConfig(BuilderConfig): |
| 275 """BuilderConfig for canary/release launcher targets.""" | 226 """BuilderConfig for canary/release launcher targets.""" |
| 276 | 227 |
| 277 CONFIG_BUILDERNAME_MAP = { | |
| 278 'master-release': 'Canary master', | |
| 279 } | |
| 280 | |
| 281 def _GetBuilderName(self): | |
| 282 parts = [self.config.base] | |
| 283 if self.config.children: | |
| 284 parts.append('group') | |
| 285 if self.config.category == ChromiteTarget.CANARY_TOOLCHAIN: | |
| 286 parts.append('toolchain') | |
| 287 parts.append('canary' if self.config.get('active_waterfall') == 'chromeos' | |
| 288 else 'full') | |
| 289 return ' '.join(parts) | |
| 290 | |
| 291 def _GetLegacySlaveType(self): | 228 def _GetLegacySlaveType(self): |
| 292 if self.config.is_master and not self.config['boards']: | 229 if self.config.is_master and not self.config['boards']: |
| 293 # For boardless release masters, use a wimpy builder. | 230 # For boardless release masters, use a wimpy builder. |
| 294 # | 231 # |
| 295 # NOTE: Currently only implemented on release branch. | 232 # NOTE: Currently only implemented on release branch. |
| 296 if self.branch: | 233 if self.branch: |
| 297 return SlaveType.GCE_WIMPY | 234 return SlaveType.GCE_WIMPY |
| 298 return SlaveType.BAREMETAL | 235 return SlaveType.BAREMETAL |
| 299 | 236 |
| 300 | 237 |
| 301 class SdkBuilderConfig(BuilderConfig): | 238 class SdkBuilderConfig(BuilderConfig): |
| 302 """BuilderConfig for SDK launcher targets.""" | 239 """BuilderConfig for SDK launcher targets.""" |
| 303 | 240 |
| 304 SLAVE_TYPE = SlaveType.GCE | 241 SLAVE_TYPE = SlaveType.GCE |
| 305 COLLAPSE = AlwaysCollapseFunc | 242 COLLAPSE = AlwaysCollapseFunc |
| 306 TIMEOUT = 22 * 3600 # 22 Hours. | 243 TIMEOUT = 22 * 3600 # 22 Hours. |
| 307 | 244 |
| 308 def _GetBuilderName(self): | |
| 309 # Return 'major/minor' (end of toolchain name). | |
| 310 return '%s sdk' % (self.config.base,) | |
| 311 | |
| 312 def _IsExperimental(self): | 245 def _IsExperimental(self): |
| 313 return False | 246 return False |
| 314 | 247 |
| 315 | 248 |
| 316 class ToolchainBuilderConfig(BuilderConfig): | 249 class ToolchainBuilderConfig(BuilderConfig): |
| 317 """BuilderConfig for toolchain launcher targets. | 250 """BuilderConfig for toolchain launcher targets. |
| 318 | 251 |
| 319 Toolchain builders leverage a declared slave class to share slaves between | 252 Toolchain builders leverage a declared slave class to share slaves between |
| 320 them. | 253 them. |
| 321 """ | 254 """ |
| 322 | 255 |
| 323 SLAVE_CLASS = 'toolchain' | 256 SLAVE_CLASS = 'toolchain' |
| 324 | 257 |
| 325 def _GetBuilderName(self): | |
| 326 # Expected toolchain names are: | |
| 327 # - internal-toolchain-VERSION (base='internal', suffix='toolchain-VERSION') | |
| 328 # - toolchain-VERSION (base='', suffix='toolchain-VERSION') | |
| 329 frags = self.config.suffix.split('-') | |
| 330 assert len(frags) == 2, ( | |
| 331 "Unsupported toolchain suffix: %s" % (self.config.suffix,)) | |
| 332 if self.config.name: | |
| 333 return '%s %s (%s)' % (frags[0], frags[1], self.config.base) | |
| 334 return '%s %s' % (frags[0], frags[1]) | |
| 335 | |
| 336 | 258 |
| 337 # Map of cbuildbot target type to configuration class. | 259 # Map of cbuildbot target type to configuration class. |
| 338 # | 260 # |
| 339 # This is an ordered dictionary. The order of items corresponds to the | 261 # This is an ordered dictionary. The order of items corresponds to the |
| 340 # config type's order on the waterfall. | 262 # config type's order on the waterfall. |
| 341 # | 263 # |
| 342 # Any configuration type not mapped should default to the 'None' value. | 264 # Any configuration type not mapped should default to the 'None' value. |
| 343 CONFIG_MAP = OrderedDict(( | 265 CONFIG_MAP = OrderedDict(( |
| 344 (ChromiteTarget.PRE_CQ_LAUNCHER, PreCqLauncherBuilderConfig), | 266 (ChromiteTarget.PRE_CQ_LAUNCHER, PreCqLauncherBuilderConfig), |
| 345 (ChromiteTarget.PALADIN, PaladinBuilderConfig), | 267 (ChromiteTarget.PALADIN, PaladinBuilderConfig), |
| 346 (ChromiteTarget.INCREMENTAL, IncrementalBuilderConfig), | 268 (ChromiteTarget.INCREMENTAL, IncrementalBuilderConfig), |
| 347 (ChromiteTarget.FULL, FullBuilderConfig), | 269 (ChromiteTarget.FULL, FullBuilderConfig), |
| 348 (ChromiteTarget.ASAN, AsanBuilderConfig), | 270 (ChromiteTarget.ASAN, AsanBuilderConfig), |
| 349 (ChromiteTarget.FIRMWARE, FirmwareBuilderConfig), | 271 (ChromiteTarget.FIRMWARE, BuilderConfig), |
| 350 (ChromiteTarget.PFQ, PfqBuilderConfig), | 272 (ChromiteTarget.PFQ, BuilderConfig), |
| 351 (ChromiteTarget.PRE_FLIGHT_BRANCH, PreFlightBranchBuilderConfig), | 273 (ChromiteTarget.PRE_FLIGHT_BRANCH, BuilderConfig), |
| 352 (ChromiteTarget.CANARY, CanaryBuilderConfig), | 274 (ChromiteTarget.CANARY, CanaryBuilderConfig), |
| 353 (ChromiteTarget.SDK, SdkBuilderConfig), | 275 (ChromiteTarget.SDK, SdkBuilderConfig), |
| 354 (ChromiteTarget.CANARY_TOOLCHAIN, CanaryBuilderConfig), | 276 (ChromiteTarget.CANARY_TOOLCHAIN, CanaryBuilderConfig), |
| 355 (ChromiteTarget.TOOLCHAIN, ToolchainBuilderConfig), | 277 (ChromiteTarget.TOOLCHAIN, ToolchainBuilderConfig), |
| 356 (ChromiteTarget.ANDROID_PFQ, PfqBuilderConfig), | 278 (ChromiteTarget.ANDROID_PFQ, BuilderConfig), |
| 357 (None, BuilderConfig), | 279 (None, BuilderConfig), |
| 358 )) | 280 )) |
| 359 | 281 |
| 360 # Determine ordinals for each BuilderTarget type. | 282 # Determine ordinals for each BuilderTarget type. |
| 361 _config_map_keys = CONFIG_MAP.keys() | 283 _config_map_keys = CONFIG_MAP.keys() |
| 362 ORDINALS = dict((k, _config_map_keys.index(k)) | 284 ORDINALS = dict((k, _config_map_keys.index(k)) |
| 363 for k in CONFIG_MAP.iterkeys()) | 285 for k in CONFIG_MAP.iterkeys()) |
| 364 | 286 |
| 365 | 287 |
| 366 def GetBuilderConfig(target, **kwargs): | 288 def GetBuilderConfig(target, **kwargs): |
| (...skipping 20 matching lines...) Expand all Loading... |
| 387 | 309 |
| 388 def IsGCESlave(slavename): | 310 def IsGCESlave(slavename): |
| 389 """Returns (bool): Whether |slavename| is hosted on GCE. | 311 """Returns (bool): Whether |slavename| is hosted on GCE. |
| 390 | 312 |
| 391 Args: | 313 Args: |
| 392 slavename: The hostname of the slave. | 314 slavename: The hostname of the slave. |
| 393 """ | 315 """ |
| 394 # The "-c2" suffix indicates that a builder is in GCE (as opposed to | 316 # The "-c2" suffix indicates that a builder is in GCE (as opposed to |
| 395 # in the Chrome Golo, which has a -m2 suffix). | 317 # in the Chrome Golo, which has a -m2 suffix). |
| 396 return bool(re.search(r'-c\d+$', slavename)) | 318 return bool(re.search(r'-c\d+$', slavename)) |
| OLD | NEW |