aboutsummaryrefslogtreecommitdiffstats
# -*- python -*-
# ex: set filetype=python:

import os
import imp
import pkg_resources

from buildbot.plugins import *
from buildbot.plugins import db
from yoctoabb import builders, config, schedulers, workers, services, www

#
# Prepare to feel ill
#
# Buildbot uses plugins from pkg_resources, i.e. things which are installed
# For the Yocto autobuilder, we want the plugin from this repo/directory.
#
# Firstly we therefore have to create a dummy pkg_resources entry/distribution
# which we add into the global working set. Ugly. It gets worse.
#
# The get_plugins('www') call from www/service.py happens before this
# master.cfg file is parsed, which means our plugin won't be found. There
# is no API to rescan for plugins. We therefore so some horrible internal
# API monkey patching to add ourselves into the internal list.

# Create a fake distribution to insert into the global working_set
us = os.path.dirname(os.path.realpath(__file__))
d = pkg_resources.Distribution(us + "/yocto_console_view", metadata=None, project_name="yocto_console_view", version="0.0.1")

# Create the fake entry point definition
ep = pkg_resources.EntryPoint.parse("yocto_console_view = yoctoabb.yocto_console_view.yocto_console_view:ep", dist=d)

# Add the mapping to the fake EntryPoint
d._ep_map = {'buildbot.www': {'yocto_console_view': ep}}

# Add the fake distribution to the global working_set
pkg_resources.working_set.add(d)

# Now monkey patch us into buildbot's plugins DB
for entry in pkg_resources.iter_entry_points('buildbot.www'):
    if entry.name == "yocto_console_view":
        plugindb = db._DB._namespaces['www']
        plugindb._real_tree.add(entry.name, db._PluginEntry('buildbot.www', entry, plugindb._load_entry))


# supports re-loading configuration with buildbot sighup, meaning we can change
# configuration without having to restart buildbot.
# Note: code modules (in lib/, steps/ and reporters/) are not reloaded with a
# buildbot sighup
imp.reload(config)
imp.reload(builders)
imp.reload(schedulers)
imp.reload(workers)
imp.reload(services)
imp.reload(www)

c = BuildmasterConfig = {}

# Disable usage reporting
c['buildbotNetUsageData'] = None
c['protocols'] = {'pb': {'port': 9989}}
c['db'] = {'db_url' : "sqlite:///state.sqlite",}

# Allows UI to resolve poky git hashes
c['change_source'] = [
    changes.GitPoller(repourl='https://git.openembedded.org/bitbake', branches=True, project="bitbake", pollInterval=10*60),
    changes.GitPoller(repourl='https://git.yoctoproject.org/git/poky', branches=True, pollInterval=10*60),
    changes.GitPoller(repourl='https://git.yoctoproject.org/git/poky-contrib', branches=True, pollInterval=10*60),
    changes.GitPoller(repourl='https://git.yoctoproject.org/git/yocto-docs', branches=True, project="yocto-docs", pollInterval=10*60)
]

def codebaseGenerator(chdict):
    if "yocto-docs" in chdict['repository']:
        return "yocto-docs"
    elif "bitbake" in chdict['repository']:
        return "bitbake"
    return ''

c['codebaseGenerator'] = codebaseGenerator

# Items which are common to Yocto Project autobuilder deployments using the
# yocto-autobuilder-helper scripts
c['schedulers'] = schedulers.schedulers
c['builders'] = builders.builders
c['services'] = services.services
c['www'] = www.www

# These items are specific to an individual AB deployment
c['workers'] = workers.workers

# This enables our prioritizeBuilders function from builders.py.
# Builders such as buildperf-*,
# oe-selftest-*, and reproducible-* will be assigned (if possible)
# before other builders since their possible worker lists are smaller
c['prioritizeBuilders'] = builders.prioritizeBuilders

c['title'] = "Yocto Autobuilder"
c['titleURL'] = "https://autobuilder.yoctoproject.org/main/"
# visible location for internal web server
c['buildbotURL'] = "https://autobuilder.yoctoproject.org/main/"

# How to enable profiling
#c['www']['plugins']['profiler'] = True