From 80bb89ed4e8fe96ce231cb4b6ac19943d186b57c Mon Sep 17 00:00:00 2001 From: keyonghan <54558023+keyonghan@users.noreply.github.com> Date: Fri, 5 Jan 2024 13:49:33 -0800 Subject: [PATCH] Skip priority bump for already bringup true target in Flake Bot (#3400) Fixes: https://github.com/flutter/flutter/issues/140886 --- .../update_existing_flaky_issues.dart | 7 +++++++ .../update_existing_flaky_issues_test.dart | 13 +++++-------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/app_dart/lib/src/request_handlers/update_existing_flaky_issues.dart b/app_dart/lib/src/request_handlers/update_existing_flaky_issues.dart index d1f2b58e3..e581e4655 100644 --- a/app_dart/lib/src/request_handlers/update_existing_flaky_issues.dart +++ b/app_dart/lib/src/request_handlers/update_existing_flaky_issues.dart @@ -87,6 +87,7 @@ class UpdateExistingFlakyIssue extends ApiRequestHandler { GithubService gitHub, RepositorySlug slug, { required Bucket bucket, + required bool bringup, required BuilderStatistic statistic, required Issue existingIssue, required CiYaml ciYaml, @@ -97,6 +98,10 @@ class UpdateExistingFlakyIssue extends ApiRequestHandler { final IssueUpdateBuilder updateBuilder = IssueUpdateBuilder(statistic: statistic, threshold: _threshold, existingIssue: existingIssue, bucket: bucket); await gitHub.createComment(slug, issueNumber: existingIssue.number, body: updateBuilder.issueUpdateComment); + // No need to bump priority and reassign if this is already marked as `bringup: true`. + if (bringup) { + return; + } await gitHub.replaceLabelsForIssue(slug, issueNumber: existingIssue.number, labels: updateBuilder.issueLabels); if (existingIssue.assignee == null && !updateBuilder.isBelow) { final String testOwnerContent = await gitHub.getFileContent( @@ -150,6 +155,7 @@ class UpdateExistingFlakyIssue extends ApiRequestHandler { gitHub, slug, bucket: Bucket.prod, + bringup: builderFlakyMap[statistic.name]!, statistic: statistic, existingIssue: nameToExistingIssue[statistic.name]!, ciYaml: ciYaml, @@ -166,6 +172,7 @@ class UpdateExistingFlakyIssue extends ApiRequestHandler { gitHub, slug, bucket: Bucket.staging, + bringup: builderFlakyMap[statistic.name]!, statistic: statistic, existingIssue: nameToExistingIssue[statistic.name]!, ciYaml: ciYaml, diff --git a/app_dart/test/request_handlers/update_existing_flaky_issues_test.dart b/app_dart/test/request_handlers/update_existing_flaky_issues_test.dart index 698ec38ae..77c8d2ddb 100644 --- a/app_dart/test/request_handlers/update_existing_flaky_issues_test.dart +++ b/app_dart/test/request_handlers/update_existing_flaky_issues_test.dart @@ -271,7 +271,8 @@ void main() { .single as Map; // Verify comment is created correctly. - List captured = verify(mockIssuesService.createComment(captureAny, captureAny, captureAny)).captured; + final List captured = + verify(mockIssuesService.createComment(captureAny, captureAny, captureAny)).captured; expect(captured.length, 6); expect(captured[0].toString(), Config.flutterSlug.toString()); expect(captured[1], existingIssueNumber); @@ -280,18 +281,14 @@ void main() { expect(captured[4], existingIssueNumber); expect(captured[5], expectedStagingCiyamlTestIssueComment); - // Verify labels are applied correctly. - captured = verify( + // Verify no labels are applied for already `bringup: true` target. + verifyNever( mockGitHubClient.request( captureAny, captureAny, body: captureAnyNamed('body'), ), - ).captured; - expect(captured.length, 6); - expect(captured[0].toString(), 'PUT'); - expect(captured[1], '/repos/${Config.flutterSlug.fullName}/issues/$existingIssueNumber/labels'); - expect(captured[2], GitHubJson.encode(['some random label', 'P0'])); + ); expect(result['Status'], 'success'); });