-
Notifications
You must be signed in to change notification settings - Fork 25
/
master.cfg
376 lines (322 loc) · 11.3 KB
/
master.cfg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
# -*- python -*-
# ex: set filetype=python:
from buildbot.plugins import *
from buildbot.process.properties import Property, Properties
from buildbot.steps.shell import ShellCommand, Compile, Test, SetPropertyFromCommand
from buildbot.steps.mtrlogobserver import MTR, MtrLogObserver
from buildbot.steps.source.github import GitHub
from buildbot.process.remotecommand import RemoteCommand
from datetime import timedelta
from twisted.internet import defer
import docker
import os
import sys
sys.setrecursionlimit(10000)
sys.path.insert(0, "/srv/buildbot/master")
from common_factories import *
from constants import *
from locks import *
from schedulers_definition import *
from utils import *
with open("master-config.yaml", "r") as f:
master_config = yaml.safe_load(f)
# This is the dictionary that the buildmaster pays attention to. We also use
# a shorter alias to save typing.
c = BuildmasterConfig = {}
# Load the slave, database passwords and 3rd-party tokens from an external private file, so
# that the rest of the configuration can be public.
config = {"private": {}}
exec(open("master-private.cfg").read(), config, {})
####### BUILDBOT SERVICES
# '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.
c["services"] = []
context = util.Interpolate("buildbot/%(prop:buildername)s")
gs = reporters.GitHubStatusPush(
token=config["private"]["gh_mdbci"]["access_token"],
context=context,
startDescription="Build started.",
endDescription="Build done.",
verbose=True,
builders=github_status_builders,
)
c["services"].append(gs)
c['secretsProviders'] = [secrets.SecretInAFile(dirname="/srv/buildbot/master/master-credential-provider")]
####### PROJECT IDENTITY
# the 'title' string will appear at the top of this buildbot installation's
# home pages (linked to the 'titleURL').
c["title"] = os.getenv("TITLE", default="MariaDB CI")
c["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.
c["buildbotURL"] = os.getenv("BUILDMASTER_URL", default="https://buildbot.mariadb.org/")
# '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)
c["protocols"] = {"pb": {"port": os.getenv("PORT", default=master_config["port"])}}
####### DB URL
c["db"] = {
# This specifies what database buildbot uses to store its state.
"db_url": config["private"]["db_url"]
}
mtrDbPool = util.EqConnectionPool(
"MySQLdb",
config["private"]["db_host"],
config["private"]["db_user"],
config["private"]["db_password"],
config["private"]["db_mtr_db"],
)
####### Disable net usage reports from being sent to buildbot.net
c["buildbotNetUsageData"] = None
####### SCHEDULERS
# Configure the Schedulers, which decide how to react to incoming changes.
c["schedulers"] = getSchedulers()
####### 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
# worker name and password must be configured on the worker.
c["workers"] = []
# Docker workers
workers = {}
def addWorker(
worker_name_prefix,
worker_id,
worker_type,
dockerfile,
jobs=5,
save_packages=False,
shm_size="15G",
):
name, instance = createWorker(
worker_name_prefix,
worker_id,
worker_type,
dockerfile,
jobs,
save_packages,
shm_size,
)
if name[0] not in workers:
workers[name[0]] = [name[1]]
else:
workers[name[0]].append(name[1])
c["workers"].append(instance)
for w_name in master_config["workers"]:
jobs = 7
for builder in master_config["builders"]:
worker_name = w_name[:-1]
worker_id = w_name[-1]
os_name = "-".join(builder.split("-")[1:])
image_tag = "".join(os_name.split("-"))
# Skip s390x non-SLES builders on SLES host (bbw2)
if ("s390x" in builder) and (worker_id == "2") and ("sles" not in os_name):
continue
if image_tag.startswith("ubuntu"):
image_tag = image_tag[:-2] + "." + image_tag[-2:]
quay_name = os.getenv("CONTAINER_REGISTRY_URL", default="quay.io/mariadb-foundation/bb-worker:") + image_tag
if builder.startswith("x86"):
os_name += "-i386"
quay_name += "-386"
addWorker(
worker_name,
worker_id,
"-" + os_name,
quay_name,
jobs=jobs,
save_packages=True,
)
####### FACTORY CODE
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(
steps.SetProperty(
property="dockerfile",
value=util.Interpolate("%(kw:url)s", url=dockerfile),
description="dockerfile",
)
)
f_deb_autobake.addStep(getSourceTarball())
# build steps
f_deb_autobake.addStep(
steps.Compile(
logfiles={"CMakeCache.txt": "./builddir/CMakeCache.txt"},
command=["debian/autobake-deb.sh"],
env={
"CCACHE_DIR": "/mnt/ccache",
"DEB_BUILD_OPTIONS": util.Interpolate(
"parallel=%(kw:jobs)s",
jobs=util.Property("jobs", default="$(getconf _NPROCESSORS_ONLN)"),
),
},
description="autobake-deb.sh",
)
)
# upload artifacts
f_deb_autobake.addStep(
steps.SetPropertyFromCommand(
command="find .. -maxdepth 1 -type f", extract_fn=ls2string
)
)
f_deb_autobake.addStep(createDebRepo())
f_deb_autobake.addStep(uploadDebArtifacts())
f_deb_autobake.addStep(
steps.Trigger(
name="dockerlibrary",
schedulerNames=["s_dockerlibrary"],
waitForFinish=False,
updateSourceStamp=False,
set_properties={
"tarbuildnum": Property("tarbuildnum"),
"mariadb_version": Property("mariadb_version"),
"master_branch": Property("master_branch"),
"parentbuildername": Property("buildername"),
},
doStepIf=lambda step: hasDockerLibrary(step),
)
)
f_deb_autobake.addStep(
steps.Trigger(
name="release preparation",
schedulerNames=["s_release_prep"],
waitForFinish=True,
updateSourceStamp=False,
set_properties={
"tarbuildnum": Property("tarbuildnum"),
"mariadb_version": Property("mariadb_version"),
"master_branch": Property("master_branch"),
"parentbuildername": Property("buildername"),
},
doStepIf=lambda step: savePackage(step),
)
)
f_deb_autobake.addStep(
steps.Trigger(
name="install",
schedulerNames=["s_install"],
waitForFinish=False,
updateSourceStamp=False,
set_properties={
"tarbuildnum": Property("tarbuildnum"),
"mariadb_version": Property("mariadb_version"),
"master_branch": Property("master_branch"),
"parentbuildername": Property("buildername"),
},
doStepIf=lambda step: hasInstall(step) and savePackage(step) and hasFiles(step),
)
)
f_deb_autobake.addStep(
steps.Trigger(
name="major-minor-upgrade",
schedulerNames=["s_upgrade"],
waitForFinish=False,
updateSourceStamp=False,
set_properties={
"tarbuildnum": Property("tarbuildnum"),
"mariadb_version": Property("mariadb_version"),
"master_branch": Property("master_branch"),
"parentbuildername": Property("buildername"),
},
doStepIf=lambda step: hasUpgrade(step) and savePackage(step) and hasFiles(step),
)
)
f_deb_autobake.addStep(
steps.ShellCommand(
name="cleanup", command="rm -r * .* 2> /dev/null || true", alwaysRun=True
)
)
####### BUILDERS LIST
c["builders"] = []
for builder in master_config["builders"]:
splits = builder.split("-")
arch = splits[0]
os_name = "-".join(splits[1:])
mtr_additional_args = None
if "mtr_additional_args" in os_info[os_name]:
if arch in os_info[os_name]["mtr_additional_args"]:
mtr_additional_args = os_info[os_name]["mtr_additional_args"][arch]
if arch == "amd64":
arch = "x64"
worker_name = arch + "-bbw-docker-" + os_name
if arch == "x86":
worker_name = "x64-bbw-docker-" + os_name + "-i386"
build_type = os_info[os_name]["type"]
# Add builder only if it's not a protected branches one
if builder not in github_status_builders:
tags = [os_name]
if arch == "s390x" and builder in builders_galera_mtr:
tags += ["experimental"]
if "sid" in builder or "stream-9" in builder:
tags += ["bleeding-edge"]
c["builders"].append(
util.BuilderConfig(
name=builder,
workernames=workers[worker_name],
tags=tags,
collapseRequests=True,
nextBuild=nextBuild,
canStartBuild=canStartBuild,
locks=getLocks,
factory=f_quick_build,
)
)
factory_instance = f_deb_autobake
properties = {}
if arch == "ppc64le":
properties["verbose_build"] = "VERBOSE=1"
if mtr_additional_args is not None:
properties["mtr_additional_args"] = mtr_additional_args
if build_type == "rpm":
properties["rpm_type"] = "".join(os_name.split("-"))
factory_instance = f_rpm_autobake
tags = [os_name, build_type, "autobake"]
# From mariadb.org-tools/release/prep - under
# Dirs for buildbot.mariadb.org
if builder in [
"aarch64-openeuler-2403",
"amd64-openeuler-2403",
"s390x-ubuntu-2004",
"s390x-rhel-8",
"s390x-sles-15",
"ppc64le-rhel-9",
"s390x-rhel-9",
"ppc64le-ubuntu-2204",
"s390x-ubuntu-2204",
"amd64-debian-sid",
"aarch64-debian-sid",
"ppc64le-debian-sid",
"amd64-opensuse-1505",
"amd64-opensuse-1506",
"amd64-sles-1505",
"s390x-sles-1505",
]:
tags += ["release_packages"]
c["builders"].append(
util.BuilderConfig(
name=builder + "-" + build_type + "-autobake",
workernames=workers[worker_name],
tags=tags,
collapseRequests=True,
nextBuild=nextBuild,
canStartBuild=canStartBuild,
locks=getLocks,
properties=properties,
factory=factory_instance,
)
)
c["logEncoding"] = "utf-8"
c["multiMaster"] = True
c["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",
}