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

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

Issue 2944983003: [milo] {buildbucket,buildbot,swarming,logdog} -> backends/*. (Closed)
Patch Set: fix the tests Created 3 years, 6 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 | « milo/appengine/frontend/main_test.go ('k') | milo/appengine/job_source/buildbot/build_test.go » ('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 "errors" 9 "errors"
10 "fmt" 10 "fmt"
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 } 440 }
441 if got_revision != "" { 441 if got_revision != "" {
442 ss.Revision = resp.NewLink(got_revision, "") 442 ss.Revision = resp.NewLink(got_revision, "")
443 if repository != "" { 443 if repository != "" {
444 ss.Revision.URL = repository + "/+/" + got_revision 444 ss.Revision.URL = repository + "/+/" + got_revision
445 } 445 }
446 } 446 }
447 return ss 447 return ss
448 } 448 }
449 449
450 func getDebugBuild(c context.Context, builder string, buildNum int) (*buildbotBu ild, error) { 450 func renderBuild(c context.Context, b *buildbotBuild) *resp.MiloBuild {
451 » fname := fmt.Sprintf("%s.%d.json", builder, buildNum)
452 » // ../buildbot below assumes that
453 » // - this code is not executed by tests outside of this dir
454 » // - this dir is a sibling of frontend dir
455 » path := filepath.Join("..", "buildbot", "testdata", fname)
456 » raw, err := ioutil.ReadFile(path)
457 » if err != nil {
458 » » return nil, err
459 » }
460 » b := &buildbotBuild{}
461 » return b, json.Unmarshal(raw, b)
462 }
463
464 // build fetches a buildbot build and translates it into a miloBuild.
465 func Build(c context.Context, master, builder string, buildNum int) (*resp.MiloB uild, error) {
466 » var b *buildbotBuild
467 » var err error
468 » if master == "debug" {
469 » » b, err = getDebugBuild(c, builder, buildNum)
470 » } else {
471 » » b, err = getBuild(c, master, builder, buildNum)
472 » }
473 » if err != nil {
474 » » return nil, err
475 » }
476
477 // Modify the build for rendering. 451 // Modify the build for rendering.
478 updatePostProcessBuild(b) 452 updatePostProcessBuild(b)
479 453
480 // TODO(hinoka): Do all fields concurrently. 454 // TODO(hinoka): Do all fields concurrently.
481 return &resp.MiloBuild{ 455 return &resp.MiloBuild{
482 SourceStamp: sourcestamp(c, b), 456 SourceStamp: sourcestamp(c, b),
483 Summary: summary(c, b), 457 Summary: summary(c, b),
484 Components: components(b), 458 Components: components(b),
485 PropertyGroup: properties(b), 459 PropertyGroup: properties(b),
486 Blame: blame(b), 460 Blame: blame(b),
487 » }, nil 461 » }
462 }
463
464 // DebugBuild fetches a debugging build for testing.
465 func DebugBuild(c context.Context, relBuildbotDir string, builder string, buildN um int) (*resp.MiloBuild, error) {
466 » fname := fmt.Sprintf("%s.%d.json", builder, buildNum)
467 » // ../buildbot below assumes that
468 » // - this code is not executed by tests outside of this dir
469 » // - this dir is a sibling of frontend dir
470 » path := filepath.Join(relBuildbotDir, "testdata", fname)
471 » raw, err := ioutil.ReadFile(path)
472 » if err != nil {
473 » » return nil, err
474 » }
475 » b := &buildbotBuild{}
476 » if err := json.Unmarshal(raw, b); err != nil {
477 » » return nil, err
478 » }
479 » return renderBuild(c, b), nil
480 }
481
482 // Build fetches a buildbot build and translates it into a miloBuild.
483 func Build(c context.Context, master, builder string, buildNum int) (*resp.MiloB uild, error) {
484 » b, err := getBuild(c, master, builder, buildNum)
485 » if err != nil {
486 » » return nil, err
487 » }
488 » return renderBuild(c, b), nil
488 } 489 }
489 490
490 // updatePostProcessBuild transforms a build from its raw JSON format into the 491 // updatePostProcessBuild transforms a build from its raw JSON format into the
491 // format that should be presented to users. 492 // format that should be presented to users.
492 // 493 //
493 // Post-processing includes: 494 // Post-processing includes:
494 // - If the build is LogDog-only, promotes aliases (LogDog links) to 495 // - If the build is LogDog-only, promotes aliases (LogDog links) to
495 // first-class links in the build. 496 // first-class links in the build.
496 func updatePostProcessBuild(b *buildbotBuild) { 497 func updatePostProcessBuild(b *buildbotBuild) {
497 // If this is a LogDog-only build, we want to promote the LogDog links. 498 // If this is a LogDog-only build, we want to promote the LogDog links.
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 var newAliases map[string][]*buildbotLinkAlias 626 var newAliases map[string][]*buildbotLinkAlias
626 if l := remainingAliases.Len(); l > 0 { 627 if l := remainingAliases.Len(); l > 0 {
627 newAliases = make(map[string][]*buildbotLinkAlias, l) 628 newAliases = make(map[string][]*buildbotLinkAlias, l)
628 remainingAliases.Iter(func(v string) bool { 629 remainingAliases.Iter(func(v string) bool {
629 newAliases[v] = s.Aliases[v] 630 newAliases[v] = s.Aliases[v]
630 return true 631 return true
631 }) 632 })
632 } 633 }
633 s.Aliases = newAliases 634 s.Aliases = newAliases
634 } 635 }
OLDNEW
« no previous file with comments | « milo/appengine/frontend/main_test.go ('k') | milo/appengine/job_source/buildbot/build_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698