Skip to content

Commit cedb115

Browse files
author
buildbot
committed
Added exception capture and error message when the --release switch to coverage_changes specify a release for which there aren't any data. Also tweaked the diff output for code coverage changes.
- Legacy-Id: 9239
1 parent c3023c0 commit cedb115

2 files changed

Lines changed: 212 additions & 5 deletions

File tree

Lines changed: 206 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,206 @@
1+
# -*- python -*-
2+
# ex: set syntax=python:
3+
4+
# This is a sample buildmaster config file. It must be installed as
5+
# 'master.cfg' in your buildmaster's base directory.
6+
7+
# This is the dictionary that the buildmaster pays attention to. We also use
8+
# a shorter alias to save typing.
9+
c = BuildmasterConfig = {}
10+
11+
####### BUILDSLAVES
12+
13+
# The 'slaves' list defines the set of recognized buildslaves. Each element is
14+
# a BuildSlave object, specifying a unique slave name and password. The same
15+
# slave name and password must be configured on the slave.
16+
from buildbot.buildslave import BuildSlave
17+
c['slaves'] = [
18+
BuildSlave("datatracker_py27_1", "yWQaUzdJk8oL"),
19+
BuildSlave("datatracker_py27_2", "nm+=+knVGycN"),
20+
BuildSlave("datatracker_py27_3", "WZgYahJ4twXR"),
21+
]
22+
23+
# 'protocols' contains information about protocols which master will use for
24+
# communicating with slaves.
25+
# You must define at least 'port' option that slaves could connect to your master
26+
# with this protocol.
27+
# 'port' must match the value configured into the buildslaves (with their
28+
# --master option)
29+
c['protocols'] = {'pb': {'host':'zinfandel.tools.ietf.org', 'port': 9989}}
30+
31+
####### CHANGESOURCES
32+
33+
# the 'change_source' setting tells the buildmaster how it should find out
34+
# about source code changes.
35+
36+
from buildbot.changes.pb import PBChangeSource
37+
# c['change_source'] = []
38+
# with open("users") as file:
39+
# userinfo = json.read(file)
40+
# for user in userinfo:
41+
# prefix = userinfo[user]["prefix"]
42+
# c.['change_source'].append(PBChangeSource(user=user, passwd="BRiR6XcT7x3$", prefix=prefix))
43+
c['change_source'] = [
44+
PBChangeSource(user="ietfdb", passwd="BRiR6XcT7x3$"),
45+
]
46+
47+
####### SCHEDULERS
48+
49+
# Configure the Schedulers, which decide how to react to incoming changes. In this
50+
# case, just kick off a 'runtests' build
51+
52+
from buildbot.schedulers.basic import SingleBranchScheduler, AnyBranchScheduler
53+
from buildbot.schedulers.forcesched import ForceScheduler
54+
from buildbot.changes import filter
55+
c['schedulers'] = [
56+
AnyBranchScheduler(name="pyflakes", treeStableTimer=10, builderNames=["run_pyflakes"]),
57+
AnyBranchScheduler(name="test", treeStableTimer=60*10, builderNames=["run_tests"]),
58+
SingleBranchScheduler(name="crawler", treeStableTimer=60*60*4, builderNames=["run_crawler"],
59+
change_filter=filter.ChangeFilter(branch='trunk')),
60+
]
61+
62+
####### BUILDERS
63+
64+
# The 'builders' list defines the Builders, which tell Buildbot how to perform a build:
65+
# what steps, and which slaves can execute them. Note that any particular build will
66+
# only take place on one slave.
67+
68+
from buildbot.process.factory import BuildFactory
69+
from buildbot.steps.source.svn import SVN
70+
from buildbot.steps.shell import ShellCommand
71+
from buildbot.steps.python import PyFlakes
72+
from buildbot.process.properties import Property, Interpolate
73+
from buildbot.config import BuilderConfig
74+
75+
76+
c['builders'] = []
77+
78+
# Run pyflakes
79+
factory = BuildFactory()
80+
factory.addStep(SVN(
81+
workdir=Interpolate('build/%(src::branch)s'), haltOnFailure=True,
82+
repourl=Interpolate('https://svn.tools.ietf.org/svn/tools/ietfdb/%(src::branch:~trunk)s'),
83+
descriptionSuffix=[Interpolate('%(src::branch)s %(src::revision)s')],
84+
))
85+
factory.addStep(ShellCommand(
86+
workdir=Interpolate('build/%(src::branch)s'), haltOnFailure=True,
87+
command=["pip", "install", "-r", "requirements.txt"]))
88+
factory.addStep(PyFlakes(
89+
workdir=Interpolate('build/%(src::branch)s'), haltOnFailure=True,
90+
command=["ietf/manage.py", "pyflakes", "--verbosity=0"]))
91+
# This should be the last action
92+
factory.addStep(ShellCommand(descriptionDone="mark as passed",
93+
workdir=Interpolate('build/%(src::branch)s'),
94+
command=["svn", "--username=buildbot@tools.ietf.org", "--password=ax+u#ikxabx7",
95+
"--no-auth-cache", "--non-interactive",
96+
"propset", "--revprop", "-r", Property('got_revision'), "test:pyflakes", "passed" ]))
97+
98+
c['builders'].append(BuilderConfig(name="run_pyflakes", factory=factory,
99+
slavenames=["datatracker_py27_1", "datatracker_py27_2", "datatracker_py27_3"]))
100+
101+
# Run tests
102+
factory = BuildFactory()
103+
factory.addStep(SVN(
104+
workdir=Interpolate('build/%(src::branch)s'), haltOnFailure=True,
105+
repourl=Interpolate('https://svn.tools.ietf.org/svn/tools/ietfdb/%(src::branch:~trunk)s'),
106+
descriptionSuffix=[Interpolate('%(src::branch)s %(src::revision)s')],
107+
))
108+
factory.addStep(ShellCommand(
109+
workdir=Interpolate('build/%(src::branch)s'), haltOnFailure=True,
110+
command=["pip", "install", "-r", "requirements.txt"]))
111+
factory.addStep(ShellCommand(
112+
workdir=Interpolate('build/%(src::branch)s'), haltOnFailure=True,
113+
command=["ietf/manage.py", "test", "--settings=settings_sqlitetest"]))
114+
# This should be the last action
115+
factory.addStep(ShellCommand(descriptionDone="mark as passed",
116+
workdir=Interpolate('build/%(src::branch)s'),
117+
command=["svn", "--username=buildbot@tools.ietf.org", "--password=ax+u#ikxabx7",
118+
"--no-auth-cache", "--non-interactive",
119+
"propset", "--revprop", "-r", Property('got_revision'), "test:unittest", "passed" ]))
120+
121+
c['builders'].append(BuilderConfig(name="run_tests", factory=factory,
122+
slavenames=["datatracker_py27_1", "datatracker_py27_2", "datatracker_py27_3"]))
123+
124+
# Run test-crawler
125+
factory = BuildFactory()
126+
factory.addStep(SVN(
127+
workdir=Interpolate('build/%(src::branch)s'), haltOnFailure=True,
128+
repourl=Interpolate('https://svn.tools.ietf.org/svn/tools/ietfdb/%(src::branch:~trunk)s')))
129+
factory.addStep(ShellCommand(
130+
workdir=Interpolate('build/%(src::branch)s'), haltOnFailure=True,
131+
command=["pip", "install", "-r", "requirements.txt"]))
132+
factory.addStep(ShellCommand(
133+
workdir=Interpolate('build/%(src::branch)s'), haltOnFailure=True,
134+
command=["bin/test-crawl", "--settings=ietf.settings_testcrawl"]))
135+
# This should be the last action
136+
factory.addStep(ShellCommand(descriptionDone="mark as passed",
137+
workdir=Interpolate('build/%(src::branch)s'),
138+
command=["svn", "--username=buildbot@tools.ietf.org", "--password=ax+u#ikxabx7",
139+
"--no-auth-cache", "--non-interactive",
140+
"propset", "--revprop", "-r", Property('got_revision'), "test:crawler", "passed" ]))
141+
142+
c['builders'].append(BuilderConfig(name="run_crawler", factory=factory,
143+
slavenames=["datatracker_py27_1"]))
144+
145+
146+
####### STATUS TARGETS
147+
148+
# 'status' is a list of Status Targets. The results of each build will be
149+
# pushed to these targets. buildbot/status/*.py has a variety to choose from,
150+
# including web pages, email senders, and IRC bots.
151+
152+
c['status'] = []
153+
154+
from buildbot.status import html
155+
from buildbot.status.web import authz, auth
156+
157+
authz_cfg=authz.Authz(
158+
# change any of these to True to enable; see the manual for more
159+
# options
160+
auth.BasicAuth([("ietfdb","ietfdb")]),
161+
gracefulShutdown = False,
162+
forceBuild = 'auth', # use this to test your slave once it is set up
163+
forceAllBuilds = False,
164+
pingBuilder = False,
165+
stopBuild = False,
166+
stopAllBuilds = False,
167+
cancelPendingBuild = False,
168+
)
169+
c['status'].append(html.WebStatus(http_port=8010, authz=authz_cfg))
170+
171+
# A second web status with slightly different rendering
172+
from twisted.python import log
173+
def changelinkfilter(html, project):
174+
log.msg(" * changelinkfilter(html='%s', project='%s')" % (html, project))
175+
return html
176+
177+
import jinja2, os
178+
trac_template_loaders = [jinja2.FileSystemLoader(os.path.join(os.getcwd(), 'trac_view'))]
179+
c['status'].append(html.WebStatus(http_port=8011, jinja_loaders=trac_template_loaders,
180+
authz=authz_cfg))
181+
182+
183+
####### PROJECT IDENTITY
184+
185+
# the 'title' string will appear at the top of this buildbot
186+
# installation's html.WebStatus home page (linked to the
187+
# 'titleURL') and is embedded in the title of the waterfall HTML page.
188+
189+
c['title'] = "IETF Datatracker"
190+
c['titleURL'] = "https://datatracker.ietf.org/"
191+
192+
# the 'buildbotURL' string should point to the location where the buildbot's
193+
# internal web server (usually the html.WebStatus page) is visible. This
194+
# typically uses the port number set in the Waterfall 'status' entry, but
195+
# with an externally-visible host name which the buildbot cannot figure out
196+
# without some help.
197+
198+
c['buildbotURL'] = "http://zinfandel.tools.ietf.org:8010/"
199+
200+
####### DB URL
201+
202+
c['db'] = {
203+
# This specifies what database buildbot uses to store its state. You can leave
204+
# this at its default for all but the largest installations.
205+
'db_url' : "sqlite:///state.sqlite",
206+
}

ietf/utils/management/commands/coverage_changes.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,10 @@ def read_coverage(self, filename, version=None):
3232
try:
3333
data = json.load(file)
3434
except ValueError as e:
35-
self.stderr.write("Failure to read json data from %s: %s" % (filename, e))
36-
exit(1)
35+
raise CommandError("Failure to read json data from %s: %s" % (filename, e))
3736
version = version or data["version"]
37+
if not version in data:
38+
raise CommandError("There is no data for version %s available in %s" % (version, filename))
3839
return data[version], version
3940

4041
def coverage_diff(self, master, latest, sections=','.join(valid_sections), release=None, **options):
@@ -60,12 +61,12 @@ def coverage_diff(self, master, latest, sections=','.join(valid_sections), relea
6061
if not key in mcoverage:
6162
mcoverage[key] = None
6263
if type(mcoverage[key]) is float or type(lcoverage[key]) is float:
63-
mval = ("%8.2f" % mcoverage[key]) if mcoverage[key] else "-"
64-
lval = ("%8.2f" % lcoverage[key]) if lcoverage[key] else "-"
64+
mval = ("%5.1f" % (100*mcoverage[key])) if mcoverage[key] else "-"
65+
lval = ("%5.1f %%" % (100*lcoverage[key])) if lcoverage[key] else "- "
6566
else:
6667
mval = mcoverage[key]
6768
lval = lcoverage[key]
68-
if mval != lval:
69+
if mcoverage[key] != lcoverage[key]:
6970
if not header_written:
7071
self.stdout.write(self.diff_line_format %
7172
("\n%s"%section.capitalize(), mversion[:7], lversion[:7]))

0 commit comments

Comments
 (0)