dashboard: ask builders to re-build Go tip to freshen subrepos

This ensures we always have results for subrepo-tip at go-tip.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/5569091
This commit is contained in:
Andrew Gerrand 2012-01-30 14:50:36 +11:00
parent 43ebc6b5c6
commit faa1bf04fd
4 changed files with 46 additions and 8 deletions

View File

@ -262,6 +262,13 @@ func (t *Tag) Valid() os.Error {
return nil return nil
} }
// Commit returns the Commit that corresponds with this Tag.
func (t *Tag) Commit(c appengine.Context) (*Commit, os.Error) {
com := &Commit{Hash: t.Hash}
err := datastore.Get(c, com.Key(c), com)
return com, err
}
// GetTag fetches a Tag by name from the datastore. // GetTag fetches a Tag by name from the datastore.
func GetTag(c appengine.Context, tag string) (*Tag, os.Error) { func GetTag(c appengine.Context, tag string) (*Tag, os.Error) {
t := &Tag{Kind: tag} t := &Tag{Kind: tag}

View File

@ -196,17 +196,44 @@ func buildTodo(c appengine.Context, builder, packagePath, goHash string) (interf
Run(c) Run(c)
for { for {
com := new(Commit) com := new(Commit)
if _, err := t.Next(com); err != nil { if _, err := t.Next(com); err == datastore.Done {
if err == datastore.Done { break
err = nil } else if err != nil {
}
return nil, err return nil, err
} }
if com.Result(builder, goHash) == nil { if com.Result(builder, goHash) == nil {
return com, nil return com, nil
} }
} }
panic("unreachable")
// Nothing left to do if this is a package (not the Go tree).
if packagePath != "" {
return nil, nil
}
// If there are no Go tree commits left to build,
// see if there are any subrepo commits that need to be built at tip.
// If so, ask the builder to build a go tree at the tip commit.
// TODO(adg): do the same for "weekly" and "release" tags.
tag, err := GetTag(c, "tip")
if err != nil {
return nil, err
}
pkgs, err := Packages(c, "subrepo")
if err != nil {
return nil, err
}
for _, pkg := range pkgs {
com, err := pkg.LastCommit(c)
if err != nil {
c.Warningf("%v: no Commit found: %v", pkg, err)
continue
}
if com.Result(builder, tag.Hash) == nil {
return tag.Commit(c)
}
}
return nil, nil
} }
// packagesHandler returns a list of the non-Go Packages monitored // packagesHandler returns a list of the non-Go Packages monitored

View File

@ -109,7 +109,11 @@ var testRequests = []struct {
{"/result", nil, &Result{PackagePath: testPkg, Builder: "linux-386", Hash: "1001", GoHash: "0001", OK: true}, nil}, {"/result", nil, &Result{PackagePath: testPkg, Builder: "linux-386", Hash: "1001", GoHash: "0001", OK: true}, nil},
{"/todo", url.Values{"kind": {"build-package"}, "builder": {"linux-386"}, "packagePath": {testPkg}, "goHash": {"0001"}}, nil, nil}, {"/todo", url.Values{"kind": {"build-package"}, "builder": {"linux-386"}, "packagePath": {testPkg}, "goHash": {"0001"}}, nil, nil},
{"/todo", url.Values{"kind": {"build-package"}, "builder": {"linux-386"}, "packagePath": {testPkg}, "goHash": {"0002"}}, nil, &Todo{Kind: "build-package", Data: &Commit{Hash: "1003"}}}, {"/todo", url.Values{"kind": {"build-package"}, "builder": {"linux-386"}, "packagePath": {testPkg}, "goHash": {"0002"}}, nil, &Todo{Kind: "build-package", Data: &Commit{Hash: "1003"}}},
// re-build Go revision for stale subrepos
{"/todo", url.Values{"kind": {"build-go-commit"}, "builder": {"linux-386"}}, nil, &Todo{Kind: "build-go-commit", Data: &Commit{Hash: "0005"}}},
{"/result", nil, &Result{PackagePath: testPkg, Builder: "linux-386", Hash: "1001", GoHash: "0005", OK: false, Log: "boo"}, nil}, {"/result", nil, &Result{PackagePath: testPkg, Builder: "linux-386", Hash: "1001", GoHash: "0005", OK: false, Log: "boo"}, nil},
{"/todo", url.Values{"kind": {"build-go-commit"}, "builder": {"linux-386"}}, nil, nil},
} }
func testHandler(w http.ResponseWriter, r *http.Request) { func testHandler(w http.ResponseWriter, r *http.Request) {
@ -215,8 +219,8 @@ func testHandler(w http.ResponseWriter, r *http.Request) {
errorf("Response.Data not *Commit: %T", g.Data) errorf("Response.Data not *Commit: %T", g.Data)
return return
} }
if e.Data.(*Commit).Hash != gd.Hash { if eh := e.Data.(*Commit).Hash; eh != gd.Hash {
errorf("hashes don't match: got %q, want %q", g, e) errorf("hashes don't match: got %q, want %q", gd.Hash, eh)
return return
} }
} }

View File

@ -145,7 +145,7 @@ func TagState(c appengine.Context, name string) ([]*PackageState, os.Error) {
for _, pkg := range pkgs { for _, pkg := range pkgs {
commit, err := pkg.LastCommit(c) commit, err := pkg.LastCommit(c)
if err != nil { if err != nil {
c.Errorf("no Commit found: %v", pkg) c.Warningf("%v: no Commit found: %v", pkg, err)
continue continue
} }
results := commit.Results(tag.Hash) results := commit.Results(tag.Hash)