blob: d0be3070e75aeef5eaf2e5d1b6c853f5d5b40e29 [file] [log] [blame]
import json
import os
import sys
from buildbot.changes.pb import PBChangeSource
from buildbot.plugins import util
from datetime import timedelta
from loadConfig import *
from buildbot.www.hooks.github import GitHubEventHandler
def load_password(name, default=None):
if os.getenv(name):
return os.getenv(name)
try:
passwords = json.load(open('passwords.json'))
return passwords.get(name, default)
except Exception as e:
print('Error in finding {} in passwords.json'.format(name))
return default
# This is work-around for https://bugs.webkit.org/show_bug.cgi?id=222361
from buildbot.process.buildstep import BuildStep
BuildStep.warn_deprecated_if_oldstyle_subclass = lambda self, name: None
is_test_mode_enabled = os.getenv('BUILDBOT_PRODUCTION') is None
c = BuildmasterConfig = {}
c['change_source'] = PBChangeSource(port=16000)
# permissions for WebStatus
c['www'] = dict(port='tcp:8710:interface=127.0.0.1', plugins=dict(waterfall_view={}, console_view={}, grid_view={}), allowed_origins=["*"])
c['www']['ui_default_config'] = {
'Builders.show_workers_name': True,
'Builders.buildFetchLimit': 1000,
'Workers.showWorkerBuilders': True,
}
if not is_test_mode_enabled:
credentials = load_password('BUILD_WEBKIT_CREDENTIALS')
if not credentials:
print('BUILD_WEBKIT credentials not found. Please ensure BUILD_WEBKIT_CREDENTIALS is configured either in env variables or in passwords.json')
sys.exit(1)
# See https://docs.buildbot.net/2.10.0/manual/configuration/www.html#example-configs
authz = util.Authz(
allowRules=[util.AnyControlEndpointMatcher(role="admin")],
roleMatchers=[util.RolesFromEmails(admin=list(credentials.keys()))]
)
auth = util.UserPasswordAuth(credentials)
c['www']['auth'] = auth
c['www']['authz'] = authz
c['www']['change_hook_dialects'] = dict(
github={
'class': GitHubEventHandler,
'secret': load_password('GITHUB_HOOK_SECRET'),
'token': load_password('GITHUB_COM_ACCESS_TOKEN'),
},
)
c['protocols'] = {'pb': {'port': 17000}}
c['projectName'] = 'WebKit'
c['projectURL'] = 'https://webkit.org'
if is_test_mode_enabled:
c['buildbotURL'] = 'http://localhost:8710/'
else:
c['buildbotURL'] = 'https://build.webkit.org/'
db_url = load_password('DB_URL')
db_name = load_password('DB_NAME')
db_username = load_password('DB_USERNAME')
db_password = load_password('DB_PASSWORD')
if None in [db_url, db_name, db_username, db_password]:
print('\n\nERROR: Database information missing from passwords.json.\n')
sys.exit(1)
# See https://docs.buildbot.net/2.10.0/manual/configuration/global.html#database-specification
c['db_url'] = 'postgresql://{}:{}@{}/{}'.format(db_username, db_password, db_url, db_name)
# configure a janitor to delete old logs
c['configurators'] = [util.JanitorConfigurator(logHorizon=timedelta(weeks=26), hour='1', dayOfWeek='*')]
c['buildCacheSize'] = 60
c['logCompressionMethod'] = 'lz4'
c['buildbotNetUsageData'] = None
loadBuilderConfig(c, is_test_mode_enabled=is_test_mode_enabled)