blob: 03356db6ddba5838bd9aaad1e6bb60f207836a57 [file] [log] [blame]
// Copyright 2022 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package main
import (
buildbucketpb "go.chromium.org/luci/buildbucket/proto"
resultpb "go.chromium.org/luci/resultdb/proto/v1"
)
// failureSignature represents a single failure mode of a Buildbucket build,
// used for clustering builds to identify common failure modes.
//
// A single build might have multiple failure signatures.
type failureSignature struct {
FailedTest string `json:"failed_test"`
FailureReason string `json:"failure_reason"`
// TestGNLabel is the GN label of the failed test. It might be empty.
//
// TODO(olivernewman): GN label is just metadata and shouldn't be used for
// clustering. Figure out a way to avoid considering the GN label when
// grouping failed builds by failure mode; if a test gets moved from one GN
// label to another we shouldn't consider that a separate test.
TestGNLabel string `json:"gn_label"`
// TODO(olivernewman): also cluster by build summary text as a fallback.
}
// buildResult is a convenience type for bundling together the metadata of a
// build with the failed test results.
type buildResult struct {
Build *buildbucketpb.Build
FailedTests []*resultpb.TestResult
}
func (b buildResult) integrationRevisionCount() (int, bool) {
outputProps := b.Build.Output.Properties.AsMap()
count, ok := outputProps["integration-revision-count"]
if !ok {
return 0, false
}
return int(count.(float64)), true
}
// culpritFeature represents a numerical feature used to estimate a potential
// culprit change's likelihood of causing a given failure mode.
type culpritFeature struct {
Name string `json:"name"`
Score int `json:"score"`
Weight int `json:"weight"`
}