Skip to content

Commit

Permalink
Skip flake status check when target no longer exists (flutter#3441)
Browse files Browse the repository at this point in the history
  • Loading branch information
keyonghan authored Jan 24, 2024
1 parent 869c69f commit a22d1ad
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 5 deletions.
22 changes: 17 additions & 5 deletions app_dart/lib/src/request_handlers/file_flaky_issue_and_pr.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,7 @@ class FileFlakyIssueAndPR extends ApiRequestHandler<Body> {
final Map<String?, PullRequest> 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;
}

Expand Down Expand Up @@ -93,6 +89,22 @@ class FileFlakyIssueAndPR extends ApiRequestHandler<Body> {
});
}

bool shouldSkip(BuilderStatistic statistic, CiYaml ciYaml, List<pb.Target> 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<bool> _fileIssueAndPR(
Expand Down
22 changes: 22 additions & 0 deletions app_dart/test/request_handlers/file_flaky_issue_and_pr_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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: <String>['103', '102', '101'],
succeededBuilds: <String>['203', '202', '201'],
recentCommit: 'abc',
flakyBuildOfRecentCommit: '103',
flakyNumber: 3,
totalNumber: 6,
);
final List<pb.Target> targets = unCheckedSchedulerConfig.targets;
expect(handler.shouldSkip(builderStatistic, ciYaml, targets), true);
});
});

test('retrieveMetaTagsFromContent can work with different newlines', () async {
Expand Down

0 comments on commit a22d1ad

Please sign in to comment.