Skip to content
Merged
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
5 changes: 5 additions & 0 deletions app_dart/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
include: ../analysis_options.yaml

analyzer:
exclude:
# Optional: exclude the generated file if you don't want it analyzed
- hook/build.dart

linter:
rules:
# a few rules listed below are the ones we would like to exclude from flutter_lint package, for app_dart
Expand Down
5 changes: 4 additions & 1 deletion app_dart/bin/gae_server.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import 'package:cocoon_service/cocoon_service.dart';
import 'package:cocoon_service/server.dart';
import 'package:cocoon_service/src/foundation/appengine_utils.dart';
import 'package:cocoon_service/src/foundation/providers.dart';
import 'package:cocoon_service/src/request_handling/http_io.dart';
import 'package:cocoon_service/src/service/big_query.dart';
import 'package:cocoon_service/src/service/build_status_service.dart';
import 'package:cocoon_service/src/service/commit_service.dart';
Expand Down Expand Up @@ -143,7 +144,9 @@ Future<void> main() async {
);

return runAppEngine(
server,
(HttpRequest request) async {
await server(request.toRequest());
},
onAcceptingConnections: (InternetAddress address, int port) {
final host = address.isLoopback ? 'localhost' : address.host;
print('Serving requests at http://$host:$port/');
Expand Down
32 changes: 32 additions & 0 deletions app_dart/hook/build.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright 2026 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'dart:io';

import 'package:native_assets_cli/native_assets_cli.dart';

void main(List<String> args) async {
await build(args, (config, output) async {
// 1. Read the source file (e.g., your App Engine config)
final configFile = File('config.yaml');
final content = await configFile.readAsString();

// 2. Define the path for the generated code
// It's best to put this in 'lib/src/generated_config.dart'
final outputFile = File('lib/src/generated_config.dart');

// 3. Write the file as a raw string constant
await outputFile.writeAsString("""
// GENERATED CODE - DO NOT MODIFY BY HAND
// Generated by build.dart hook

const String configFileContent =
r\'\'\'$content\'\'\';
""");

// 4. (Optional) Tell Dart that this hook depends on the config file
// This ensures that if config.yaml changes, the hook runs again.
output.addDependency(configFile.uri);
});
}
9 changes: 9 additions & 0 deletions app_dart/lib/cocoon_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@

export 'src/foundation/context.dart';
export 'src/foundation/utils.dart';
export 'src/model/firestore/base.dart' hide AppDocument;
export 'src/model/firestore/commit.dart';
export 'src/model/firestore/presubmit_check.dart';
export 'src/model/firestore/presubmit_guard.dart';
export 'src/model/firestore/suppressed_test.dart';
export 'src/model/firestore/task.dart';
export 'src/model/firestore/tree_status_change.dart';
export 'src/request_handlers/check_flaky_builders.dart';
export 'src/request_handlers/create_branch.dart';
export 'src/request_handlers/dart_internal_subscription.dart';
Expand Down Expand Up @@ -35,6 +42,7 @@ export 'src/request_handling/authentication.dart';
export 'src/request_handling/cache_request_handler.dart';
export 'src/request_handling/checkrun_authentication.dart';
export 'src/request_handling/dashboard_authentication.dart';
export 'src/request_handling/http_utils.dart';
export 'src/request_handling/pubsub.dart';
export 'src/request_handling/pubsub_authentication.dart';
export 'src/request_handling/request_handler.dart';
Expand All @@ -47,6 +55,7 @@ export 'src/service/build_bucket_client.dart';
export 'src/service/cache_service.dart';
export 'src/service/config.dart';
export 'src/service/firestore.dart';
export 'src/service/flags/dynamic_config.dart';
export 'src/service/gerrit_service.dart';
export 'src/service/github_checks_service.dart';
export 'src/service/luci_build_service.dart';
Expand Down
5 changes: 2 additions & 3 deletions app_dart/lib/server.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'dart:io';
import 'dart:math';

import 'cocoon_service.dart';
Expand All @@ -25,7 +24,7 @@ import 'src/service/content_aware_hash_service.dart';
import 'src/service/discord_service.dart';
import 'src/service/scheduler/ci_yaml_fetcher.dart';

typedef Server = Future<void> Function(HttpRequest);
typedef Server = Future<void> Function(Request);

/// Creates a service with the given dependencies.
Server createServer({
Expand Down Expand Up @@ -404,7 +403,7 @@ Server createServer({
'/readiness_check': ReadinessCheck(config: config),
};

return (HttpRequest request) async {
return (Request request) async {
if (handlers.containsKey(request.uri.path)) {
final handler = handlers[request.uri.path]!;
await handler.service(request);
Expand Down
2 changes: 1 addition & 1 deletion app_dart/lib/src/foundation/github_checks_util.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
// found in the LICENSE file.

import 'dart:core';
import 'dart:io';

import 'package:cocoon_server/logging.dart';
import 'package:github/github.dart' as github;
import 'package:github/hooks.dart';
import 'package:retry/retry.dart';

import '../request_handling/http_utils.dart';
import '../service/config.dart';

/// Wrapper class for github checkrun service. This is used to simplify
Expand Down
1 change: 0 additions & 1 deletion app_dart/lib/src/foundation/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import 'dart:async';
import 'dart:convert';
import 'dart:io';

import 'package:cocoon_server/logging.dart';
import 'package:github/github.dart';
Expand Down
35 changes: 35 additions & 0 deletions app_dart/lib/src/generated_config.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions app_dart/lib/src/model/firestore/account.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'dart:io';

import 'package:googleapis/firestore/v1.dart' as g;
import 'package:path/path.dart' as p;

import '../../request_handling/http_utils.dart';
import '../../service/firestore.dart';
import 'base.dart';

Expand Down
3 changes: 0 additions & 3 deletions app_dart/lib/src/model/firestore/commit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,12 @@
/// @docImport 'task.dart';
library;

import 'dart:io';

import 'package:github/github.dart';
import 'package:googleapis/firestore/v1.dart' hide Status;
import 'package:path/path.dart' as p;
import 'package:truncate/truncate.dart';

import '../../../cocoon_service.dart';
import '../../service/firestore.dart';
import '../commit_ref.dart';
import 'base.dart';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'dart:io';

import 'package:googleapis/firestore/v1.dart' as g;
import 'package:path/path.dart' as p;

import '../../request_handling/http_utils.dart';
import '../../service/firestore.dart';
import 'base.dart';

Expand Down
1 change: 0 additions & 1 deletion app_dart/lib/src/model/firestore/github_build_status.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import 'package:googleapis/firestore/v1.dart' hide Status;
import 'package:path/path.dart' as p;

import '../../../cocoon_service.dart';
import '../../service/firestore.dart';
import 'base.dart';

const String kGithubBuildStatusCollectionId = 'githubBuildStatuses';
Expand Down
1 change: 0 additions & 1 deletion app_dart/lib/src/model/firestore/github_gold_status.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import 'package:googleapis/firestore/v1.dart' hide Status;
import 'package:path/path.dart' as p;

import '../../../cocoon_service.dart';
import '../../service/firestore.dart';
import 'base.dart';

const String kGithubGoldStatusCollectionId = 'githubGoldStatuses';
Expand Down
1 change: 0 additions & 1 deletion app_dart/lib/src/model/firestore/presubmit_guard.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import 'package:googleapis/firestore/v1.dart' hide Status;
import 'package:path/path.dart' as p;

import '../../../cocoon_service.dart';
import '../../service/firestore.dart';
import 'base.dart';

final class PresubmitGuardId extends AppDocumentId<PresubmitGuard> {
Expand Down
1 change: 0 additions & 1 deletion app_dart/lib/src/model/firestore/task.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import 'package:meta/meta.dart';
import 'package:path/path.dart' as p;

import '../../../cocoon_service.dart';
import '../../service/firestore.dart';
import '../bbv2_extension.dart';
import '../ci_yaml/target.dart';
import '../task_ref.dart';
Expand Down
6 changes: 2 additions & 4 deletions app_dart/lib/src/request_handlers/get_build_status_badge.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
// found in the LICENSE file.

import 'dart:async';
import 'dart:io';

import 'package:cocoon_common/rpc_model.dart' as rpc_model;
import 'package:meta/meta.dart';

import '../request_handling/http_utils.dart';
import '../request_handling/request_handler.dart';
import '../request_handling/response.dart';
import 'get_build_status.dart';
Expand Down Expand Up @@ -48,12 +48,10 @@ final class GetBuildStatusBadge extends GetBuildStatus {
Future<Response> get(Request request) async {
return Response.string(
generateSVG(await super.createResponse(request)),
contentType: _imageSvgXml,
contentType: kImageSvgXml,
);
}

static final _imageSvgXml = ContentType.parse('image/svg+xml');

@visibleForTesting
String generateSVG(rpc_model.BuildStatusResponse response) {
final passing = response.failingTasks.isEmpty;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'dart:io';

import 'package:googleapis/firestore/v1.dart';

import '../../cocoon_service.dart';
import '../model/firestore/base.dart';
import '../model/firestore/ci_staging.dart';
import '../request_handling/exceptions.dart';
import '../request_handling/public_api_request_handler.dart';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// found in the LICENSE file.

import 'dart:async';
import 'dart:io';

import 'package:cocoon_common/rpc_model.dart';

Expand Down
1 change: 0 additions & 1 deletion app_dart/lib/src/request_handlers/get_presubmit_guard.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// found in the LICENSE file.

import 'dart:async';
import 'dart:io';

import 'package:cocoon_common/guard_status.dart';
import 'package:cocoon_common/rpc_model.dart' as rpc_model;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// found in the LICENSE file.

import 'dart:async';
import 'dart:io';
import 'dart:math';

import 'package:cocoon_common/guard_status.dart';
Expand All @@ -12,7 +11,6 @@ import 'package:github/github.dart';
import 'package:meta/meta.dart';

import '../../cocoon_service.dart';
import '../model/firestore/presubmit_guard.dart';
import '../request_handling/public_api_request_handler.dart';
import '../service/firestore/unified_check_run.dart';

Expand Down
1 change: 0 additions & 1 deletion app_dart/lib/src/request_handlers/get_status.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import 'package:github/github.dart';
import 'package:meta/meta.dart';

import '../../cocoon_service.dart';
import '../model/firestore/commit.dart';
import '../request_handling/public_api_request_handler.dart';
import '../service/build_status_service.dart';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import 'package:github/github.dart';
import 'package:meta/meta.dart';

import '../../cocoon_service.dart';
import '../model/firestore/suppressed_test.dart';
import '../request_handling/public_api_request_handler.dart';

/// Request handler to get a list of suppressed tests.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// found in the LICENSE file.

import 'dart:convert';
import 'dart:io';

import 'package:cocoon_common/is_release_branch.dart';
import 'package:cocoon_server/logging.dart';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
// found in the LICENSE file.

import 'dart:convert';
import 'dart:io';

import 'package:archive/archive.dart';
import 'package:buildbucket/buildbucket_pb.dart' as bbv2;
import 'package:cocoon_common/is_release_branch.dart';
import 'package:cocoon_server/logging.dart';
Expand Down Expand Up @@ -77,7 +77,9 @@ final class PostsubmitLuciSubscription extends SubscriptionHandler {
log.debug('Updating buildId=${build.id} for result=${build.status}');

// Add build fields that are stored in a separate compressed buffer.
build.mergeFromBuffer(ZLibCodec().decode(buildsPubSub.buildLargeFields));
build.mergeFromBuffer(
const ZLibDecoder().decodeBytes(buildsPubSub.buildLargeFields),
);
log.info('build ${build.toProto3Json()}');

final fsTask = await fs.Task.fromFirestore(_firestore, userData.taskId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
// found in the LICENSE file.

import 'dart:convert';
import 'dart:io';

import 'package:archive/archive.dart';
import 'package:buildbucket/buildbucket_pb.dart' as bbv2;
import 'package:cocoon_server/logging.dart';

Expand Down Expand Up @@ -80,7 +80,9 @@ final class PresubmitLuciSubscription extends SubscriptionHandler {
var build = buildsPubSub.build;

// Add build fields that are stored in a separate compressed buffer.
build.mergeFromBuffer(ZLibCodec().decode(buildsPubSub.buildLargeFields));
build.mergeFromBuffer(
const ZLibDecoder().decodeBytes(buildsPubSub.buildLargeFields),
);

final builderName = build.builder.builder;
final tagSet = BuildTags.fromStringPairs(build.tags);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import 'dart:async';
import 'dart:convert';
import 'dart:io';

import 'package:cocoon_server/logging.dart';
import 'package:github/github.dart';
Expand Down
Loading
Loading