Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(970)

Side by Side Diff: milo/appengine/buildbot/build.go

Issue 2608493002: Milo: Parse <br> from step text and renders the line breaks (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | milo/appengine/buildbot/expectations/win_chromium_rel_ng.246309.build.json » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The LUCI Authors. All rights reserved. 1 // Copyright 2016 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0 2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file. 3 // that can be found in the LICENSE file.
4 4
5 package buildbot 5 package buildbot
6 6
7 import ( 7 import (
8 "encoding/json" 8 "encoding/json"
9 "fmt" 9 "fmt"
10 "io/ioutil" 10 "io/ioutil"
11 "net/http" 11 "net/http"
12 "path/filepath" 12 "path/filepath"
13 "regexp"
13 "sort" 14 "sort"
14 "strings" 15 "strings"
15 "time" 16 "time"
16 17
17 ds "github.com/luci/gae/service/datastore" 18 ds "github.com/luci/gae/service/datastore"
18 "github.com/luci/luci-go/common/data/stringset" 19 "github.com/luci/luci-go/common/data/stringset"
19 "github.com/luci/luci-go/common/logging" 20 "github.com/luci/luci-go/common/logging"
20 "github.com/luci/luci-go/milo/api/resp" 21 "github.com/luci/luci-go/milo/api/resp"
21 "github.com/luci/luci-go/milo/common/miloerror" 22 "github.com/luci/luci-go/milo/common/miloerror"
22 "golang.org/x/net/context" 23 "golang.org/x/net/context"
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 Source: source, 168 Source: source,
168 Duration: duration, 169 Duration: duration,
169 Type: resp.Summary, // This is more or less ignored. 170 Type: resp.Summary, // This is more or less ignored.
170 LevelsDeep: 1, 171 LevelsDeep: 1,
171 Text: []string{}, // Status messages. Eg "This build fai led on..xyz" 172 Text: []string{}, // Status messages. Eg "This build fai led on..xyz"
172 } 173 }
173 174
174 return sum 175 return sum
175 } 176 }
176 177
178 var rLineBreak = regexp.MustCompile("<br */*>")
estaab 2016/12/28 00:57:13 use "<br */?>" since only zero or one slash is exp
hinoka 2016/12/28 19:29:44 Done.
179
177 // components takes a full buildbot build struct and extract step info from all 180 // components takes a full buildbot build struct and extract step info from all
178 // of the steps and returns it as a list of milo Build Components. 181 // of the steps and returns it as a list of milo Build Components.
179 func components(b *buildbotBuild) (result []*resp.BuildComponent) { 182 func components(b *buildbotBuild) (result []*resp.BuildComponent) {
180 for _, step := range b.Steps { 183 for _, step := range b.Steps {
181 if step.Hidden == true { 184 if step.Hidden == true {
182 continue 185 continue
183 } 186 }
184 bc := &resp.BuildComponent{ 187 bc := &resp.BuildComponent{
185 Label: step.Name, 188 Label: step.Name,
186 » » » Text: step.Text, 189 » » }
190 » » // Step text sometimes contains <br>, which we want to parse int o new lines.
191 » » for _, t := range step.Text {
192 » » » for _, line := range rLineBreak.Split(t, -1) {
193 » » » » bc.Text = append(bc.Text, line)
194 » » » }
187 } 195 }
188 196
189 // Figure out the status. 197 // Figure out the status.
190 if !step.IsStarted { 198 if !step.IsStarted {
191 bc.Status = resp.NotRun 199 bc.Status = resp.NotRun
192 } else if !step.IsFinished { 200 } else if !step.IsFinished {
193 bc.Status = resp.Running 201 bc.Status = resp.Running
194 } else { 202 } else {
195 if len(step.Results) > 0 { 203 if len(step.Results) > 0 {
196 status := int(step.Results[0].(float64)) 204 status := int(step.Results[0].(float64))
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 484
477 // TODO(hinoka): Do all fields concurrently. 485 // TODO(hinoka): Do all fields concurrently.
478 return &resp.MiloBuild{ 486 return &resp.MiloBuild{
479 SourceStamp: sourcestamp(c, b), 487 SourceStamp: sourcestamp(c, b),
480 Summary: summary(c, b), 488 Summary: summary(c, b),
481 Components: components(b), 489 Components: components(b),
482 PropertyGroup: properties(b), 490 PropertyGroup: properties(b),
483 Blame: blame(b), 491 Blame: blame(b),
484 }, nil 492 }, nil
485 } 493 }
OLDNEW
« no previous file with comments | « no previous file | milo/appengine/buildbot/expectations/win_chromium_rel_ng.246309.build.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698