From 2d83fa5bf154b059c0304177f82bb7ff9bcf7029 Mon Sep 17 00:00:00 2001 From: Andrew Gerrand Date: Thu, 4 Dec 2014 10:45:11 +1100 Subject: [PATCH] x/tools/dashboard/app: update to support git This adds a "Git" dashboard at "/git/", which has its own namespace for datastore and memcache. Once we have pushed out the new git repositories we will spin up a commit watcher and builders that point to the Git dashboard. Once we are ready to switch the dashboard over to the new Git builders, the (*Dashboard).Context method will be changed to return "Git" as the default namespace. The old builders will be retired, and the new builders will be configured to report to "/" instead of "/git/". At that point all our old data will still be available in the default namespace, but hidden from view. LGTM=dsymonds, cmang R=bradfitz, cmang, dsymonds, adg CC=golang-codereviews https://golang.org/cl/183050043 --- dashboard/app/app.yaml | 6 +- dashboard/app/build/dash.go | 82 +++++++++++++++++++++++++-- dashboard/app/build/handler.go | 26 ++++----- dashboard/app/build/init.go | 1 + dashboard/app/build/perf_changes.go | 2 +- dashboard/app/build/perf_changes.html | 6 +- dashboard/app/build/perf_detail.go | 4 +- dashboard/app/build/perf_detail.html | 10 ++-- dashboard/app/build/perf_graph.go | 4 +- dashboard/app/build/perf_graph.html | 6 +- dashboard/app/build/perf_learn.go | 2 +- dashboard/app/build/test.go | 2 +- dashboard/app/build/ui.go | 13 +++-- dashboard/app/build/ui.html | 12 ++-- dashboard/app/build/update.go | 2 +- 15 files changed, 124 insertions(+), 54 deletions(-) diff --git a/dashboard/app/app.yaml b/dashboard/app/app.yaml index 8424cd0c..48ba8052 100644 --- a/dashboard/app/app.yaml +++ b/dashboard/app/app.yaml @@ -11,11 +11,11 @@ api_version: go1 handlers: - url: /static static_dir: static -- url: /(|gccgo/)log/.+ +- url: /(|gccgo/|git/)log/.+ script: _go_app -- url: /(|gccgo/)(|commit|packages|result|perf-result|tag|todo|perf|perfdetail|perfgraph|updatebenchmark) +- url: /(|gccgo/|git/)(|commit|packages|result|perf-result|tag|todo|perf|perfdetail|perfgraph|updatebenchmark) script: _go_app -- url: /(|gccgo/)(init|buildtest|key|perflearn|_ah/queue/go/delay) +- url: /(|gccgo/|git/)(init|buildtest|key|perflearn|_ah/queue/go/delay) script: _go_app login: admin diff --git a/dashboard/app/build/dash.go b/dashboard/app/build/dash.go index 52ca74da..9c092e78 100644 --- a/dashboard/app/build/dash.go +++ b/dashboard/app/build/dash.go @@ -13,18 +13,27 @@ import ( "appengine" ) +func handleFunc(path string, h http.HandlerFunc) { + for _, d := range dashboards { + http.HandleFunc(d.Prefix+path, h) + } +} + // Dashboard describes a unique build dashboard. type Dashboard struct { Name string // This dashboard's name and namespace - RelPath string // The relative url path + Prefix string // The path prefix (no trailing /) Packages []*Package // The project's packages to build } // dashboardForRequest returns the appropriate dashboard for a given URL path. func dashboardForRequest(r *http.Request) *Dashboard { - if strings.HasPrefix(r.URL.Path, gccgoDash.RelPath) { + if strings.HasPrefix(r.URL.Path, gccgoDash.Prefix) { return gccgoDash } + if strings.HasPrefix(r.URL.Path, gitDash.Prefix) { + return gitDash + } return goDash } @@ -43,12 +52,12 @@ func (d *Dashboard) Context(c appengine.Context) appengine.Context { } // the currently known dashboards. -var dashboards = []*Dashboard{goDash, gccgoDash} +var dashboards = []*Dashboard{goDash, gitDash, gccgoDash} // goDash is the dashboard for the main go repository. var goDash = &Dashboard{ Name: "Go", - RelPath: "/", + Prefix: "", Packages: goPackages, } @@ -105,10 +114,71 @@ var goPackages = []*Package{ }, } +// gitDash is the dashboard for the main go repository on git. +var gitDash = &Dashboard{ + Name: "Git", + Prefix: "/git", + Packages: gitPackages, +} + +// gitPackages is a list of all of the packages built by the main go repository +// on git. +var gitPackages = []*Package{ + { + Kind: "go", + Name: "Go", + }, + { + Kind: "subrepo", + Name: "blog", + Path: "golang.org/x/blog", + }, + { + Kind: "subrepo", + Name: "codereview", + Path: "golang.org/x/codereview", + }, + { + Kind: "subrepo", + Name: "crypto", + Path: "golang.org/x/crypto", + }, + { + Kind: "subrepo", + Name: "exp", + Path: "golang.org/x/exp", + }, + { + Kind: "subrepo", + Name: "image", + Path: "golang.org/x/image", + }, + { + Kind: "subrepo", + Name: "net", + Path: "golang.org/x/net", + }, + { + Kind: "subrepo", + Name: "sys", + Path: "golang.org/x/sys", + }, + { + Kind: "subrepo", + Name: "talks", + Path: "golang.org/x/talks", + }, + { + Kind: "subrepo", + Name: "tools", + Path: "golang.org/x/tools", + }, +} + // gccgoDash is the dashboard for gccgo. var gccgoDash = &Dashboard{ - Name: "Gccgo", - RelPath: "/gccgo/", + Name: "Gccgo", + Prefix: "/gccgo", Packages: []*Package{ { Kind: "gccgo", diff --git a/dashboard/app/build/handler.go b/dashboard/app/build/handler.go index 5d06815c..ee75ba9b 100644 --- a/dashboard/app/build/handler.go +++ b/dashboard/app/build/handler.go @@ -841,22 +841,20 @@ func keyHandler(w http.ResponseWriter, r *http.Request) { } func init() { - for _, d := range dashboards { - // admin handlers - http.HandleFunc(d.RelPath+"init", initHandler) - http.HandleFunc(d.RelPath+"key", keyHandler) + // admin handlers + handleFunc("/init", initHandler) + handleFunc("/key", keyHandler) - // authenticated handlers - http.HandleFunc(d.RelPath+"commit", AuthHandler(commitHandler)) - http.HandleFunc(d.RelPath+"packages", AuthHandler(packagesHandler)) - http.HandleFunc(d.RelPath+"result", AuthHandler(resultHandler)) - http.HandleFunc(d.RelPath+"perf-result", AuthHandler(perfResultHandler)) - http.HandleFunc(d.RelPath+"tag", AuthHandler(tagHandler)) - http.HandleFunc(d.RelPath+"todo", AuthHandler(todoHandler)) + // authenticated handlers + handleFunc("/commit", AuthHandler(commitHandler)) + handleFunc("/packages", AuthHandler(packagesHandler)) + handleFunc("/result", AuthHandler(resultHandler)) + handleFunc("/perf-result", AuthHandler(perfResultHandler)) + handleFunc("/tag", AuthHandler(tagHandler)) + handleFunc("/todo", AuthHandler(todoHandler)) - // public handlers - http.HandleFunc(d.RelPath+"log/", logHandler) - } + // public handlers + handleFunc("/log/", logHandler) } func validHash(hash string) bool { diff --git a/dashboard/app/build/init.go b/dashboard/app/build/init.go index e7d63ed5..9654d183 100644 --- a/dashboard/app/build/init.go +++ b/dashboard/app/build/init.go @@ -33,6 +33,7 @@ func initHandler(w http.ResponseWriter, r *http.Request) { logErr(w, r, err) return } + p.NextNum = 1 // So we can add the first commit. if _, err := datastore.Put(c, p.Key(c), p); err != nil { logErr(w, r, err) return diff --git a/dashboard/app/build/perf_changes.go b/dashboard/app/build/perf_changes.go index 4abbf1a4..f52f2113 100644 --- a/dashboard/app/build/perf_changes.go +++ b/dashboard/app/build/perf_changes.go @@ -19,7 +19,7 @@ import ( ) func init() { - http.HandleFunc("/perf", perfChangesHandler) + handleFunc("/perf", perfChangesHandler) } // perfSummaryHandler draws the main benchmarking page. diff --git a/dashboard/app/build/perf_changes.html b/dashboard/app/build/perf_changes.html index 24f0534d..16819e14 100644 --- a/dashboard/app/build/perf_changes.html +++ b/dashboard/app/build/perf_changes.html @@ -8,9 +8,9 @@

Go Dashboard

diff --git a/dashboard/app/build/perf_detail.go b/dashboard/app/build/perf_detail.go index f8d9bfda..04d374a6 100644 --- a/dashboard/app/build/perf_detail.go +++ b/dashboard/app/build/perf_detail.go @@ -20,9 +20,7 @@ import ( ) func init() { - for _, d := range dashboards { - http.HandleFunc(d.RelPath+"perfdetail", perfDetailUIHandler) - } + handleFunc("/perfdetail", perfDetailUIHandler) } func perfDetailUIHandler(w http.ResponseWriter, r *http.Request) { diff --git a/dashboard/app/build/perf_detail.html b/dashboard/app/build/perf_detail.html index 18b30283..8de84271 100644 --- a/dashboard/app/build/perf_detail.html +++ b/dashboard/app/build/perf_detail.html @@ -21,9 +21,9 @@

Go Dashboard

@@ -74,12 +74,12 @@ {{$m.Name}} {{if $m.Link0}} - {{$m.Val0}} + {{$m.Val0}} {{else}} {{$m.Val0}} {{end}} {{if $m.Link1}} - {{$m.Val1}} + {{$m.Val1}} {{else}} {{$m.Val1}} {{end}} diff --git a/dashboard/app/build/perf_graph.go b/dashboard/app/build/perf_graph.go index 81eb5e16..fbdff89d 100644 --- a/dashboard/app/build/perf_graph.go +++ b/dashboard/app/build/perf_graph.go @@ -18,9 +18,7 @@ import ( ) func init() { - for _, d := range dashboards { - http.HandleFunc(d.RelPath+"perfgraph", perfGraphHandler) - } + handleFunc("/perfgraph", perfGraphHandler) } func perfGraphHandler(w http.ResponseWriter, r *http.Request) { diff --git a/dashboard/app/build/perf_graph.html b/dashboard/app/build/perf_graph.html index da1c0d00..5031a92a 100644 --- a/dashboard/app/build/perf_graph.html +++ b/dashboard/app/build/perf_graph.html @@ -53,9 +53,9 @@

Go Dashboard

diff --git a/dashboard/app/build/perf_learn.go b/dashboard/app/build/perf_learn.go index 683ba60b..d2a57bf6 100644 --- a/dashboard/app/build/perf_learn.go +++ b/dashboard/app/build/perf_learn.go @@ -18,7 +18,7 @@ import ( ) func init() { - http.HandleFunc("/perflearn", perfLearnHandler) + handleFunc("/perflearn", perfLearnHandler) } const ( diff --git a/dashboard/app/build/test.go b/dashboard/app/build/test.go index 34a1c39f..228dfef8 100644 --- a/dashboard/app/build/test.go +++ b/dashboard/app/build/test.go @@ -26,7 +26,7 @@ import ( ) func init() { - http.HandleFunc("/buildtest", testHandler) + handleFunc("/buildtest", testHandler) } var testEntityKinds = []string{ diff --git a/dashboard/app/build/ui.go b/dashboard/app/build/ui.go index c2cf7c5a..9e75292e 100644 --- a/dashboard/app/build/ui.go +++ b/dashboard/app/build/ui.go @@ -27,9 +27,7 @@ import ( ) func init() { - for _, d := range dashboards { - http.HandleFunc(d.RelPath, uiHandler) - } + handleFunc("/", uiHandler) } // uiHandler draws the build status page. @@ -437,7 +435,14 @@ func repoURL(dashboard, hash, packagePath string) (string, error) { if dashboard == "Gccgo" { return "https://code.google.com/p/gofrontend/source/detail?r=" + hash, nil } - return "https://code.google.com/p/go/source/detail?r=" + hash, nil + if dashboard == "Git" { + return "https://go.googlesource.com/go/+/" + hash, nil + } + return "https://golang.org/change/" + hash, nil + } + if dashboard == "Git" { + repo := strings.TrimPrefix(packagePath, "golang.org/x/") + return "https://go.googlesource.com/" + repo + "/+/" + hash, nil } m := repoRe.FindStringSubmatch(packagePath) if m == nil { diff --git a/dashboard/app/build/ui.html b/dashboard/app/build/ui.html index 6ae268c6..01b8c085 100644 --- a/dashboard/app/build/ui.html +++ b/dashboard/app/build/ui.html @@ -22,16 +22,16 @@

Go Dashboard