diff --git a/app_dart/lib/src/request_handlers/file_flaky_issue_and_pr.dart b/app_dart/lib/src/request_handlers/file_flaky_issue_and_pr.dart index 10ab0bc95..6bca5d3cd 100644 --- a/app_dart/lib/src/request_handlers/file_flaky_issue_and_pr.dart +++ b/app_dart/lib/src/request_handlers/file_flaky_issue_and_pr.dart @@ -55,11 +55,7 @@ class FileFlakyIssueAndPR extends ApiRequestHandler { final Map nameToExistingPR = await getExistingPRs(gitHub, slug); int filedIssueAndPRCount = 0; for (final BuilderStatistic statistic in builderStatisticList) { - // Skip if ignore_flakiness is specified. - if (getIgnoreFlakiness(statistic.name, ciYaml)) { - continue; - } - if (statistic.flakyRate < _threshold) { + if (shouldSkip(statistic, ciYaml, targets)) { continue; } @@ -93,6 +89,22 @@ class FileFlakyIssueAndPR extends ApiRequestHandler { }); } + bool shouldSkip(BuilderStatistic statistic, CiYaml ciYaml, List targets) { + // Skips if the target has been removed from .ci.yaml. + if (!targets.map((e) => e.name).toList().contains(statistic.name)) { + return true; + } + // Skips if ignore_flakiness is specified. + if (getIgnoreFlakiness(statistic.name, ciYaml)) { + return true; + } + // Skips if the flaky percentage is below the threshold. + if (statistic.flakyRate < _threshold) { + return true; + } + return false; + } + double get _threshold => double.parse(request!.uri.queryParameters[kThresholdKey]!); Future _fileIssueAndPR( diff --git a/app_dart/test/request_handlers/file_flaky_issue_and_pr_test.dart b/app_dart/test/request_handlers/file_flaky_issue_and_pr_test.dart index f5ec497f2..1c44b27e8 100644 --- a/app_dart/test/request_handlers/file_flaky_issue_and_pr_test.dart +++ b/app_dart/test/request_handlers/file_flaky_issue_and_pr_test.dart @@ -672,6 +672,28 @@ void main() { expect(result['Status'], 'success'); }); + + test('skips when the target doesn not exist', () { + final YamlMap? ci = loadYaml(ciYamlContent) as YamlMap?; + final pb.SchedulerConfig unCheckedSchedulerConfig = pb.SchedulerConfig()..mergeFromProto3Json(ci); + final CiYaml ciYaml = CiYaml( + slug: Config.flutterSlug, + branch: Config.defaultBranch(Config.flutterSlug), + config: unCheckedSchedulerConfig, + ); + final BuilderStatistic builderStatistic = BuilderStatistic( + name: 'Mac_android test', + flakyRate: 0.5, + flakyBuilds: ['103', '102', '101'], + succeededBuilds: ['203', '202', '201'], + recentCommit: 'abc', + flakyBuildOfRecentCommit: '103', + flakyNumber: 3, + totalNumber: 6, + ); + final List targets = unCheckedSchedulerConfig.targets; + expect(handler.shouldSkip(builderStatistic, ciYaml, targets), true); + }); }); test('retrieveMetaTagsFromContent can work with different newlines', () async {