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

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

Issue 2979283002: Add manifest links and hack to index on revision. (Closed)
Patch Set: actually upload 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
« no previous file with comments | « milo/common/config.go ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "time" 19 "time"
19 20
20 "github.com/luci/gae/service/datastore" 21 "github.com/luci/gae/service/datastore"
22
23 "github.com/luci/luci-go/common/data/cmpbin"
21 ) 24 )
22 25
23 // BuildSummary is a datastore model which is used for storing staandardized 26 // BuildSummary is a datastore model which is used for storing staandardized
24 // summarized build data, and is used for backend-agnostic views (i.e. builders, 27 // summarized build data, and is used for backend-agnostic views (i.e. builders,
25 // console). It contains only data that: 28 // console). It contains only data that:
26 // * is necessary to render these simplified views 29 // * is necessary to render these simplified views
27 // * is present in all implementations (buildbot, buildbucket) 30 // * is present in all implementations (buildbot, buildbucket)
28 // 31 //
29 // This entity will live as a child of the various implementation's 32 // This entity will live as a child of the various implementation's
30 // representations of a build (e.g. buildbotBuild). It has various 'tag' fields 33 // representations of a build (e.g. buildbotBuild). It has various 'tag' fields
31 // so that it can be queried by the various backend-agnostic views. 34 // so that it can be queried by the various backend-agnostic views.
32 type BuildSummary struct { 35 type BuildSummary struct {
33 // _id for a BuildSummary is always 1 36 // _id for a BuildSummary is always 1
34 _ int64 `gae:"$id,1"` 37 _ int64 `gae:"$id,1"`
35 38
36 // BuildKey will always point to the "real" build, i.e. a buildbotBuild or 39 // BuildKey will always point to the "real" build, i.e. a buildbotBuild or
37 // a buildbucketBuild. It is always the parent key for the BuildSummary. 40 // a buildbucketBuild. It is always the parent key for the BuildSummary.
38 BuildKey *datastore.Key `gae:"$parent"` 41 BuildKey *datastore.Key `gae:"$parent"`
39 42
40 // Global identifier for the builder that this Build belongs to, i.e.: 43 // Global identifier for the builder that this Build belongs to, i.e.:
41 // "buildbot/<mastername>/<buildername>" 44 // "buildbot/<mastername>/<buildername>"
42 // "buildbucket/<bucketname>/<buildername>" 45 // "buildbucket/<bucketname>/<buildername>"
43 BuilderID string 46 BuilderID string
44 47
45 // KnownConsoleHash is used for backfilling and must always equal the ra w
46 // value of:
47 //
48 // sha256(sorted(ConsoleEpochs.keys())
49 //
50 // This is used to identify BuildSummaries which haven't yet been includ ed in
51 // some new Console definition (or which have been removed from a Consol e
52 // definition).
53 KnownConsoleHash []byte
54
55 // ConsoleEpochs is used for backfilling, and is a series of cmpbin tupl es:
56 //
57 // (console_name[str], recorded_epoch[int])
58 //
59 // This maps which epoch (version) of a console definition this BuildSum mary
60 // belongs to. Whenever a console definition changes, its epoch increase s. The
61 // backfiller will then identify BuildSummary objects which are out of d ate
62 // and update them.
63 ConsoleEpochs [][]byte
64
65 // ConsoleTags contains query tags for the console view. These are cmpbi n
66 // tuples which look like:
67 //
68 // (console_name[str], sort_criteria[tuple], sort_values[tuple])
69 //
70 // `sort_criteria` are defined by the console definition, and will likel y look
71 // like (manifest_name[str], repo_url[str]), but other sort_criteria may be
72 // added later.
73 //
74 // `sort_values` are defined by the selected sort_criteria, and will lik ely
75 // look like (commit_revision[str],). In any event, this string is opaqu e and
76 // only to be used by the console itself.
77 ConsoleTags [][]byte
78
79 // Created is the time when the Build was first created. Due to pending 48 // Created is the time when the Build was first created. Due to pending
80 // queues, this may be substantially before Summary.Start. 49 // queues, this may be substantially before Summary.Start.
81 Created time.Time 50 Created time.Time
82 51
83 // Summary summarizes relevant bits about the overall build. 52 // Summary summarizes relevant bits about the overall build.
84 Summary Summary 53 Summary Summary
85 54
86 // CurrentStep summarizes relevant bits about the currently running step (if 55 // CurrentStep summarizes relevant bits about the currently running step (if
87 // any). Only expected to be set if !Summary.Status.Terminal(). 56 // any). Only expected to be set if !Summary.Status.Terminal().
88 CurrentStep Summary 57 CurrentStep Summary
89 58
90 // Manifests is a list of links to source manifests that this build repo rted. 59 // Manifests is a list of links to source manifests that this build repo rted.
91 Manifests []ManifestLink 60 Manifests []ManifestLink
92 61
93 // Patches is the list of patches which are associated with this build. 62 // Patches is the list of patches which are associated with this build.
94 // We reserve the multi-patch case for advanced (multi-repo) tryjobs... 63 // We reserve the multi-patch case for advanced (multi-repo) tryjobs...
95 // Typically there will only be one patch associated with a build. 64 // Typically there will only be one patch associated with a build.
96 Patches []PatchInfo 65 Patches []PatchInfo
66
67 // ManifestRevisionIndex has a single entry for each
68 // 0 ++ project ++ console ++ manifest_name ++ url ++ revision.decode( 'hex')
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
97 } 76 }
77
78 // AddManifestRevisionIndex adds a new entry to ManifestRevisionIndex.
79 //
80 // `revision` should be the hex-decoded git revision.
81 //
82 // It's up to the caller to ensure that entries in ManifestRevisionIndex aren't
83 // duplicated.
84 func (bs *BuildSummary) AddManifestRevisionIndex(project, console, manifest, rep oURL string, revision []byte) {
85 var buf bytes.Buffer
86 cmpbin.WriteUint(&buf, 0) // version
87 cmpbin.WriteString(&buf, project)
88 cmpbin.WriteString(&buf, console)
89 cmpbin.WriteString(&buf, manifest)
90 cmpbin.WriteString(&buf, repoURL)
91 cmpbin.WriteBytes(&buf, revision)
92 bs.ManifestRevisionIndex = append(bs.ManifestRevisionIndex, buf.Bytes())
93 }
OLDNEW
« no previous file with comments | « milo/common/config.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698