}
// recordResult sends build results to the dashboard
-func (b *Builder) recordResult(ok bool, pkg, hash, goHash, buildLog string) error {
+func (b *Builder) recordResult(ok bool, pkg, hash, goHash, buildLog string, runTime time.Duration) error {
req := obj{
"Builder": b.name,
"PackagePath": pkg,
"GoHash": goHash,
"OK": ok,
"Log": buildLog,
+ "RunTime": runTime,
}
args := url.Values{"key": {b.key}, "builder": {b.name}}
return dash("POST", "result", args, req, nil)
// build
logfile := path.Join(workpath, "build.log")
+ startTime := time.Now()
buildLog, status, err := runLog(b.envv(), logfile, srcDir, *buildCmd)
+ runTime := time.Now().Sub(startTime)
if err != nil {
return fmt.Errorf("%s: %s", *buildCmd, err)
}
if status != 0 {
// record failure
- return b.recordResult(false, "", hash, "", buildLog)
+ return b.recordResult(false, "", hash, "", buildLog, runTime)
}
// record success
- if err = b.recordResult(true, "", hash, "", ""); err != nil {
+ if err = b.recordResult(true, "", hash, "", "", runTime); err != nil {
return fmt.Errorf("recordResult: %s", err)
}
}
// record the result
- err = b.recordResult(ok, pkg, hash, goHash, buildLog)
+ err = b.recordResult(ok, pkg, hash, goHash, buildLog, 0)
if err != nil {
log.Printf("buildPackages %s: %v", pkg, err)
}