-
Notifications
You must be signed in to change notification settings - Fork 1
/
master.cfg
269 lines (221 loc) · 11.8 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:
import os
from buildbot.plugins import *
from buildbot.process.properties import Interpolate
from datetime import datetime
# This is the buildmaster config file. It must be installed as
# 'master.cfg' in your buildmaster's base directory.
# Custom variables
REPO_URL="https://github.com/lquinet/meta-fullmetalupdate-extra.git"
SUPPORTED_MACHINES_ROCKO=["imx6qdlsabresd", "raspberrypi3"]
SUPPORTED_MACHINES_THUD=["imx8mqevk", "stm32mp1-disco"]
SUPPORTED_MACHINES_WARRIOR=["imx8mqevk"]
BRANCH_MACHINE_PAIRS = {
"rocko" : SUPPORTED_MACHINES_ROCKO,
"thud" : SUPPORTED_MACHINES_THUD,
"warrior" : SUPPORTED_MACHINES_WARRIOR,
}
YOCTO_REPO_URL="https://github.com/lquinet/fullmetalupdate-yocto-demo.git"
# This is the dictionary that the buildmaster pays attention to. We also use
# a shorter alias to save typing.
c = BuildmasterConfig = {}
####### 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'] = [worker.Worker("example-worker", 'pass', max_builds=1)] # limit Concurrency to 1
if 'BUILDBOT_MQ_URL' in os.environ:
c['mq'] = {
'type' : 'wamp',
'router_url': os.environ['BUILDBOT_MQ_URL'],
'realm': os.environ.get('BUILDBOT_MQ_REALM', 'buildbot').decode('utf-8'),
'debug' : 'BUILDBOT_MQ_DEBUG' in os.environ,
'debug_websockets' : 'BUILDBOT_MQ_DEBUG' in os.environ,
'debug_lowlevel' : 'BUILDBOT_MQ_DEBUG' in os.environ,
}
# '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.environ.get("BUILDBOT_WORKER_PORT", 9989)}}
####### CHANGESOURCES
# the 'change_source' setting tells the buildmaster how it should find out
# about source code changes.
gitpoller = changes.GitPoller(
repourl=REPO_URL,
workdir='gitpoller-workdir',
branches=True,
pollInterval=60) # poll all branches from meta-fullmetalupdate-extra repo
c['change_source'] = [gitpoller]
####### BUILDERS
# The 'builders' list defines the Builders, which tell Buildbot how to perform a build:
# what steps, and which workers can execute them. Note that any particular build will
# only take place on one worker.
c['builders'] = []
BUILDBOT_WORKER_WORKDIR=os.environ.get("BUILDBOT_WORKER_WORKDIR", "/tmp/buildbot")
# Create all builders depending of BRANCH_MACHINE_PAIRS
for branch, machines in BRANCH_MACHINE_PAIRS.items():
for machine in machines:
machine_branch = "{}_{}".format(machine, branch)
# Create steps list
all_steps = [
# create directory for the branch/machine pair
steps.ShellCommand(name="mkdir -p {}".format(machine_branch),
command="mkdir -p {}".format(machine_branch),
description="mkdir -p {}".format(machine_branch),
workdir="{}".format(BUILDBOT_WORKER_WORKDIR)),
# clone fullmetalupdate-yocto-demo
steps.ShellCommand(name="clone fullmetalupdate-yocto-demo",
command="rm -rf fullmetalupdate-yocto-demo \
; git clone {} \
&& mkdir -p fullmetalupdate-yocto-demo/build".format(YOCTO_REPO_URL),
haltOnFailure=True,
description="clone fullmetalupdate-yocto-demo",
workdir="{}/{}".format(BUILDBOT_WORKER_WORKDIR, machine_branch)),
# Launch ConfigureBuild script
steps.ShellCommand(name="ConfigureBuild",
command="./ConfigureBuild.sh",
haltOnFailure=True,
description="ConfigureBuild",
workdir="{}/{}/fullmetalupdate-yocto-demo".format(BUILDBOT_WORKER_WORKDIR, machine_branch)),
# Launch StartBuild.sh sync
steps.ShellCommand(name="./StartBuild.sh sync {} {} dev".format(machine, branch),
command="./StartBuild.sh sync {} {} dev".format(machine, branch),
haltOnFailure=True,
description="./StartBuild.sh sync {} {} dev".format(machine, branch),
workdir="{}/{}/fullmetalupdate-yocto-demo".format(BUILDBOT_WORKER_WORKDIR, machine_branch)),
# Launch StartBuild.sh all
steps.ShellCommand(name="./StartBuild.sh all",
command="./StartBuild.sh all",
haltOnFailure=True,
description="./StartBuild.sh all",
workdir="{}/{}/fullmetalupdate-yocto-demo".format(BUILDBOT_WORKER_WORKDIR, machine_branch)),
# Copy image file
steps.ShellCommand(name="Copy image",
command="mkdir -p images \
&& cp fullmetalupdate-yocto-demo/build/yocto/build/tmp/fullmetalupdate-os/deploy/images/{}/fullmetalupdate-os-package-{}.wic \
images/fullmetalupdate-os-package-{}_{}.wic".format(machine, machine, machine, "$(date -u +\"%FT%H%M%SZ\")"),
haltOnFailure=True,
description="Copy image",
workdir="{}/{}".format(BUILDBOT_WORKER_WORKDIR, machine_branch)),
# Flash image
steps.ShellCommand(name="Flash image",
command="dd if=$(ls -t | head -1) of=$SD_CARD_DEV_PATH bs=1M iflag=fullblock oflag=direct conv=fsync && sync",
haltOnFailure=True,
description="Flash image",
workdir="{}/{}/images".format(BUILDBOT_WORKER_WORKDIR, machine_branch)),
]
# build factory from steps
factory = util.BuildFactory(all_steps)
# append new builder
c['builders'].append(util.BuilderConfig(name="{}_builder".format(machine_branch),
workernames=["example-worker"],
factory=factory))
# Create test builders
for branch, machines in BRANCH_MACHINE_PAIRS.items(): # first loop for branches
for machine in machines: # second loop for machines
machine_branch = "{}_{}".format(machine, branch)
# Create steps list
all_steps = [
# Launch StartBuild.sh all
steps.ShellCommand(name="./StartBuild.sh all",
command="./StartBuild.sh all",
haltOnFailure=True,
description="./StartBuild.sh all",
workdir="{}/{}/fullmetalupdate-yocto-demo".format(BUILDBOT_WORKER_WORKDIR, machine_branch)),
# Copy image file
steps.ShellCommand(name="Copy image",
command="mkdir -p images \
&& cp fullmetalupdate-yocto-demo/build/yocto/build/tmp/fullmetalupdate-os/deploy/images/{}/fullmetalupdate-os-package-{}.wic \
images/fullmetalupdate-os-package-{}_$(date -u +\"%FT%H%M%SZ\").wic".format(machine, machine, machine, "$(date -u +\"%FT%H%M%SZ\")"),
haltOnFailure=True,
description="Copy image",
workdir="{}/{}".format(BUILDBOT_WORKER_WORKDIR, machine_branch)),
# Flash image
steps.ShellCommand(name="Flash image",
command="dd if=$(ls -t | head -1) of=$SD_CARD_DEV_PATH bs=1M iflag=fullblock oflag=direct conv=fsync && sync",
haltOnFailure=True,
description="Flash image",
workdir="{}/{}/images".format(BUILDBOT_WORKER_WORKDIR, machine_branch)),
]
# build factory from steps
factory = util.BuildFactory(all_steps)
# append new builder
c['builders'].append(util.BuilderConfig(name="{}_test_builder".format(machine_branch),
workernames=["example-worker"],
factory=factory))
####### SCHEDULERS
# Configure the Schedulers, which decide how to react to incoming changes.
c['schedulers'] = []
# Create one sheduler for each branch
for branch, machines in BRANCH_MACHINE_PAIRS.items():
builderNames = []
for machine in machines:
builderNames.append("{}_{}_builder".format(machine, branch))
c['schedulers'].append(
schedulers.SingleBranchScheduler(
name="{}_meta-fullmetalupdate-extra_sched".format(branch),
change_filter=util.ChangeFilter(branch=branch),
treeStableTimer=60,
builderNames=builderNames)
)
# Create a forced scheduler for each builder
for b in c['builders']:
c['schedulers'].append(
schedulers.ForceScheduler(
name="forced_sched_{}".format(b.name),
builderNames=[b.name])
)
# Create a test scheduler: run all tests builders if there is a change in test branch
builderNames = []
for branch, machines in BRANCH_MACHINE_PAIRS.items(): # first loop for branches
for machine in machines: # second loop for machines
builderNames.append("{}_{}_test_builder".format(machine, branch))
c['schedulers'].append(
schedulers.SingleBranchScheduler(
name="test_meta-fullmetalupdate-extra_sched",
change_filter=util.ChangeFilter(branch="test"),
treeStableTimer=60,
builderNames=builderNames)
)
####### BUILDBOT SERVICES (REPORTERS)
# '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'] = []
# publishes a build status using GitHub Status API
context = Interpolate("buildbot/%(prop:buildername)s")
gs = reporters.GitHubStatusPush(token=os.environ.get("GITHUB_TOKEN", ""),
context=context,
startDescription='Build started.',
endDescription='Build done.',
verbose=True)
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'] = "FMU automation build"
c['titleURL'] = "https://github.com/lquinet/fmu-automation-build"
# 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.environ.get("BUILDBOT_WEB_URL", "http://localhost:8010/")
# minimalistic config to activate new web UI
# Buildbot badges plugin produces an image with information about the last build
# availabe at http://<buildbotURL>/badges/<buildername>.svg
c['www'] = dict(
port=os.environ.get("BUILDBOT_WEB_PORT", 8010),
plugins=dict(
waterfall_view={},
console_view={},
badges={})
)
####### DB URL
c['db'] = {
# This specifies what database buildbot uses to store its state. You can leave
# this at its default for all but the largest installations.
'db_url' : os.environ.get("BUILDBOT_DB_URL", "sqlite://").format(**os.environ),
}