Skip to content

Commit

Permalink
Skip priority bump for already bringup true target in Flake Bot (#3400)
Browse files Browse the repository at this point in the history
  • Loading branch information
keyonghan authored Jan 5, 2024
1 parent 68b7b1e commit 80bb89e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ class UpdateExistingFlakyIssue extends ApiRequestHandler<Body> {
GithubService gitHub,
RepositorySlug slug, {
required Bucket bucket,
required bool bringup,
required BuilderStatistic statistic,
required Issue existingIssue,
required CiYaml ciYaml,
Expand All @@ -97,6 +98,10 @@ class UpdateExistingFlakyIssue extends ApiRequestHandler<Body> {
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(
Expand Down Expand Up @@ -150,6 +155,7 @@ class UpdateExistingFlakyIssue extends ApiRequestHandler<Body> {
gitHub,
slug,
bucket: Bucket.prod,
bringup: builderFlakyMap[statistic.name]!,
statistic: statistic,
existingIssue: nameToExistingIssue[statistic.name]!,
ciYaml: ciYaml,
Expand All @@ -166,6 +172,7 @@ class UpdateExistingFlakyIssue extends ApiRequestHandler<Body> {
gitHub,
slug,
bucket: Bucket.staging,
bringup: builderFlakyMap[statistic.name]!,
statistic: statistic,
existingIssue: nameToExistingIssue[statistic.name]!,
ciYaml: ciYaml,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,8 @@ void main() {
.single as Map<String, dynamic>;

// Verify comment is created correctly.
List<dynamic> captured = verify(mockIssuesService.createComment(captureAny, captureAny, captureAny)).captured;
final List<dynamic> captured =
verify(mockIssuesService.createComment(captureAny, captureAny, captureAny)).captured;
expect(captured.length, 6);
expect(captured[0].toString(), Config.flutterSlug.toString());
expect(captured[1], existingIssueNumber);
Expand All @@ -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(<String>['some random label', 'P0']));
);

expect(result['Status'], 'success');
});
Expand Down

0 comments on commit 80bb89e

Please sign in to comment.