summaryrefslogtreecommitdiff
path: root/misc/dashboard/builder
diff options
context:
space:
mode:
authorOndřej Surý <ondrej@sury.org>2011-08-03 16:54:30 +0200
committerOndřej Surý <ondrej@sury.org>2011-08-03 16:54:30 +0200
commit28592ee1ea1f5cdffcf85472f9de0285d928cf12 (patch)
tree32944e18b23f7fe4a0818a694aa2a6dfb1835463 /misc/dashboard/builder
parente836bee4716dc0d4d913537ad3ad1925a7ac32d0 (diff)
downloadgolang-upstream/59.tar.gz
Imported Upstream version 59upstream/59
Diffstat (limited to 'misc/dashboard/builder')
-rw-r--r--misc/dashboard/builder/http.go7
-rw-r--r--misc/dashboard/builder/main.go33
-rw-r--r--misc/dashboard/builder/package.go48
3 files changed, 62 insertions, 26 deletions
diff --git a/misc/dashboard/builder/http.go b/misc/dashboard/builder/http.go
index 5e1da0c87..98400c51a 100644
--- a/misc/dashboard/builder/http.go
+++ b/misc/dashboard/builder/http.go
@@ -112,16 +112,15 @@ func packages() (pkgs []string, err os.Error) {
return
}
-// updatePackage sends package build results and info to the dashboard
-func (b *Builder) updatePackage(pkg string, state bool, buildLog, info string, hash string) os.Error {
+// updatePackage sends package build results and info dashboard
+func (b *Builder) updatePackage(pkg string, ok bool, buildLog, info string) os.Error {
return dash("POST", "package", nil, param{
"builder": b.name,
"key": b.key,
"path": pkg,
- "state": strconv.Btoa(state),
+ "ok": strconv.Btoa(ok),
"log": buildLog,
"info": info,
- "go_rev": hash[:12],
})
}
diff --git a/misc/dashboard/builder/main.go b/misc/dashboard/builder/main.go
index 9377fbe32..989965bc4 100644
--- a/misc/dashboard/builder/main.go
+++ b/misc/dashboard/builder/main.go
@@ -60,8 +60,9 @@ var (
)
var (
- goroot string
- releaseRegexp = regexp.MustCompile(`^(release|weekly)\.[0-9\-.]+`)
+ goroot string
+ binaryTagRe = regexp.MustCompile(`^(release\.r|weekly\.)[0-9\-.]+`)
+ releaseRe = regexp.MustCompile(`^release\.r[0-9\-.]+`)
)
func main() {
@@ -161,7 +162,7 @@ func NewBuilder(builder string) (*Builder, os.Error) {
b := &Builder{name: builder}
// get goos/goarch from builder string
- s := strings.Split(builder, "-", 3)
+ s := strings.SplitN(builder, "-", 3)
if len(s) >= 2 {
b.goos, b.goarch = s[0], s[1]
} else {
@@ -177,7 +178,7 @@ func NewBuilder(builder string) (*Builder, os.Error) {
if err != nil {
return nil, fmt.Errorf("readKeys %s (%s): %s", b.name, fn, err)
}
- v := strings.Split(string(c), "\n", -1)
+ v := strings.Split(string(c), "\n")
b.key = v[0]
if len(v) >= 3 {
b.codeUsername, b.codePassword = v[1], v[2]
@@ -200,7 +201,7 @@ func (b *Builder) buildExternal() {
log.Println("hg pull failed:", err)
continue
}
- hash, tag, err := firstTag(releaseRegexp)
+ hash, tag, err := firstTag(releaseRe)
if err != nil {
log.Println(err)
continue
@@ -321,7 +322,7 @@ func (b *Builder) buildHash(hash string) (err os.Error) {
}
// if this is a release, create tgz and upload to google code
- releaseHash, release, err := firstTag(releaseRegexp)
+ releaseHash, release, err := firstTag(binaryTagRe)
if hash == releaseHash {
// clean out build state
err = run(b.envv(), srcDir, "./clean.bash", "--nopkg")
@@ -357,7 +358,10 @@ func (b *Builder) envv() []string {
"GOROOT_FINAL=/usr/local/go",
}
for _, k := range extraEnv {
- e = append(e, k+"="+os.Getenv(k))
+ s, err := os.Getenverror(k)
+ if err == nil {
+ e = append(e, k+"="+s)
+ }
}
return e
}
@@ -368,9 +372,14 @@ func (b *Builder) envvWindows() []string {
"GOOS": b.goos,
"GOARCH": b.goarch,
"GOROOT_FINAL": "/c/go",
+ // TODO(brainman): remove once we find make that does not hang.
+ "MAKEFLAGS": "-j1",
}
for _, name := range extraEnv {
- start[name] = os.Getenv(name)
+ s, err := os.Getenverror(name)
+ if err == nil {
+ start[name] = s
+ }
}
skip := map[string]bool{
"GOBIN": true,
@@ -384,7 +393,7 @@ func (b *Builder) envvWindows() []string {
skip[name] = true
}
for _, kv := range os.Environ() {
- s := strings.Split(kv, "=", 2)
+ s := strings.SplitN(kv, "=", 2)
name := strings.ToUpper(s[0])
switch {
case name == "":
@@ -583,7 +592,7 @@ func fullHash(rev string) (hash string, err os.Error) {
if s == "" {
return "", fmt.Errorf("cannot find revision")
}
- if len(s) != 20 {
+ if len(s) != 40 {
return "", fmt.Errorf("hg returned invalid hash " + s)
}
return s, nil
@@ -594,7 +603,7 @@ var revisionRe = regexp.MustCompile(`^([^ ]+) +[0-9]+:([0-9a-f]+)$`)
// firstTag returns the hash and tag of the most recent tag matching re.
func firstTag(re *regexp.Regexp) (hash string, tag string, err os.Error) {
o, _, err := runLog(nil, "", goroot, "hg", "tags")
- for _, l := range strings.Split(o, "\n", -1) {
+ for _, l := range strings.Split(o, "\n") {
if l == "" {
continue
}
@@ -607,7 +616,7 @@ func firstTag(re *regexp.Regexp) (hash string, tag string, err os.Error) {
continue
}
tag = s[1]
- hash, err = fullHash(s[3])
+ hash, err = fullHash(s[2])
return
}
err = os.NewError("no matching tag found")
diff --git a/misc/dashboard/builder/package.go b/misc/dashboard/builder/package.go
index ee65d7669..b6674428d 100644
--- a/misc/dashboard/builder/package.go
+++ b/misc/dashboard/builder/package.go
@@ -10,35 +10,47 @@ import (
"go/token"
"log"
"os"
- "path"
+ "path/filepath"
+ "strings"
)
+const MaxCommentLength = 500 // App Engine won't store more in a StringProperty.
+
func (b *Builder) buildPackages(workpath string, hash string) os.Error {
pkgs, err := packages()
if err != nil {
return err
}
for _, p := range pkgs {
- goroot := path.Join(workpath, "go")
- goinstall := path.Join(goroot, "bin", "goinstall")
+ goroot := filepath.Join(workpath, "go")
+ gobin := filepath.Join(goroot, "bin")
+ goinstall := filepath.Join(gobin, "goinstall")
envv := append(b.envv(), "GOROOT="+goroot)
+ // add GOBIN to path
+ for i, v := range envv {
+ if strings.HasPrefix(v, "PATH=") {
+ p := filepath.SplitList(v[5:])
+ p = append([]string{gobin}, p...)
+ s := strings.Join(p, string(filepath.ListSeparator))
+ envv[i] = "PATH=" + s
+ }
+ }
+
// goinstall
- buildLog, code, err := runLog(envv, "", goroot, goinstall, p)
+ buildLog, code, err := runLog(envv, "", goroot, goinstall, "-log=false", p)
if err != nil {
log.Printf("goinstall %v: %v", p, err)
- continue
}
- built := code != 0
// get doc comment from package source
- info, err := packageComment(p, path.Join(goroot, "pkg", p))
+ info, err := packageComment(p, filepath.Join(goroot, "src", "pkg", p))
if err != nil {
- log.Printf("goinstall %v: %v", p, err)
+ log.Printf("packageComment %v: %v", p, err)
}
// update dashboard with build state + info
- err = b.updatePackage(p, built, buildLog, info, hash)
+ err = b.updatePackage(p, code == 0, buildLog, info)
if err != nil {
log.Printf("updatePackage %v: %v", p, err)
}
@@ -46,9 +58,15 @@ func (b *Builder) buildPackages(workpath string, hash string) os.Error {
return nil
}
+func isGoFile(fi *os.FileInfo) bool {
+ return fi.IsRegular() && // exclude directories
+ !strings.HasPrefix(fi.Name, ".") && // ignore .files
+ filepath.Ext(fi.Name) == ".go"
+}
+
func packageComment(pkg, pkgpath string) (info string, err os.Error) {
fset := token.NewFileSet()
- pkgs, err := parser.ParseDir(fset, pkgpath, nil, parser.PackageClauseOnly|parser.ParseComments)
+ pkgs, err := parser.ParseDir(fset, pkgpath, isGoFile, parser.PackageClauseOnly|parser.ParseComments)
if err != nil {
return
}
@@ -62,5 +80,15 @@ func packageComment(pkg, pkgpath string) (info string, err os.Error) {
pdoc := doc.NewPackageDoc(pkgs[name], pkg)
info = pdoc.Doc
}
+ // grab only first paragraph
+ if parts := strings.SplitN(info, "\n\n", 2); len(parts) > 1 {
+ info = parts[0]
+ }
+ // replace newlines with spaces
+ info = strings.Replace(info, "\n", " ", -1)
+ // truncate
+ if len(info) > MaxCommentLength {
+ info = info[:MaxCommentLength]
+ }
return
}