go.fuchsia.dev/infra@v0.0.0-20240507153436-9b593402251b/cmd/autogardener/affected.go (about) 1 // Copyright 2022 The Fuchsia Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 package main 6 7 import ( 8 "context" 9 _ "embed" 10 "time" 11 12 "cloud.google.com/go/bigquery" 13 buildbucketpb "go.chromium.org/luci/buildbucket/proto" 14 ) 15 16 //go:embed queries/affected_test_results.sql 17 var affectedTestResultsQuery string 18 19 type changeAffectingTest struct { 20 Change *buildbucketpb.GerritChange 21 TestStatus string 22 } 23 24 func getChangesAffectingTest( 25 ctx context.Context, 26 bqClient *bigquery.Client, 27 sig failureSignature, 28 windowEnd time.Time, 29 ) ([]changeAffectingTest, error) { 30 return runQuery[changeAffectingTest](ctx, bqClient, affectedTestResultsQuery, 31 map[string]any{ 32 "test_id": sig.FailedTest, 33 // Use a pretty large time window because tryjobs may have run up to 34 // 24 hours before the change landed. 35 "earliest_time": windowEnd.Add(-48 * time.Hour), 36 "latest_time": windowEnd, 37 }, 38 ) 39 }