forked from MariaDB/buildbot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
master.cfg
270 lines (216 loc) · 13.1 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
# -*- 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 twisted.internet import defer
import sys
import docker
from datetime import timedelta
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)
####### PROJECT IDENTITY
# the 'title' string will appear at the top of this buildbot installation's
# home pages (linked to the 'titleURL').
c['title'] = "MariaDB CI"
c['titleURL'] = "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'] = "https://buildbot.mariadb.org/"
# Custom plugin
# exec(open("grid.py").read())
# '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': 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 = '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
def dpkgDeb():
return ShellCommand(
name="dpkg-scanpackages/sources",
haltOnFailure=True,
command=["sh", "-xc", util.Interpolate("""
mkdir -p debs/
find .. -maxdepth 1 -type f -exec cp {} debs/ \;
cd debs
( dpkg-scanpackages . /dev/null && dpkg-scanpackages --type ddeb . /dev/null )| gzip -9c > Packages.gz
dpkg-scansources . /dev/null | gzip -9c > Sources.gz
cd ..
find debs -type f -exec sha256sum {} \; | sort > sha256sums.txt
""")],
doStepIf=lambda step: hasFiles(step) and savePackage(step),
descriptionDone=util.Interpolate("""
Repository available with: echo "deb [trusted=yes] https://ci.mariadb.org/%(prop:tarbuildnum)s/%(prop:buildername)s/debs ./" >> /etc/apt/sources.list
""")
)
f_quick_build = getQuickBuildFactory(mtrDbPool)
f_rpm_autobake = getRpmAutobakeFactory(mtrDbPool)
## f_deb_autobake
f_deb_autobake = util.BuildFactory()
f_deb_autobake.addStep(steps.ShellCommand(name="Environment details", command=['bash', '-c', 'date -u && uname -a && ulimit -a']))
f_deb_autobake.addStep(steps.SetProperty(property="dockerfile", value=util.Interpolate("%(kw:url)s", url=dockerfile), description="dockerfile"))
f_deb_autobake.addStep(downloadSourceTarball())
f_deb_autobake.addStep(steps.ShellCommand(command=util.Interpolate("tar -xvzf /mnt/packages/%(prop:tarbuildnum)s_%(prop:mariadb_version)s.tar.gz --strip-components=1")))
# 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 binaries
f_deb_autobake.addStep(steps.SetPropertyFromCommand(command="find .. -maxdepth 1 -type f", extract_fn=ls2string))
#f_deb_autobake.addStep(steps.MultipleFileUpload(workersrcs=util.Property('packages'),
# masterdest=util.Interpolate('/srv/buildbot/packages/' + '%(prop:tarbuildnum)s' + '/' + '%(prop:buildername)s'), mode=0o755, url=util.Interpolate('https://ci.mariadb.org/' + "%(prop:tarbuildnum)s" + "/" + '%(prop:buildername)s' + "/"), doStepIf=lambda step: hasFiles(step) and savePackage(step)))
#f_deb_autobake.addStep(steps.ShellCommand(name='save_packages', haltOnFailure=True, command=util.Interpolate('mkdir -p ' + '/packages/' + '%(prop:tarbuildnum)s' + '/' + '%(prop:buildername)s'+ ' && cp ' + '%(prop:packages)s' + ' /packages/' + '%(prop:tarbuildnum)s' + '/' + '%(prop:buildername)s' + '/' + ' && sync /packages/' + '%(prop:tarbuildnum)s'), doStepIf=lambda step: hasFiles(step) and savePackage(step)))
f_deb_autobake.addStep(dpkgDeb())
#f_deb_autobake.addStep(steps.MultipleFileUpload(workersrcs=['debs/Packages.gz', 'debs/Sources.gz'],
# masterdest=util.Interpolate('/srv/buildbot/packages/' + '%(prop:tarbuildnum)s' + '/' + '%(prop:buildername)s'), mode=0o755, url=util.Interpolate('https://ci.mariadb.org/' + "%(prop:tarbuildnum)s" + "/" + '%(prop:buildername)s' + "/"), doStepIf=lambda step: hasFiles(step) and savePackage(step)))
f_deb_autobake.addStep(steps.ShellCommand(name='save_packages', timeout=7200, haltOnFailure=True, command=util.Interpolate('mkdir -p ' + '/packages/' + '%(prop:tarbuildnum)s' + '/' + '%(prop:buildername)s'+ ' && cp -r debs/ sha256sums.txt /packages/' + '%(prop:tarbuildnum)s' + '/' + '%(prop:buildername)s' + '/' + ' && sync /packages/' + '%(prop:tarbuildnum)s'), doStepIf=lambda step: hasFiles(step) and savePackage(step)))
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='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"), "sst_mode": "off"}, doStepIf=lambda step: hasInstall(step) and savePackage(step) and hasFiles(step)))
f_deb_autobake.addStep(steps.Trigger(name='galera-sst-mariabackup', 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"), "sst_mode": "mariabackup"}, doStepIf=lambda step: hasInstall(step) and savePackage(step) and hasFiles(step)))
f_deb_autobake.addStep(steps.Trigger(name='galera-sst-mysqldump', 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"), "sst_mode": "mysqldump"}, doStepIf=lambda step: hasInstall(step) and savePackage(step) and hasFiles(step)))
f_deb_autobake.addStep(steps.Trigger(name='galera-sst-rsync', 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"), "sst_mode": "rsync"}, 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:
c['builders'].append(
util.BuilderConfig(name=builder,
workernames=workers[worker_name],
tags=[os_name],
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
c['builders'].append(
util.BuilderConfig(name=builder + "-" + build_type + "-autobake",
workernames=workers[worker_name],
tags=[os_name, build_type, "autobake"],
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': 'ws://localhost:8085/ws',
'realm': 'realm1',
# valid are: none, critical, error, warn, info, debug, trace
'wamp_debug_level' : 'info'
}