Skip to content

Commit

Permalink
ignore redundant 'type-' labels (#309)
Browse files Browse the repository at this point in the history
sdk triage bot updates:
- if an issue already has a `type-` label, don't add any as part of the
triage process
- address feedback from
#271 (comment)

---

- [x] I’ve reviewed the contributor guide and applied the relevant
portions to this PR.

<details>
  <summary>Contribution guidelines:</summary><br>

- See our [contributor
guide](https://github.com/dart-lang/.github/blob/main/CONTRIBUTING.md)
for general expectations for PRs.
- Larger or significant changes should be discussed in an issue before
creating a PR.
- Contributions to our repos should follow the [Dart style
guide](https://dart.dev/guides/language/effective-dart) and use `dart
format`.
- Most changes should add an entry to the changelog and may need to [rev
the pubspec package
version](https://github.com/dart-lang/sdk/blob/main/docs/External-Package-Maintenance.md#making-a-change).
- Changes to packages require [corresponding
tests](https://github.com/dart-lang/.github/blob/main/CONTRIBUTING.md#Testing).

Note that many Dart repos have a weekly cadence for reviewing PRs -
please allow for some latency before initial review feedback.
</details>
  • Loading branch information
devoncarew authored Oct 24, 2024
1 parent d5c8c18 commit 673428a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
11 changes: 8 additions & 3 deletions pkgs/sdk_triage_bot/lib/triage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ Future<void> triage(
final issue = await githubService.fetchIssue(sdkSlug, issueNumber);
logger.log('## issue ${issue.htmlUrl}');
logger.log('');
final labels = issue.labels.map((l) => l.name).toList();
if (labels.isNotEmpty) {
logger.log('labels: ${labels.join(', ')}');
final existingLabels = issue.labels.map((l) => l.name).toList();
if (existingLabels.isNotEmpty) {
logger.log('labels: ${existingLabels.join(', ')}');
logger.log('');
}
logger.log('"${issue.title}"');
Expand Down Expand Up @@ -88,6 +88,11 @@ ${trimmedBody(comment.body ?? '')}
exit(1);
}

// If an issue already has a `type-` label, we don't need to apply more.
if (existingLabels.any((label) => label.startsWith('type-'))) {
newLabels.removeWhere((label) => label.startsWith('type-'));
}

// ask for the summary
String summary;
try {
Expand Down
22 changes: 22 additions & 0 deletions pkgs/sdk_triage_bot/test/triage_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,26 @@ void main() {
expect(githubService.updatedLabels, contains(startsWith('area-')));
expect(githubService.updatedLabels, contains('triage-automation'));
});

test('ignore redundant type labels', () async {
final githubService = GithubServiceMock();
final geminiService = GeminiServiceStub();

githubService.returnedIssue = Issue(
url: 'https://github.com/dart-lang/sdk/issues/55869',
title: 'Add full support for service ID zones',
number: mockIssueNumber,
body: 'Lorem ipsum.',
labels: [IssueLabel(name: 'type-enhancement')],
);

await triage(
mockIssueNumber,
githubService: githubService,
geminiService: geminiService,
logger: TestLogger(),
);

expect(githubService.updatedLabels, ['area-vm', 'triage-automation']);
});
}

0 comments on commit 673428a

Please sign in to comment.