Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 19 additions & 38 deletions app_dart/lib/src/request_handlers/github/webhook_subscription.dart
Original file line number Diff line number Diff line change
Expand Up @@ -571,12 +571,19 @@ final class GithubWebhookSubscription extends SubscriptionHandler {

Future<void> _checkForTests(PullRequestEvent pullRequestEvent) async {
final pr = pullRequestEvent.pullRequest!;
// We do not need to add test labels if this is an auto roller author.
if (config.rollerAccounts.contains(pr.user!.login)) {
return;
}
final eventAction = pullRequestEvent.action;
final slug = pr.base!.repo!.slug();
final isTipOfTree = pr.base!.ref == Config.defaultBranch(slug);
final gitHubClient = await config.createGitHubClient(pullRequest: pr);
await _validateRefs(gitHubClient, pr);
if (kNeedsTests.contains(slug) && isTipOfTree) {
log.info(
'Applying framework repo labels for: owner=${slug.owner} repo=${slug.name} and pr=${pr.number}',
);
switch (slug.name) {
case 'flutter':
final isFusion = slug == Config.flutterSlug;
Expand All @@ -587,15 +594,16 @@ final class GithubWebhookSubscription extends SubscriptionHandler {
gitHubClient,
eventAction,
pr,
isFusion: isFusion,
files: files,
files,
slug,
);
if (isFusion) {
await _applyEngineRepoLabels(
gitHubClient,
eventAction,
pr,
files: files,
files,
slug,
);
}
case 'packages':
Expand All @@ -607,23 +615,14 @@ final class GithubWebhookSubscription extends SubscriptionHandler {
Future<void> _applyFrameworkRepoLabels(
GitHub gitHubClient,
String? eventAction,
PullRequest pr, {
bool isFusion = false,
List<PullRequestFile>? files,
}) async {
PullRequest pr,
List<PullRequestFile> files,
RepositorySlug slug,
) async {
if (pr.user!.login == 'engine-flutter-autoroll') {
return;
}

final slug = pr.base!.repo!.slug();
log.info(
'Applying framework repo labels for: owner=${slug.owner} repo=${slug.name} isFusion=$isFusion and pr=${pr.number}',
);

files ??= await gitHubClient.pullRequests
.listFiles(slug, pr.number!)
.toList();

final labels = <String>{};
var hasTests = false;
var needsTests = false;
Expand Down Expand Up @@ -668,11 +667,6 @@ final class GithubWebhookSubscription extends SubscriptionHandler {
);
}

// We do not need to add test labels if this is an auto roller author.
if (config.rollerAccounts.contains(pr.user!.login)) {
return;
}

if (!hasTests &&
needsTests &&
!pr.draft! &&
Expand Down Expand Up @@ -754,15 +748,15 @@ final class GithubWebhookSubscription extends SubscriptionHandler {
Future<void> _applyEngineRepoLabels(
GitHub gitHubClient,
String? eventAction,
PullRequest pr, {
List<PullRequestFile>? files,
}) async {
PullRequest pr,
List<PullRequestFile> files,
RepositorySlug slug,
) async {
// Do not apply the test labels for the autoroller accounts.
if (pr.user!.login == 'skia-flutter-autoroll') {
return;
}

final slug = pr.base!.repo!.slug();
var hasTests = false;
var needsTests = false;

Expand All @@ -772,9 +766,6 @@ final class GithubWebhookSubscription extends SubscriptionHandler {

var engineFiles = 0;

files ??= await gitHubClient.pullRequests
.listFiles(slug, pr.number!)
.toList();
for (var file in files) {
final path = file.filename!;
if (isFusion && _isFusionEnginePath(path)) {
Expand All @@ -800,11 +791,6 @@ final class GithubWebhookSubscription extends SubscriptionHandler {
return;
}

// We do not need to add test labels if this is an auto roller author.
if (config.rollerAccounts.contains(pr.user!.login)) {
return;
}

if (!hasTests &&
needsTests &&
!pr.draft! &&
Expand Down Expand Up @@ -882,11 +868,6 @@ final class GithubWebhookSubscription extends SubscriptionHandler {
}
}

// We do not need to add test labels if this is an auto roller author.
if (config.rollerAccounts.contains(pr.user!.login)) {
return;
}

if (!hasTests &&
needsTests &&
!pr.draft! &&
Expand Down