Skip to content

Commit

Permalink
Merge branch 'flutter:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardoamador authored Jan 12, 2024
2 parents a27052b + 919cc8a commit 01256f1
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 21 deletions.
5 changes: 5 additions & 0 deletions app_dart/lib/src/service/github_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,11 @@ class GithubService {
);
}

/// Gets label list for an issue.
Future<List<IssueLabel>> getIssueLabels(RepositorySlug slug, int issueNumber) async {
return github.issues.listLabelsByIssue(slug, issueNumber).toList();
}

/// Adds labels to an issue.
///
/// A pull request is an issue. This works for pull requests as well.
Expand Down
20 changes: 10 additions & 10 deletions app_dart/lib/src/service/luci_build_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import 'cache_service.dart';
import 'config.dart';
import 'exceptions.dart';
import 'gerrit_service.dart';
import 'github_service.dart';

const Set<String> taskFailStatusSet = <String>{
Task.statusInfraFailure,
Expand Down Expand Up @@ -203,15 +204,6 @@ class LuciBuildService {
final Map<String, Object> properties = target.getProperties();
properties.putIfAbsent('git_branch', () => pullRequest.base!.ref!.replaceAll('refs/heads/', ''));

final List<String>? labels = pullRequest.labels
?.where((label) => label.name.startsWith(githubBuildLabelPrefix))
.map((obj) => obj.name)
.toList();

if (labels != null && labels.isNotEmpty) {
properties[propertiesGithubBuildLabelName] = labels;
}

requests.add(
Request(
scheduleBuild: _createPresubmitScheduleBuild(
Expand Down Expand Up @@ -363,7 +355,15 @@ class LuciBuildService {
'commit_branch': branch,
'commit_sha': sha,
};
final Map<String, Object>? properties = build.input!.properties;
final Map<String, Object> properties = Map.of(build.input!.properties ?? <String, Object>{});
final GithubService githubService = await config.createGithubService(slug);
final List<github.IssueLabel> issueLabels = await githubService.getIssueLabels(slug, prNumber);
final List<String> labels =
issueLabels.where((label) => label.name.startsWith(githubBuildLabelPrefix)).map((obj) => obj.name).toList();

if (labels.isNotEmpty) {
properties[propertiesGithubBuildLabelName] = labels;
}
log.info('input ${build.input!} properties $properties');

final ScheduleBuildRequest scheduleBuildRequest = _createPresubmitScheduleBuild(
Expand Down
12 changes: 3 additions & 9 deletions app_dart/test/service/luci_build_service_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -341,11 +341,7 @@ void main() {
});

test('schedule try builds with github build labels successfully', () async {
final issueLabels = [
IssueLabel(name: '${LuciBuildService.githubBuildLabelPrefix}hello'),
IssueLabel(name: '${LuciBuildService.githubBuildLabelPrefix}world'),
];
final PullRequest pullRequest = generatePullRequest(labels: issueLabels);
final PullRequest pullRequest = generatePullRequest();
when(mockBuildBucketClient.batch(any)).thenAnswer((_) async {
return BatchResponse(
responses: <Response>[
Expand Down Expand Up @@ -393,10 +389,6 @@ void main() {
'git_ref': 'refs/pull/123/head',
'exe_cipd_version': 'refs/heads/main',
'recipe': 'devicelab/devicelab',
LuciBuildService.propertiesGithubBuildLabelName: [
'${LuciBuildService.githubBuildLabelPrefix}hello',
'${LuciBuildService.githubBuildLabelPrefix}world',
],
});
expect(dimensions.length, 1);
expect(dimensions[0].key, 'os');
Expand Down Expand Up @@ -768,6 +760,8 @@ void main() {
'repo_name': 'flutter',
'user_agent': 'flutter-cocoon',
});
final Map<String, Object>? properties = scheduleBuildRequest.properties;
expect(properties!['overrides'], ['override: test']);
});
});

Expand Down
5 changes: 5 additions & 0 deletions app_dart/test/src/service/fake_github_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ class FakeGithubService implements GithubService {
return GitReference();
}

@override
Future<List<IssueLabel>> getIssueLabels(RepositorySlug slug, int issueNumber) {
return Future.value(<IssueLabel>[IssueLabel(name: 'override: test')]);
}

@override
Future<List<Issue>> listIssues(
RepositorySlug slug, {
Expand Down
2 changes: 1 addition & 1 deletion auto_submit/lib/service/approver_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class ApproverService {
// TODO(ricardoamador) this will need to be refactored to make this code more general and
// not applicable to only flutter.
await for (github.PullRequestReview review in reviews) {
if (review.user.login == 'fluttergithubbot' && review.state == 'APPROVED') {
if (review.user?.login == 'fluttergithubbot' && review.state == 'APPROVED') {
// Already approved.
return;
}
Expand Down
2 changes: 1 addition & 1 deletion auto_submit/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ environment:
dependencies:
appengine: 0.13.7
corsac_jwt: 1.0.0-nullsafety.1
github: 9.20.0
github: 9.22.0
googleapis: 11.4.0
googleapis_auth: 1.4.1
graphql: 5.2.0-beta.7
Expand Down

0 comments on commit 01256f1

Please sign in to comment.