Skip to content
Closed
Show file tree
Hide file tree
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
4 changes: 0 additions & 4 deletions app_dart/lib/src/datastore/cocoon_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,6 @@ class Config {

/// A List of try builders for LUCI
List<Map<String, dynamic>> get luciTryBuilders => <Map<String, String>>[
<String, String>{
'name': 'Cocoon',
'repo': 'cocoon',
},
<String, String>{
'name': 'Linux',
'repo': 'flutter',
Expand Down
36 changes: 5 additions & 31 deletions app_dart/lib/src/request_handlers/github_webhook.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@ import '../request_handling/exceptions.dart';
import '../request_handling/request_handler.dart';
import '../service/buildbucket.dart';

/// List of Github supported repos.
const Set<String> supportedRepos = <String>{'engine', 'flutter', 'cocoon'};

/// List of repos that require CQ+1 label.
const Set<String> needsCQLabelList = <String>{'flutter/flutter'};

@immutable
class GithubWebhook extends RequestHandler<Body> {
GithubWebhook(Config config, this.buildBucketClient, {HttpClient skiaClient})
Expand Down Expand Up @@ -62,8 +56,6 @@ class GithubWebhook extends RequestHandler<Body> {
return Body.empty;
} on FormatException {
throw const BadRequestException('Could not process input data.');
} on InternalServerError {
rethrow;
}
}

Expand Down Expand Up @@ -94,11 +86,6 @@ class GithubWebhook extends RequestHandler<Body> {
case 'ready_for_review':
case 'reopened':
await _checkForLabelsAndTests(event, isDraft);
await _scheduleIfMergeable(
event,
cancelRunningBuilds: event.action == 'edited',
labels: existingLabels,
);
break;
case 'labeled':
case 'synchronize':
Expand All @@ -109,10 +96,6 @@ class GithubWebhook extends RequestHandler<Body> {
);
break;
case 'unlabeled':
if (!needsCQLabelList
.contains(event.repository.fullName.toLowerCase())) {
break;
}
if (!await _checkForCqLabel(existingLabels)) {
await _cancelLuci(
event.repository.name,
Expand Down Expand Up @@ -148,14 +131,8 @@ class GithubWebhook extends RequestHandler<Body> {
}
// The mergeable flag may be null. False indicates there's a merge conflict,
// null indicates unknown. Err on the side of allowing the job to run.

// For flutter/flutter tests need to be optimized before enforcing CQ.
bool runCQ = true;
if (needsCQLabelList.contains(event.repository.fullName.toLowerCase())) {
runCQ = await _checkForCqLabel(labels);
}

if (runCQ) {
if (event.pullRequest.mergeable != false &&
await _checkForCqLabel(labels)) {
await _scheduleLuci(
number: event.number,
sha: event.pullRequest.head.sha,
Expand Down Expand Up @@ -209,7 +186,7 @@ class GithubWebhook extends RequestHandler<Body> {
]));
return batch.responses
.map((Response response) => response.searchBuilds)
.expand((SearchBuildsResponse response) => response.builds ?? <Build>[])
.expand((SearchBuildsResponse response) => response.builds)
.toList();
}

Expand All @@ -223,7 +200,7 @@ class GithubWebhook extends RequestHandler<Body> {
assert(sha != null);
assert(repositoryName != null);
assert(skipRunningCheck != null);
if (!supportedRepos.contains(repositoryName)) {
if (repositoryName != 'flutter' && repositoryName != 'engine') {
log.error('Unsupported repo on webhook: $repositoryName');
throw BadRequestException(
'Repository $repositoryName is not supported by this service.');
Expand Down Expand Up @@ -254,9 +231,6 @@ class GithubWebhook extends RequestHandler<Body> {
(Map<String, dynamic> builder) => builder['repo'] == repositoryName)
.map<String>((Map<String, dynamic> builder) => builder['name'])
.toList();
if (builderNames.isEmpty) {
throw InternalServerError('$repositoryName does not have any builders');
}

final List<Request> requests = <Request>[];
for (String builder in builderNames) {
Expand Down Expand Up @@ -311,7 +285,7 @@ class GithubWebhook extends RequestHandler<Body> {

Future<void> _cancelLuci(
String repositoryName, int number, String sha, String reason) async {
if (!supportedRepos.contains(repositoryName)) {
if (repositoryName != 'flutter' && repositoryName != 'engine') {
throw BadRequestException(
'This service does not support repository $repositoryName.');
}
Expand Down
2 changes: 1 addition & 1 deletion app_dart/lib/src/request_handlers/luci_status.dart
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class LuciStatusHandler extends RequestHandler<Body> {
}

Future<RepositorySlug> _getRepoNameForBuilder(String builderName) async {
final List<Map<String, dynamic>> builders = config.luciTryBuilders;
final List<Map<String, dynamic>> builders = config.luciBuilders;
final String repoName = builders.firstWhere(
(Map<String, dynamic> builder) =>
builder['name'] == builderName)['repo'];
Expand Down
Loading