Skip bug creation for already `bringup: true` targets (#2236)
diff --git a/app_dart/lib/src/request_handlers/check_flaky_builders.dart b/app_dart/lib/src/request_handlers/check_flaky_builders.dart
index 5b40997..67714b3 100644
--- a/app_dart/lib/src/request_handlers/check_flaky_builders.dart
+++ b/app_dart/lib/src/request_handlers/check_flaky_builders.dart
@@ -68,8 +68,6 @@
);
final List<_BuilderInfo> eligibleBuilders =
await _getEligibleFlakyBuilders(gitHub, slug, content: ciContent, ciYaml: ciYaml);
- final List<BuilderStatistic> stagingBuilderStatisticList =
- await bigquery.listBuilderStatistic(kBigQueryProjectId, bucket: 'staging');
final String testOwnerContent = await gitHub.getFileContent(
slug,
kTestOwnerPath,
@@ -84,18 +82,6 @@
// Manually add a 1s delay between consecutive GitHub requests to deal with secondary rate limit error.
// https://docs.github.com/en/rest/guides/best-practices-for-integrators#dealing-with-secondary-rate-limits
await Future.delayed(config.githubRequestDelay);
- } else if (_shouldFileIssue(builderRecords, info)) {
- final BuilderDetail builderDetail = BuilderDetail(
- statistic: stagingBuilderStatisticList
- .where((BuilderStatistic builderStatistic) => builderStatistic.name == info.name)
- .single,
- existingIssue: null,
- existingPullRequest: null,
- isMarkedFlaky: true,
- type: type,
- ownership: testOwnership,
- );
- await fileFlakyIssue(builderDetail: builderDetail, gitHub: gitHub, slug: slug, bringup: true);
}
}
return Body.forJson(const <String, dynamic>{
@@ -103,17 +89,6 @@
});
}
- /// A new issue should be filed for staging builders if
- /// 1) there is any flake in recent runs
- /// 2) there is no open flaky bug tracking the flake
- bool _shouldFileIssue(List<BuilderRecord> builderRecords, _BuilderInfo info) {
- final bool noExistingOpenIssue = info.existingIssue == null ||
- info.existingIssue != null &&
- info.existingIssue!.isClosed &&
- DateTime.now().difference(info.existingIssue!.closedAt!) > const Duration(days: kGracePeriodForClosedFlake);
- return noExistingOpenIssue && builderRecords.any((BuilderRecord record) => record.isFlaky);
- }
-
/// A builder should be deflaked if satisfying three conditions.
/// 1) There are enough data records.
/// 2) There is no flake
diff --git a/app_dart/test/request_handlers/check_flaky_builders_test.dart b/app_dart/test/request_handlers/check_flaky_builders_test.dart
index c6efe29..17669f3 100644
--- a/app_dart/test/request_handlers/check_flaky_builders_test.dart
+++ b/app_dart/test/request_handlers/check_flaky_builders_test.dart
@@ -9,7 +9,6 @@
import 'package:cocoon_service/src/request_handlers/flaky_handler_utils.dart';
import 'package:cocoon_service/src/service/bigquery.dart';
import 'package:cocoon_service/src/service/github_service.dart';
-import 'package:collection/src/equality.dart';
import 'package:github/github.dart';
import 'package:mockito/mockito.dart';
import 'package:test/test.dart';
@@ -395,67 +394,6 @@
expect(result['Status'], 'success');
});
- test('Do not create pr but do create issue if the records have flaky runs and there is no open issue', () async {
- // When queries flaky data from BigQuery.
- when(mockBigqueryService.listRecentBuildRecordsForBuilder(kBigQueryProjectId,
- builder: captureAnyNamed('builder'), limit: captureAnyNamed('limit')))
- .thenAnswer((Invocation invocation) {
- return Future<List<BuilderRecord>>.value(semanticsIntegrationTestRecordsFlaky);
- });
- // When get issue
- when(mockIssuesService.get(captureAny, captureAny)).thenAnswer((_) {
- return Future<Issue>.value(Issue(
- state: 'closed',
- htmlUrl: existingIssueURL,
- closedAt: DateTime.now().subtract(const Duration(days: kGracePeriodForClosedFlake + 1)),
- ));
- });
- when(mockIssuesService.create(captureAny, captureAny)).thenAnswer((_) {
- return Future<Issue>.value(Issue());
- });
- // When queries flaky data from BigQuery.
- when(mockBigqueryService.listBuilderStatistic(kBigQueryProjectId, bucket: 'staging'))
- .thenAnswer((Invocation invocation) {
- return Future<List<BuilderStatistic>>.value(stagingSemanticsIntegrationTestResponse);
- });
-
- CheckFlakyBuilders.kRecordNumber = semanticsIntegrationTestRecordsAllPassed.length + 1;
- final Map<String, dynamic> result = await utf8.decoder
- .bind((await tester.get<Body>(handler)).serialize() as Stream<List<int>>)
- .transform(json.decoder)
- .single as Map<String, dynamic>;
-
- // Verify BigQuery is called correctly.
- List<dynamic> captured = verify(mockBigqueryService.listRecentBuildRecordsForBuilder(captureAny,
- builder: captureAnyNamed('builder'), limit: captureAnyNamed('limit')))
- .captured;
- expect(captured.length, 3);
- expect(captured[0].toString(), kBigQueryProjectId);
- expect(captured[1] as String?, expectedSemanticsIntegrationTestBuilderName);
- expect(captured[2] as int?, CheckFlakyBuilders.kRecordNumber);
-
- // Verify it gets the correct issue.
- captured = verify(mockIssuesService.get(captureAny, captureAny)).captured;
- expect(captured.length, 2);
- expect(captured[0], Config.flutterSlug);
- expect(captured[1] as int?, existingIssueNumber);
-
- // Verify pr is not created.
- verifyNever(mockPullRequestsService.create(captureAny, captureAny));
-
- // Verify issue is created correctly.
- captured = verify(mockIssuesService.create(captureAny, captureAny)).captured;
- expect(captured.length, 2);
- expect(captured[0].toString(), Config.flutterSlug.toString());
- expect(captured[1], isA<IssueRequest>());
- final IssueRequest issueRequest = captured[1] as IssueRequest;
- expect(issueRequest.assignee, expectedSemanticsIntegrationTestOwner);
- expect(const ListEquality<String>().equals(issueRequest.labels, expectedSemanticsIntegrationTestLabels), isTrue);
- expect(issueRequest.body, expectedSemanticsIntegrationTestResponseBody);
-
- expect(result['Status'], 'success');
- });
-
test('Do not create pr and do not create issue if the records have flaky runs and there is an open issue',
() async {
// When queries flaky data from BigQuery.