File: git_gerrit.cfg

package info (click to toggle)
buildbot 4.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 21,080 kB
  • sloc: python: 174,183; sh: 1,204; makefile: 332; javascript: 119; xml: 16
file content (218 lines) | stat: -rw-r--r-- 7,644 bytes parent folder | download | duplicates (5)
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
# -*- python -*-
# ex: set syntax=python:

from buildbot.plugins import *

# This is a sample buildmaster config file. It must be installed as
# 'master.cfg' in your buildmaster's base directory.

# This is the dictionary that the buildmaster pays attention to. We also use
# a shorter alias to save typing.
c = BuildmasterConfig = {}

####### BUILDSLAVES

# The 'slaves' list defines the set of recognized buildslaves. Each element is
# a BuildSlave object, specifying a unique slave name and password.  The same
# slave name and password must be configured on the slave.
c['slaves'] = [buildslave.BuildSlave("example-slave", "pass")]

# 'protocols' contains information about protocols which master will use for
# communicating with slaves. You must define at least 'port' option that slaves 
# could connect to your master with this protocol.
# 'port' must match the value configured into the buildslaves (with their
# --master option)
c['protocols'] = {'pb': {'port': 9989}}

####### CHANGESOURCES

# the 'change_source' setting tells the buildmaster how it should find out
# about source code changes.  Here we point to the buildbot clone of pyflakes.

#Gerrit Configuration
gerrit_url = "gerrit.example.com"
gerrit_user = "gerrit"
gerrit_port = "29418"
gerrit_project = "mygerritproject"

gerrit_repo = "ssh://%s@%s:%s/%s" % (gerrit_user, gerrit_url, gerrit_port,
                                     gerrit_project)

#Add comment-added to handled_events to have approvals information (Code-Review...)
c['change_source'] = []
c['change_source'].append(changes.GerritChangeSource(gerrit_url, gerrit_user,
                                                handled_events=["patchset-created",
                                                                "comment-added"]))

####### SCHEDULERS

# Configure the Schedulers, which decide how to react to incoming changes.  In this
# case, just kick off a 'runtests' build

#Check there is Code-Review=+2 in Approvals (of comment-added)

def change_code_review_plus_2(change):
    if "event.approvals" in change.properties:
        for a in change.properties["event.approvals"]:
            if "Code-Review" in a["type"] and int(a["value"]) == 2:
               return True
    return False


c['schedulers'] = []
c['schedulers'].append(schedulers.SingleBranchScheduler(
                            name="all",
                            change_filter=util.ChangeFilter(branch_re="master/*", filter_fn=change_code_review_plus_2),
                            treeStableTimer=None,
                            builderNames=["runtests-gcc","runtests-clang"]))
c['schedulers'].append(schedulers.ForceScheduler(
                            name="force",
                            builderNames=["runtests-gcc","runtests-clang"]))

####### BUILDERS

# The 'builders' list defines the Builders, which tell Buildbot how to perform a build:
# what steps, and which slaves can execute them.  Note that any particular build will
# only take place on one slave.

#Build with GCC
f_gcc = util.BuildFactory([
    steps.Gerrit(repourl=gerrit_repo, mode="full",retry=[60,60],timeout=3600),
    steps.ShellCommand(command=["bash","./autogen.sh"],timeout=3600),
    steps.Configure(command=["./configure"]),
    steps.Compile(command=["make", "-j", "4"]),
    steps.Compile(command=["make", "test"])
])

#Build with Clang
f_clang = BuildFactory([
    steps.Gerrit(repourl=gerrit_repo, mode="full",retry=[60,60],timeout=3600),
    steps.ShellCommand(command=["bash","./autogen.sh"],timeout=3600),
    steps.Configure(command=["./configure"],env={ "CC":"clang", "CXX":"clang++"}),
    steps.Compile(command=["make", "-j", "4"]),
    steps.Compile(command=["make", "test"])
])

c['builders'] = []
c['builders'].append(
    util.BuilderConfig(name="runtests-gcc", slavenames=["example-slave"],
                       factory=f_gcc))
c['builders'].append(
    util.BuilderConfig(name="runtests-clang", slavenames=["example-slave"],
                       factory=f_clang))


####### STATUS TARGETS

# 'status' is a list of Status Targets. The results of each build will be
# pushed to these targets. buildbot/status/*.py has a variety to choose from,
# like IRC bots.

c['status'] = []

authz_cfg=authz.Authz(
    # change any of these to True to enable; see the manual for more
    # options
    auth=auth.BasicAuth([("pyflakes","pyflakes")]),
    gracefulShutdown = False,
    forceBuild = 'auth', # use this to test your slave once it is set up
    forceAllBuilds = False,
    pingBuilder = False,
    stopBuild = False,
    stopAllBuilds = False,
    cancelPendingBuild = False,
)
c['status'].append(html.WebStatus(http_port=8010, authz=authz_cfg))

def gerritReviewCB(builderName, build, result, master, arg):
    if result == util.RETRY:
        return dict()

    message =  "Buildbot finished compiling your patchset\n"
    message += "on configuration: %s\n" % builderName
    message += "The result is: %s\n" % util.Results[result].upper()

    if arg:
        message += "\nFor more details visit:\n"
        message += build['url'] + "\n"

    if result == util.SUCCESS:
        verified = 1
    else:
        verified = -1

    return dict(message=message, labels={'Verified': verified})

def gerritStartCB(builderName, build, arg):
    message = "Buildbot started compiling your patchset\n"
    message += "on configuration: %s\n" % builderName
    message += "See your build here: %s" % build['url']

    return dict(message=message)

def gerritSummaryCB(buildInfoList, results, status, arg):
    success = False
    failure = False

    msgs = []

    for buildInfo in buildInfoList:
        msg = "Builder %(name)s %(resultText)s (%(text)s)" % buildInfo
        link = buildInfo.get('url', None)
        if link:
            msg += " - " + link
        else:
            msg += "."

        msgs.append(msg)

        if buildInfo['result'] == util.SUCCESS:
            success = True
        else:
            failure = True

    if success and not failure:
        verified = 1
    else:
        verified = -1

    return dict(message='\n\n'.join(msgs),
                labels={
                    'Verified': verified
                })

c['buildbotURL'] = 'http://buildbot.example.com/'
c['status'].append(status.GerritStatusPush(gerrit_url, gerrit_user,
                                           reviewCB=gerritReviewCB,
                                           reviewArg=c['buildbotURL'],
                                           startCB=gerritStartCB,
                                           startArg=c['buildbotURL'],
                                           summaryCB=gerritSummaryCB,
                                           summaryArg=c['buildbotURL']))

####### PROJECT IDENTITY

# the 'title' string will appear at the top of this buildbot installation's
# home pages (linked to the 'titleURL').

c['title'] = "Buildbot with Gerrit"
c['titleURL'] = "https://" + gerrit_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.

c['buildbotURL'] = "http://localhost:8010/"

# minimalistic config to activate new web UI
c['www'] = dict(port=8010,
                plugins=dict(waterfall_view={}, console_view={}, grid_view={}))

####### 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' : "sqlite:///state.sqlite",
}