Skip to content

Commit

Permalink
Create base master config
Browse files Browse the repository at this point in the history
This will remove code duplication across master.cfg files.
  • Loading branch information
cvicentiu committed Jan 12, 2025
1 parent b627f53 commit cb7f0fb
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 60 deletions.
70 changes: 10 additions & 60 deletions master.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ from collections import defaultdict

import yaml

from buildbot.plugins import reporters, secrets, steps, util
from buildbot.plugins import steps, util
from buildbot.process.properties import Property
from common_factories import (
getQuickBuildFactory,
Expand All @@ -20,7 +20,7 @@ from constants import (
SAVED_PACKAGE_BRANCHES,
)
from locks import getLocks
from schedulers_definition import SCHEDULERS
from master_common import base_master_config
from utils import (
canStartBuild,
createDebRepo,
Expand Down Expand Up @@ -52,63 +52,12 @@ with open(os.path.join(cfg_dir, "master-private.cfg"), "r") as file:

# This is the dictionary that the buildmaster pays attention to. We also use
# a shorter alias to save typing.
c = BuildmasterConfig = {
#######
# PROJECT IDENTITY
#######
# the 'title' string will appear at the top of this buildbot installation's
"title": os.getenv("TITLE", default="MariaDB CI"),
# home pages (linked to the 'titleURL').
"titleURL": os.getenv("TITLE_URL", default="https://github.com/MariaDB/server"),
# the 'buildbotURL' string should point to the location where the
# buildbot's internal web server is visible. This typically uses the port
# number set in the 'www' entry below, but with an externally-visible host
# name which the buildbot cannot figure out without some help.
"buildbotURL": os.getenv(
"BUILDMASTER_URL", default="https://buildbot.mariadb.org/"
),
# 'services' is a list of BuildbotService items like reporter targets. The
# status of each build will be pushed to these targets. buildbot/reporters/*.py
# has a variety to choose from, like IRC bots.
"services": [
reporters.GitHubStatusPush(
token=config["private"]["gh_mdbci"]["access_token"],
context=util.Interpolate("buildbot/%(prop:buildername)s"),
startDescription="Build started.",
endDescription="Build done.",
verbose=True,
builders=GITHUB_STATUS_BUILDERS,
)
],
"secretsProviders": [
secrets.SecretInAFile(dirname=os.environ["MASTER_CREDENTIALS_DIR"])
],
# 'protocols' contains information about protocols which master will use
# for communicating with workers. You must define at least 'port' option
# that workers could connect to your master with this protocol.
# 'port' must match the value configured into the workers (with their
# --master option)
"protocols": {"pb": {"port": os.environ["PORT"]}},
# This specifies what database buildbot uses to store its state.
"db": {"db_url": config["private"]["db_url"]},
# Disable net usage reports from being sent to buildbot.net
"buildbotNetUsageData": None,
# Configure the Schedulers, which decide how to react to incoming changes.
"schedulers": SCHEDULERS,
"logEncoding": "utf-8",
"multiMaster": True,
"mq": {
# Need to enable multimaster aware mq. Wamp is the only option for now.
"type": "wamp",
"router_url": os.getenv("MQ_ROUTER_URL", default="ws://localhost:8085/ws"),
"realm": "realm1",
# valid are: none, critical, error, warn, info, debug, trace
"wamp_debug_level": "info",
},
}

####### DB URL
c = BuildmasterConfig = base_master_config(config)


#######
# DB URL
#######
mtrDbPool = util.EqConnectionPool(
"MySQLdb",
config["private"]["db_host"],
Expand All @@ -117,7 +66,9 @@ mtrDbPool = util.EqConnectionPool(
config["private"]["db_mtr_db"],
)

####### WORKERS
#########
# WORKERS
#########

# The 'workers' list defines the set of recognized workers. Each element is
# a Worker object, specifying a unique worker name and password. The same
Expand Down Expand Up @@ -168,7 +119,6 @@ for w_name in master_config["workers"]:
f_quick_build = getQuickBuildFactory("nm", mtrDbPool)
f_rpm_autobake = getRpmAutobakeFactory(mtrDbPool)

## f_deb_autobake
f_deb_autobake = util.BuildFactory()
f_deb_autobake.addStep(printEnv())
f_deb_autobake.addStep(
Expand Down
79 changes: 79 additions & 0 deletions master_common.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import os

from buildbot.plugins import reporters, secrets, util
from constants import GITHUB_STATUS_BUILDERS
from schedulers_definition import SCHEDULERS


def base_master_config(
config: dict,
title=os.environ["TITLE"],
title_url=os.environ["TITLE_URL"],
buildbot_url=os.environ["BUILDMASTER_URL"],
secrets_provider_file=os.environ["MASTER_CREDENTIALS_DIR"],
master_port=os.environ["PORT"],
mq_router_url=os.environ["MQ_ROUTER_URL"],
):
# TODO(cvicentiu) either move this to environ or all other params to config
# file.
github_access_token = (config["private"]["gh_mdbci"]["access_token"],)
db_url = config["private"]["db_url"]

return {
#######
# PROJECT IDENTITY
#######
# the 'title' string will appear at the top of this buildbot
# installation's
"title": title,
# home pages (linked to the 'titleURL').
"titleURL": title_url,
# the 'buildbotURL' string should point to the location where the
# buildbot's internal web server is visible. This typically uses the
# port number set in the 'www' entry below, but with an
# externally-visible host name which the buildbot cannot figure out
# without some help.
"buildbotURL": buildbot_url,
# 'services' is a list of BuildbotService items like reporter targets.
# The status of each build will be pushed to these targets.
# buildbot/reporters/*.py has a variety to choose from, like IRC bots.
"services": [
reporters.GitHubStatusPush(
token=github_access_token,
context=util.Interpolate("buildbot/%(prop:buildername)s"),
startDescription="Build started.",
endDescription="Build done.",
verbose=True,
builders=GITHUB_STATUS_BUILDERS,
)
],
"secretsProviders": [secrets.SecretInAFile(dirname=secrets_provider_file)],
# 'protocols' contains information about protocols which master will
# use for communicating with workers. You must define at least 'port'
# option that workers could connect to your master with this protocol.
# 'port' must match the value configured into the workers (with their
# --master option)
"protocols": {
"pb": {"port": master_port},
},
# This specifies what database buildbot uses to store its state.
"db": {
"db_url": db_url,
},
# Disable net usage reports from being sent to buildbot.net
"buildbotNetUsageData": None,
# Configure the Schedulers, which decide how to react to incoming
# changes.
"schedulers": SCHEDULERS,
"logEncoding": "utf-8",
"multiMaster": True,
"mq": {
# Need to enable multimaster aware mq. Wamp is the only option for
# now.
"type": "wamp",
"router_url": mq_router_url,
"realm": "realm1",
# valid are: none, critical, error, warn, info, debug, trace
"wamp_debug_level": "info",
},
}

0 comments on commit cb7f0fb

Please sign in to comment.