| // 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 ( |
| "context" |
| _ "embed" |
| "time" |
| |
| "cloud.google.com/go/bigquery" |
| buildbucketpb "go.chromium.org/luci/buildbucket/proto" |
| ) |
| |
| //go:embed queries/affected_test_results.sql |
| var affectedTestResultsQuery string |
| |
| type changeAffectingTest struct { |
| Change *buildbucketpb.GerritChange |
| TestStatus string |
| } |
| |
| func getChangesAffectingTest( |
| ctx context.Context, |
| bqClient *bigquery.Client, |
| sig failureSignature, |
| windowEnd time.Time, |
| ) ([]changeAffectingTest, error) { |
| return runQuery[changeAffectingTest](ctx, bqClient, affectedTestResultsQuery, |
| map[string]any{ |
| "test_id": sig.FailedTest, |
| // Use a pretty large time window because tryjobs may have run up to |
| // 24 hours before the change landed. |
| "earliest_time": windowEnd.Add(-48 * time.Hour), |
| "latest_time": windowEnd, |
| }, |
| ) |
| } |