summaryrefslogtreecommitdiff
path: root/misc/dashboard/builder
diff options
context:
space:
mode:
Diffstat (limited to 'misc/dashboard/builder')
-rw-r--r--misc/dashboard/builder/http.go35
-rw-r--r--misc/dashboard/builder/main.go127
-rw-r--r--misc/dashboard/builder/package.go121
3 files changed, 5 insertions, 278 deletions
diff --git a/misc/dashboard/builder/http.go b/misc/dashboard/builder/http.go
index f5a1fcf9b..e50ae5724 100644
--- a/misc/dashboard/builder/http.go
+++ b/misc/dashboard/builder/http.go
@@ -125,41 +125,6 @@ func (b *Builder) recordResult(ok bool, pkg, hash, goHash, buildLog string, runT
return dash("POST", "result", args, req, nil)
}
-// packages fetches a list of package paths from the dashboard
-func packages() (pkgs []string, err error) {
- return nil, nil
- /* TODO(adg): un-stub this once the new package builder design is done
- var resp struct {
- Packages []struct {
- Path string
- }
- }
- err = dash("GET", "package", &resp, param{"fmt": "json"})
- if err != nil {
- return
- }
- for _, p := range resp.Packages {
- pkgs = append(pkgs, p.Path)
- }
- return
- */
-}
-
-// updatePackage sends package build results and info to the dashboard
-func (b *Builder) updatePackage(pkg string, ok bool, buildLog, info string) error {
- return nil
- /* TODO(adg): un-stub this once the new package builder design is done
- return dash("POST", "package", nil, param{
- "builder": b.name,
- "key": b.key,
- "path": pkg,
- "ok": strconv.FormatBool(ok),
- "log": buildLog,
- "info": info,
- })
- */
-}
-
func postCommit(key, pkg string, l *HgLog) error {
t, err := time.Parse(time.RFC3339, l.Date)
if err != nil {
diff --git a/misc/dashboard/builder/main.go b/misc/dashboard/builder/main.go
index 4fe65b7a5..85bb7ad4b 100644
--- a/misc/dashboard/builder/main.go
+++ b/misc/dashboard/builder/main.go
@@ -5,8 +5,8 @@
package main
import (
+ "bytes"
"encoding/xml"
- "errors"
"flag"
"fmt"
"io/ioutil"
@@ -23,7 +23,7 @@ import (
const (
codeProject = "go"
codePyScript = "misc/dashboard/googlecode_upload.py"
- hgUrl = "https://go.googlecode.com/hg/"
+ hgUrl = "https://code.google.com/p/go/"
mkdirPerm = 0750
waitInterval = 30 * time.Second // time to wait before checking for new revs
pkgBuildInterval = 24 * time.Hour // rebuild packages every 24 hours
@@ -43,8 +43,6 @@ type Builder struct {
name string
goos, goarch string
key string
- codeUsername string
- codePassword string
}
var (
@@ -55,7 +53,6 @@ var (
buildRevision = flag.String("rev", "", "Build specified revision and exit")
buildCmd = flag.String("cmd", filepath.Join(".", allCmd), "Build command (specify relative to go/src/)")
failAll = flag.Bool("fail", false, "fail all builds")
- external = flag.Bool("external", false, "Build external packages")
parallel = flag.Bool("parallel", false, "Build multiple targets in parallel")
verbose = flag.Bool("v", false, "verbose")
)
@@ -131,14 +128,6 @@ func main() {
return
}
- // external package build mode
- if *external {
- if len(builders) != 1 {
- log.Fatal("only one goos-goarch should be specified with -external")
- }
- builders[0].buildExternal()
- }
-
// go continuous build mode (default)
// check for new commits and build them
for {
@@ -212,53 +201,10 @@ func NewBuilder(builder string) (*Builder, error) {
if err != nil {
return nil, fmt.Errorf("readKeys %s (%s): %s", b.name, fn, err)
}
- v := strings.Split(string(c), "\n")
- b.key = v[0]
- if len(v) >= 3 {
- b.codeUsername, b.codePassword = v[1], v[2]
- }
-
+ b.key = string(bytes.TrimSpace(bytes.SplitN(c, []byte("\n"), 2)[0]))
return b, nil
}
-// buildExternal downloads and builds external packages, and
-// reports their build status to the dashboard.
-// It will re-build all packages after pkgBuildInterval nanoseconds or
-// a new release tag is found.
-func (b *Builder) buildExternal() {
- var prevTag string
- var nextBuild time.Time
- for {
- time.Sleep(waitInterval)
- err := run(nil, goroot, "hg", "pull", "-u")
- if err != nil {
- log.Println("hg pull failed:", err)
- continue
- }
- hash, tag, err := firstTag(releaseRe)
- if err != nil {
- log.Println(err)
- continue
- }
- if *verbose {
- log.Println("latest release:", tag)
- }
- // don't rebuild if there's no new release
- // and it's been less than pkgBuildInterval
- // nanoseconds since the last build.
- if tag == prevTag && time.Now().Before(nextBuild) {
- continue
- }
- // build will also build the packages
- if err := b.buildHash(hash); err != nil {
- log.Println(err)
- continue
- }
- prevTag = tag
- nextBuild = time.Now().Add(pkgBuildInterval)
- }
-}
-
// build checks for a new commit for this builder
// and builds it if one is found.
// It returns true if a build was attempted.
@@ -321,14 +267,6 @@ func (b *Builder) buildHash(hash string) error {
return fmt.Errorf("%s: %s", *buildCmd, err)
}
- // if we're in external mode, build all packages and return
- if *external {
- if status != 0 {
- return errors.New("go build failed")
- }
- return b.buildExternalPackages(workpath, hash)
- }
-
if status != 0 {
// record failure
return b.recordResult(false, "", hash, "", buildLog, runTime)
@@ -342,36 +280,6 @@ func (b *Builder) buildHash(hash string) error {
// build Go sub-repositories
b.buildSubrepos(filepath.Join(workpath, "go"), hash)
- // finish here if codeUsername and codePassword aren't set
- if b.codeUsername == "" || b.codePassword == "" || !*buildRelease {
- return nil
- }
-
- // if this is a release, create tgz and upload to google code
- releaseHash, release, err := firstTag(binaryTagRe)
- if hash == releaseHash {
- // clean out build state
- cmd := filepath.Join(srcDir, cleanCmd)
- if err := run(b.envv(), srcDir, cmd, "--nopkg"); err != nil {
- return fmt.Errorf("%s: %s", cleanCmd, err)
- }
- // upload binary release
- fn := fmt.Sprintf("go.%s.%s-%s.tar.gz", release, b.goos, b.goarch)
- if err := run(nil, workpath, "tar", "czf", fn, "go"); err != nil {
- return fmt.Errorf("tar: %s", err)
- }
- err := run(nil, workpath, filepath.Join(goroot, codePyScript),
- "-s", release,
- "-p", codeProject,
- "-u", b.codeUsername,
- "-w", b.codePassword,
- "-l", fmt.Sprintf("%s,%s", b.goos, b.goarch),
- fn)
- if err != nil {
- return fmt.Errorf("%s: %s", codePyScript, err)
- }
- }
-
return nil
}
@@ -429,7 +337,7 @@ func (b *Builder) buildSubrepos(goRoot, goHash string) {
}
// buildSubrepo fetches the given package, updates it to the specified hash,
-// and runs 'go test pkg/...'. It returns the build log and any error.
+// and runs 'go test -short pkg/...'. It returns the build log and any error.
func (b *Builder) buildSubrepo(goRoot, pkg, hash string) (string, error) {
goBin := filepath.Join(goRoot, "bin")
goTool := filepath.Join(goBin, "go")
@@ -466,7 +374,7 @@ func (b *Builder) buildSubrepo(goRoot, pkg, hash string) (string, error) {
}
// test the package
- log, status, err = runLog(env, "", goRoot, goTool, "test", pkg+"/...")
+ log, status, err = runLog(env, "", goRoot, goTool, "test", "-short", pkg+"/...")
if err == nil && status != 0 {
err = fmt.Errorf("go exited with status %d", status)
}
@@ -739,31 +647,6 @@ func fullHash(root, rev string) (string, error) {
return s, nil
}
-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 error) {
- o, _, err := runLog(nil, "", goroot, "hg", "tags")
- for _, l := range strings.Split(o, "\n") {
- if l == "" {
- continue
- }
- s := revisionRe.FindStringSubmatch(l)
- if s == nil {
- err = errors.New("couldn't find revision number")
- return
- }
- if !re.MatchString(s[1]) {
- continue
- }
- tag = s[1]
- hash, err = fullHash(goroot, s[2])
- return
- }
- err = errors.New("no matching tag found")
- return
-}
-
var repoRe = regexp.MustCompile(`^code\.google\.com/p/([a-z0-9\-]+(\.[a-z0-9\-]+)?)(/[a-z0-9A-Z_.\-/]+)?$`)
// repoURL returns the repository URL for the supplied import path.
diff --git a/misc/dashboard/builder/package.go b/misc/dashboard/builder/package.go
deleted file mode 100644
index dcd449ab8..000000000
--- a/misc/dashboard/builder/package.go
+++ /dev/null
@@ -1,121 +0,0 @@
-// Copyright 2011 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package main
-
-import (
- "errors"
- "fmt"
- "go/doc"
- "go/parser"
- "go/token"
- "log"
- "os"
- "path/filepath"
- "strings"
-)
-
-const MaxCommentLength = 500 // App Engine won't store more in a StringProperty.
-
-func (b *Builder) buildExternalPackages(workpath string, hash string) error {
- logdir := filepath.Join(*buildroot, "log")
- if err := os.Mkdir(logdir, 0755); err != nil {
- return err
- }
- pkgs, err := packages()
- if err != nil {
- return err
- }
- for _, p := range pkgs {
- 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, "-dashboard=false", p)
- if err != nil {
- log.Printf("goinstall %v: %v", p, err)
- }
-
- // get doc comment from package source
- var info string
- pkgPath := filepath.Join(goroot, "src", "pkg", p)
- if _, err := os.Stat(pkgPath); err == nil {
- info, err = packageComment(p, pkgPath)
- if err != nil {
- log.Printf("packageComment %v: %v", p, err)
- }
- }
-
- // update dashboard with build state + info
- err = b.updatePackage(p, code == 0, buildLog, info)
- if err != nil {
- log.Printf("updatePackage %v: %v", p, err)
- }
-
- if code == 0 {
- log.Println("Build succeeded:", p)
- } else {
- log.Println("Build failed:", p)
- fn := filepath.Join(logdir, strings.Replace(p, "/", "_", -1))
- if f, err := os.Create(fn); err != nil {
- log.Printf("creating %s: %v", fn, err)
- } else {
- fmt.Fprint(f, buildLog)
- f.Close()
- }
- }
- }
- return nil
-}
-
-func isGoFile(fi os.FileInfo) bool {
- return !fi.IsDir() && // exclude directories
- !strings.HasPrefix(fi.Name(), ".") && // ignore .files
- !strings.HasSuffix(fi.Name(), "_test.go") && // ignore tests
- filepath.Ext(fi.Name()) == ".go"
-}
-
-func packageComment(pkg, pkgpath string) (info string, err error) {
- fset := token.NewFileSet()
- pkgs, err := parser.ParseDir(fset, pkgpath, isGoFile, parser.PackageClauseOnly|parser.ParseComments)
- if err != nil {
- return
- }
- for name := range pkgs {
- if name == "main" {
- continue
- }
- pdoc := doc.New(pkgs[name], pkg, doc.AllDecls)
- if pdoc.Doc == "" {
- continue
- }
- if info != "" {
- return "", errors.New("multiple packages with docs")
- }
- 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
-}