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

Side by Side Diff: milo/common/model/build_summary.go

Issue 2978293002: [milo] Add an (uncached) method to get console rows. (Closed)
Patch Set: make manifestkey its own type Created 3 years, 5 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
OLDNEW
1 // Copyright 2017 The LUCI Authors. 1 // Copyright 2017 The LUCI Authors.
2 // 2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License. 4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at 5 // You may obtain a copy of the License at
6 // 6 //
7 // http://www.apache.org/licenses/LICENSE-2.0 7 // http://www.apache.org/licenses/LICENSE-2.0
8 // 8 //
9 // Unless required by applicable law or agreed to in writing, software 9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, 10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and 12 // See the License for the specific language governing permissions and
13 // limitations under the License. 13 // limitations under the License.
14 14
15 package model 15 package model
16 16
17 import ( 17 import (
18 "bytes" 18 "bytes"
19 "time" 19 "time"
20 20
21 "github.com/luci/gae/service/datastore" 21 "github.com/luci/gae/service/datastore"
22 22
23 "github.com/luci/luci-go/common/data/cmpbin" 23 "github.com/luci/luci-go/common/data/cmpbin"
24 ) 24 )
25 25
26 // ManifestKey is an index entry for BuildSummary, which looks like
27 // 0 ++ project ++ console ++ manifest_name ++ url ++ revision.decode('hex')
28 //
29 // This is used to index this BuildSummary as the row for any consoles that it
30 // shows up in that use the Manifest/RepoURL/Revision indexing scheme.
31 //
32 // (++ is cmpbin concatenation)
33 //
34 // Example:
35 // 0 ++ "chromium" ++ "main" ++ "UNPATCHED" ++ "https://.../src.git" ++ deadbe ef
36 //
37 // The list of interested consoles is compiled at build summarization time.
38 type ManifestKey []byte
39
26 // BuildSummary is a datastore model which is used for storing staandardized 40 // BuildSummary is a datastore model which is used for storing staandardized
27 // summarized build data, and is used for backend-agnostic views (i.e. builders, 41 // summarized build data, and is used for backend-agnostic views (i.e. builders,
28 // console). It contains only data that: 42 // console). It contains only data that:
29 // * is necessary to render these simplified views 43 // * is necessary to render these simplified views
30 // * is present in all implementations (buildbot, buildbucket) 44 // * is present in all implementations (buildbot, buildbucket)
31 // 45 //
32 // This entity will live as a child of the various implementation's 46 // This entity will live as a child of the various implementation's
33 // representations of a build (e.g. buildbotBuild). It has various 'tag' fields 47 // representations of a build (e.g. buildbotBuild). It has various 'tag' fields
34 // so that it can be queried by the various backend-agnostic views. 48 // so that it can be queried by the various backend-agnostic views.
35 type BuildSummary struct { 49 type BuildSummary struct {
(...skipping 21 matching lines...) Expand all
57 CurrentStep Summary 71 CurrentStep Summary
58 72
59 // Manifests is a list of links to source manifests that this build repo rted. 73 // Manifests is a list of links to source manifests that this build repo rted.
60 Manifests []ManifestLink 74 Manifests []ManifestLink
61 75
62 // Patches is the list of patches which are associated with this build. 76 // Patches is the list of patches which are associated with this build.
63 // We reserve the multi-patch case for advanced (multi-repo) tryjobs... 77 // We reserve the multi-patch case for advanced (multi-repo) tryjobs...
64 // Typically there will only be one patch associated with a build. 78 // Typically there will only be one patch associated with a build.
65 Patches []PatchInfo 79 Patches []PatchInfo
66 80
67 » // ManifestRevisionIndex has a single entry for each 81 » // ManifestKeys is the list of ManifestKey entries for this BuildSummary .
68 » // 0 ++ project ++ console ++ manifest_name ++ url ++ revision.decode( 'hex') 82 » ManifestKeys []ManifestKey
69 » // which matched for this build. ++ is cmpbin concatenation.
70 » //
71 » // Example:
72 » // 0 ++ "chromium" ++ "main" ++ "UNPATCHED" ++ "https://.../src.git" + + deadbeef
73 » //
74 » // The list of interested consoles is compiled at build summarization ti me.
75 » ManifestRevisionIndex [][]byte
76 } 83 }
77 84
78 // AddManifestRevisionIndex adds a new entry to ManifestRevisionIndex. 85 // AddManifestKey adds a new entry to ManifestKey.
79 // 86 //
80 // `revision` should be the hex-decoded git revision. 87 // `revision` should be the hex-decoded git revision.
81 // 88 //
82 // It's up to the caller to ensure that entries in ManifestRevisionIndex aren't 89 // It's up to the caller to ensure that entries in ManifestKey aren't
83 // duplicated. 90 // duplicated.
84 func (bs *BuildSummary) AddManifestRevisionIndex(project, console, manifest, rep oURL string, revision []byte) { 91 func (bs *BuildSummary) AddManifestKey(project, console, manifest, repoURL strin g, revision []byte) {
92 » bs.ManifestKeys = append(bs.ManifestKeys,
93 » » NewPartialManifestKey(project, console, manifest, repoURL).AddRe vision(revision))
94 }
95
96 // PartialManifestKey is an incomplete ManifestKey key which can be made
97 // complete by calling AddRevision.
98 type PartialManifestKey []byte
99
100 // AddRevision appends a git revision (as bytes) to the PartialManifestKey,
101 // returning a full index value for BuildSummary.ManifestKey.
102 func (p PartialManifestKey) AddRevision(revision []byte) ManifestKey {
103 » var buf bytes.Buffer
104 » buf.Write(p)
105 » cmpbin.WriteBytes(&buf, revision)
106 » return buf.Bytes()
107 }
108
109 // NewPartialManifestKey generates a ManifestKey prefix corresponding to
110 // the given parameters.
111 func NewPartialManifestKey(project, console, manifest, repoURL string) PartialMa nifestKey {
85 var buf bytes.Buffer 112 var buf bytes.Buffer
86 cmpbin.WriteUint(&buf, 0) // version 113 cmpbin.WriteUint(&buf, 0) // version
87 cmpbin.WriteString(&buf, project) 114 cmpbin.WriteString(&buf, project)
88 cmpbin.WriteString(&buf, console) 115 cmpbin.WriteString(&buf, console)
89 cmpbin.WriteString(&buf, manifest) 116 cmpbin.WriteString(&buf, manifest)
90 cmpbin.WriteString(&buf, repoURL) 117 cmpbin.WriteString(&buf, repoURL)
91 » cmpbin.WriteBytes(&buf, revision) 118 » return PartialManifestKey(buf.Bytes())
92 » bs.ManifestRevisionIndex = append(bs.ManifestRevisionIndex, buf.Bytes())
93 } 119 }
OLDNEW
« no previous file with comments | « milo/buildsource/swarming/expectations/build-gerrit.json ('k') | milo/frontend/appengine/templates/pages/console.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698