Skip to content

Commit 5769143

Browse files
bors-servokennytm
authored andcommitted
Auto merge of #169 - Manishearth:build-res, r=jdm
Add support for build results page Currently we get this by going to the buildbot grid, but if you're not on the latest five builds, you have to scroll through the waterfall, which is annoying. Whipped this together as I was waiting for buildbot. Completely untested. cc @jdm <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/homu/169) <!-- Reviewable:end -->
1 parent 5d3ebc0 commit 5769143

File tree

3 files changed

+99
-1
lines changed

3 files changed

+99
-1
lines changed

homu/html/build_res.html

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>Homu build result {{repo_label}}#{{pull}}</title>
6+
<style>
7+
* { font-family: sans-serif; }
8+
h1 { font-size: 20px; }
9+
h2 { font-size: 16px; }
10+
p { font-size: 15px; }
11+
12+
table { border-collapse: collapse; }
13+
td, th { border: 2px solid white; padding: 5px; font-size: 13px; }
14+
tr:nth-child(even) { background: #ddd; }
15+
16+
.treeclosed { color: grey }
17+
.success { background-color: #80C0F0; }
18+
.failed { background-color: #F08080; }
19+
.pending { background-color: #F0DE57; }
20+
21+
.yes { color: green; }
22+
.no { color: red; }
23+
24+
.sorting_asc:after { content: " ▲"; }
25+
.sorting_desc:after { content: " ▼"; }
26+
.dataTables_filter, .dataTables_info, .dataTables_empty { display: none; }
27+
#search { width: 150px; }
28+
.hide { display: none; }
29+
th { cursor: pointer; }
30+
</style>
31+
</head>
32+
<body>
33+
<h1>Homu build results - <a href="{{repo_url}}/pull/{{pull}}" target="_blank">{{repo_label}}#{{pull}}</a></h2>
34+
35+
36+
<table id="results">
37+
<thead>
38+
<tr>
39+
<th class="hide">Sort key</th>
40+
<th>Builder</th>
41+
<th>Status</th>
42+
</tr>
43+
</thead>
44+
45+
<tbody>
46+
{% for builder in builders %}
47+
<tr>
48+
<td class="hide">{{loop.index}}</td>
49+
<td>{{builder.name}}</td>
50+
<td class="{{builder.result}}"><a href="{{builder.url}}">{{builder.result}}</a></td>
51+
</tr>
52+
{% endfor %}
53+
</tbody>
54+
</table>
55+
56+
</script>
57+
</body>
58+
</html>

homu/html/queue.html

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,13 @@ <h1>Homu queue - {% if repo_url %}<a href="{{repo_url}}" target="_blank">{{repo_
9898
<td><a href="{{state.repo_url}}">{{state.repo_label}}</a></td>
9999
{% endif %}
100100
<td><a href="{{state.url}}">{{state.num}}</a></td>
101-
<td class="{{state.status}}">{{state.status}}{{state.status_ext}}</td>
101+
<td class="{{state.status}}">
102+
{% if state.status == "pending" or state.status == "failure" or state.status == "success" %}
103+
<a href="../results/{{state.repo_label}}/{{state.num}}">{{state.status}}{{state.status_ext}}</a>
104+
{% else %}
105+
{{state.status}}{{state.status_ext}}
106+
{% endif %}
107+
</td>
102108
<td class="{{state.mergeable}}">{{state.mergeable}}</td>
103109
<td>{{state.title}}</td>
104110
<td>{{state.head_ref}}</td>

homu/server.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,39 @@ def index():
6666
for label in sorted(g.repos)])
6767

6868

69+
@get('/results/<repo_label:path>/<pull:int>')
70+
def result(repo_label, pull):
71+
if repo_label not in g.states:
72+
abort(404, 'No such repository: {}'.format(repo_label))
73+
states = [state for state in g.states[repo_label].values()
74+
if state.num == pull]
75+
if len(states) == 0:
76+
abort(204, 'No build results for pull request {}'.format(pull))
77+
78+
state = states[0]
79+
builders = []
80+
repo_url = 'https://github.com/{}/{}'.format(
81+
g.cfg['repo'][repo_label]['owner'],
82+
g.cfg['repo'][repo_label]['name'])
83+
for (builder, data) in state.build_res.items():
84+
result = "pending"
85+
if data['res'] is not None:
86+
result = "success" if data['res'] else "failed"
87+
88+
if not data['url']:
89+
# This happens to old try builds
90+
abort(204, 'No build results for pull request {}'.format(pull))
91+
92+
builders.append({
93+
'url': data['url'],
94+
'result': result,
95+
'name': builder,
96+
})
97+
98+
return g.tpls['build_res'].render(repo_label=repo_label, repo_url=repo_url,
99+
builders=builders, pull=pull)
100+
101+
69102
@get('/queue/<repo_label:path>')
70103
def queue(repo_label):
71104
logger = g.logger.getChild('queue')
@@ -782,6 +815,7 @@ def start(cfg, states, queue_handler, repo_cfgs, repos, logger,
782815
tpls = {}
783816
tpls['index'] = env.get_template('index.html')
784817
tpls['queue'] = env.get_template('queue.html')
818+
tpls['build_res'] = env.get_template('build_res.html')
785819

786820
g.cfg = cfg
787821
g.states = states

0 commit comments

Comments
 (0)