| # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| import datetime |
| import os |
| import traceback |
| |
| # These modules come from $(TOPLEVEL_DIR)/scripts , |
| # which must be in the PYTHONPATH. |
| from buildbot.status.web.baseweb import WebStatus |
| from master import master_utils |
| from master import slaves_list |
| from master.status_push import TryServerHttpStatusPush |
| |
| import skia_notifier |
| |
| # This module comes from $(TOPLEVEL_DIR)/site_config , |
| # which must be in the PYTHONPATH. |
| import config |
| |
| # These modules come from the local directory. |
| from skia_master_scripts import monkeypatches |
| from skia_master_scripts import utils |
| from webstatus import buildstatus |
| from webstatus import console |
| from webstatus import waterfall |
| import builder_name_schema |
| import master_source_cfg |
| import skia_vars |
| |
| |
| c = BuildmasterConfig = {} |
| c['change_source'] = [] |
| c['schedulers'] = [] |
| c['builders'] = [] |
| c['status'] = [] |
| |
| |
| def GetSkiaGateKeeper(): |
| """Returns the GateKeeper used by Skia. |
| |
| If any of the bots in the Build category (compile bots) fails the specified |
| build steps, then the tree is automatically closed and an email is sent about |
| the tree closure. |
| |
| Note: The tree is not closed if the last run of the builder had the same |
| failing step as the current run. The tree is also not closed if the |
| gatekeeper closed the tree less than 10 mins ago. |
| """ |
| # Run the gatekeeper only on the following categories and build steps. |
| categories_steps = { |
| builder_name_schema.BUILDER_ROLE_BUILD: |
| skia_vars.GetGlobalVariable('gatekeeper_steps') |
| } |
| return monkeypatches.SkiaGateKeeper( |
| fromaddr=config.Master.Skia.from_address, |
| categories_steps=categories_steps, |
| exclusions={}, |
| subject='buildbot %(result)s in %(projectName)s on %(builder)s, ' |
| 'revision %(revision)s', |
| extraRecipients=config.Master.Skia.tree_closing_notification_recipients, |
| lookup=master_utils.FilterDomain(), |
| forgiving_steps=[], |
| useTls=config.Master.smtp_use_tls, |
| smtpUser=config.Master.smtp_user, |
| smtpPassword=SMTP_PASSWORD, |
| smtpPort=config.Master.smtp_port, |
| relayhost=config.Master.smtp_server, |
| tree_status_url=config.Master.Skia.tree_status_url, |
| check_revisions=True) |
| |
| |
| ActiveMaster = config.Master.set_active_master(os.environ.get('TESTING_MASTER', |
| 'Skia')) |
| |
| ActiveMaster.running_revision = utils.get_current_revision() |
| ActiveMaster.launch_datetime = datetime.datetime.utcnow() |
| |
| # Load the builder configuration. |
| ActiveMaster.create_schedulers_and_builders(c) |
| |
| # Load the source configuration. |
| master_source_cfg.Update(config, ActiveMaster, c) |
| |
| # Associate the slaves to the manual builders. The configuration is in |
| # slaves.cfg. |
| slaves = slaves_list.SlavesList('slaves.cfg', ActiveMaster.__class__.__name__) |
| |
| # The SMTP password is only required if the master is a production host. |
| if ActiveMaster.is_production_host: |
| try: |
| SMTP_PASSWORD = open('.skia_buildbots_password').readline().strip() |
| except IOError, e: |
| traceback.print_exc() |
| raise Exception('Please create a .skia_buildbots_password file in the ' |
| 'master directory if the master needs to run as a ' |
| 'production host (Password is in valentine).') |
| else: |
| SMTP_PASSWORD = 'dummy_password' |
| |
| |
| for builder in c['builders']: |
| builder['slavenames'] = slaves.GetSlavesName(builder=builder['name']) |
| |
| |
| # The 'slaves' list defines the set of allowable buildslaves. List all the |
| # slaves registered to a builder. Remove dupes. |
| c['slaves'] = master_utils.AutoSetupSlaves(c['builders'], |
| config.Master.GetBotPassword()) |
| master_utils.VerifySetup(c, slaves) |
| |
| # For each slave instance, add the key/value pairs in its associated dictionary, |
| # defined in slaves.cfg, to its build properties. This allows us to access |
| # extra attributes defined in slaves.cfg using WithProperties. |
| for slave_instance in c['slaves']: |
| for slave_dict in slaves.GetSlaves(): |
| if slave_dict['hostname'] == slave_instance.identity()[0]: |
| slave_instance.properties.update(slave_dict, 'BuildSlave') |
| break |
| |
| # Adds common status and tools to this master. |
| c['buildbotURL'] = 'http://%s:%d/' % ( |
| ActiveMaster.master_host, ActiveMaster.master_port_alt) |
| master_utils.AutoSetupMaster(c, ActiveMaster, mail_notifier=False) |
| |
| # Reduce the number of on-disk builds and logs, to save disk space. |
| c['buildHorizon'] = 400 |
| c['logHorizon'] = 200 |
| |
| # Replace the default console and waterfall pages with our overrides and add |
| # the trybot and failures waterfalls. |
| for status in c['status']: |
| if issubclass(status.__class__, WebStatus): |
| status.putChild('console', console.ConsoleStatusResource()) |
| status.putChild('console_json', |
| console.ConsoleJsonStatusResource(status=status, |
| order_by_time=True)) |
| status.putChild('waterfall', waterfall.WaterfallStatusResource()) |
| status.putChild('trybots', waterfall.TrybotStatusResource()) |
| status.putChild('failures', waterfall.FailureWaterfallStatusResource()) |
| status.putChild('buildstatus', buildstatus.BuildStatusStatusResource()) |
| |
| |
| # Add our own mail notifier (only in production mode): |
| # email the committer (and skia-commit list) only if it changed test results |
| if ActiveMaster.is_production_host: |
| mail_notifier = skia_notifier.SkiaNotifier( |
| fromaddr=ActiveMaster.from_address, |
| sendToInterestedUsers=True, |
| extraRecipients=['skia-commit@googlegroups.com'], |
| useTls=config.Master.smtp_use_tls, |
| smtpUser=config.Master.smtp_user, |
| smtpPassword=SMTP_PASSWORD, |
| mode='change', |
| smtpPort=config.Master.smtp_port, |
| relayhost=config.Master.smtp_server, |
| lookup=master_utils.FilterDomain( |
| permitted_domains=config.Master.permitted_domains)) |
| c['status'].append(mail_notifier) |
| |
| # Try job result emails. |
| c['status'].append(skia_notifier.SkiaTryMailNotifier( |
| fromaddr=ActiveMaster.from_address, |
| # Subject is overridden in skia_notifier.SkiaTryMailNotifier.buildMessage |
| subject='try %(result)s for changelist "%(reason)s" at %(timestamp)s', |
| mode='all', |
| lookup=master_utils.FilterDomain( |
| permitted_domains=config.Master.permitted_domains), |
| useTls=config.Master.smtp_use_tls, |
| smtpUser=config.Master.smtp_user, |
| smtpPassword=SMTP_PASSWORD, |
| smtpPort=config.Master.smtp_port, |
| relayhost=config.Master.smtp_server, |
| footer="""Skia Trybot documentation: <a href= |
| "https://sites.google.com/site/skiadocs/developer-documentation/skia-trybots"> |
| https://sites.google.com/site/skiadocs/developer-documentation/skia-trybots</a> |
| <br/></body></html>""")) |
| |
| c['status'].append( |
| TryServerHttpStatusPush(serverUrl=ActiveMaster.code_review_site)) |
| |
| # Add the gatekeeper |
| c['status'].append(GetSkiaGateKeeper()) |
| |
| |
| c['mergeRequests'] = utils.CanMergeBuildRequests |