1
0
mirror of https://github.com/golang/go synced 2024-11-21 19:14:44 -07:00

godashboard: fiddling

* some tweaks to dashboard html/css layout
  * use hmac to generate per-builder subkeys

R=agl1
CC=golang-dev
https://golang.org/cl/194092
This commit is contained in:
Russ Cox 2010-01-27 13:09:58 -08:00
parent f39dc9fff2
commit e0afb0c38b
2 changed files with 60 additions and 32 deletions

View File

@ -12,6 +12,7 @@ from google.appengine.ext.webapp.util import run_wsgi_app
import binascii import binascii
import datetime import datetime
import hashlib import hashlib
import hmac
import logging import logging
import os import os
import re import re
@ -70,21 +71,29 @@ class MainPage(webapp.RequestHandler):
results = q.fetch(30) results = q.fetch(30)
revs = [toRev(r) for r in results] revs = [toRev(r) for r in results]
allbuilders = set() builders = {}
for r in revs: for r in revs:
for b in r['builds']: for b in r['builds']:
allbuilders.add(b['builder']) f = b['builder'].split('-', 3)
goos = f[0]
goarch = f[1]
note = ""
if len(f) > 2:
note = f[2]
builders[b['builder']] = {'goos': goos, 'goarch': goarch, 'note': note}
for r in revs: for r in revs:
have = set(x['builder'] for x in r['builds']) have = set(x['builder'] for x in r['builds'])
need = allbuilders.difference(have) need = set(builders.keys()).difference(have)
for n in need: for n in need:
r['builds'].append({'builder': n, 'log':'', 'ok': False}) r['builds'].append({'builder': n, 'log':'', 'ok': False})
r['builds'].sort(cmp = byBuilder) r['builds'].sort(cmp = byBuilder)
r['shortdesc'] = r['desc'].split('\n', 2)[0]
builders = list(allbuilders) builders = list(builders.items())
builders.sort() builders.sort()
values = {"revs": revs, "builders": builders} values = {"revs": revs, "builders": [v for k,v in builders]}
path = os.path.join(os.path.dirname(__file__), 'main.html') path = os.path.join(os.path.dirname(__file__), 'main.html')
self.response.out.write(template.render(path, values)) self.response.out.write(template.render(path, values))
@ -107,9 +116,13 @@ class GetHighwater(webapp.RequestHandler):
self.response.set_status(200) self.response.set_status(200)
self.response.out.write(hw.commit) self.response.out.write(hw.commit)
def auth(req):
k = req.get('key')
return k == hmac.new(key.accessKey, req.get('builder')).hexdigest() or k == key.accessKey
class SetHighwater(webapp.RequestHandler): class SetHighwater(webapp.RequestHandler):
def post(self): def post(self):
if self.request.get('key') != key.accessKey: if not auth(self.request):
self.response.set_status(403) self.response.set_status(403)
return return
@ -141,7 +154,7 @@ class LogHandler(webapp.RequestHandler):
# it cannot be created by Build. # it cannot be created by Build.
class Init(webapp.RequestHandler): class Init(webapp.RequestHandler):
def post(self): def post(self):
if self.request.get('key') != key.accessKey: if not auth(self.request):
self.response.set_status(403) self.response.set_status(403)
return return
@ -167,7 +180,7 @@ class Init(webapp.RequestHandler):
# Build is the main command: it records the result of a new build. # Build is the main command: it records the result of a new build.
class Build(webapp.RequestHandler): class Build(webapp.RequestHandler):
def post(self): def post(self):
if self.request.get('key') != key.accessKey: if not auth(self.request):
self.response.set_status(403) self.response.set_status(403)
return return
@ -248,7 +261,7 @@ class Benchmarks(webapp.RequestHandler):
self.response.out.write(']}\n') self.response.out.write(']}\n')
def post(self): def post(self):
if self.request.get('key') != key.accessKey: if not auth(self.request):
self.response.set_status(403) self.response.set_status(403)
return return
@ -414,7 +427,7 @@ application = webapp.WSGIApplication(
('/build', Build), ('/build', Build),
('/benchmarks', Benchmarks), ('/benchmarks', Benchmarks),
('/benchmarks/.*', GetBenchmarks), ('/benchmarks/.*', GetBenchmarks),
]) ], debug=True)
def main(): def main():
run_wsgi_app(application) run_wsgi_app(application)

View File

@ -1,16 +1,20 @@
<!DOCTYPE HTML> <!DOCTYPE HTML>
<html> <html>
<head> <head>
<title>Go build</title> <title>Go dashboard</title>
<style> <style>
td.revision { h1 {
font-family: monospace; font-size: 1em;
font-weight: bold;
}
h2 {
font-size: 1em;
font-weight: bold;
} }
table.alternate { table.alternate {
white-space: nowrap; white-space: nowrap;
} }
table.alternate tr td { table.alternate tr td {
padding-right: 10px; padding-right: 10px;
} }
@ -18,40 +22,50 @@
padding-right: 0; padding-right: 0;
} }
table.alternate tr:nth-child(2n) { table.alternate tr:nth-child(2n) {
background-color: #eef; background-color: #f8f8f8;
}
td.revision {
}
span.hash {
font-family: monospace;
font-size: small;
color: #aaa;
}
span.nodeseq {
} }
td.user { td.user {
font-family: monospace; font-size: small;
} }
td.date { td.date {
font-size: 0.8em; color: #aaa;
font-size: small;
} }
td.result { td.result {
text-align: center; text-align: center;
} }
span.ok {
}
td.desc { td.desc {
font-size: 0.9em; font-size: small;
font-family: sans-serif; font-family: sans-serif;
} }
th.builder { th.builder {
font-variant: small-caps; font-weight: bold;
font-size: 1.2em; padding-right: 0.5em;
color: #966;
padding-right: 1em;
}
span.ok {
color: green;
} }
</style> </style>
</head> </head>
<body> <body>
<h1>Go dashboard</h1>
<h2>Build status</h2>
<table class="alternate" cellpadding="0" cellspacing="0"> <table class="alternate" cellpadding="0" cellspacing="0">
<tr> <tr>
{% for b in builders %}
<th class="builder">{{b}}</th>
{% endfor %}
<th></th> <th></th>
{% for b in builders %}
<th class="builder">{{b.goos}}<br>{{b.goarch}}<br>{{b.note}}</th>
{% endfor %}
<th></th> <th></th>
<th></th> <th></th>
<th></th> <th></th>
@ -59,13 +73,15 @@
{% for r in revs %} {% for r in revs %}
<tr> <tr>
<td class="revision"><span class="hash"><a href="https://code.google.com/p/go/source/detail?r={{r.node}}">{{r.node|slice:":12"}}</a></span></td>
{% for b in r.builds %} {% for b in r.builds %}
<td class="result"> <td class="result">
{% if b.ok %} {% if b.ok %}
<span class="ok"></span> <span class="ok">ok</span>
{% else %} {% else %}
{% if b.log %} {% if b.log %}
<a href="/log/{{b.log}}">failed</a> <a href="/log/{{b.log}}">fail</a>
{% else %} {% else %}
<span/> <span/>
{% endif %} {% endif %}
@ -73,10 +89,9 @@
</td> </td>
{% endfor %} {% endfor %}
<td class="revision"><a href="https://code.google.com/p/go/source/detail?r={{r.node}}">{{r.node|slice:":12"}}</a></td>
<td class="user">{{r.user|escape}}</td> <td class="user">{{r.user|escape}}</td>
<td class="date">{{r.date|escape}}</td> <td class="date">{{r.date|escape}}</td>
<td class="desc">{{r.desc|escape}}</td> <td class="desc">{{r.shortdesc|escape}}</td>
</tr> </tr>
{% endfor %} {% endfor %}
</table> </table>