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
1 change: 1 addition & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ analyzer:
avoid_dynamic_calls: ignore
comment_references: ignore
deprecated_member_use_from_same_package: ignore
duplicate_ignore: ignore
lines_longer_than_80_chars: ignore
only_throw_errors: ignore
exclude:
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 @@ -9,7 +9,8 @@ import 'package:cocoon_server/google_auth_provider.dart';
import 'package:cocoon_server/secret_manager.dart';
import 'package:cocoon_service/cocoon_service.dart';
import 'package:cocoon_service/server.dart';
import 'package:cocoon_service/src/request_handling/dashboard_authentication.dart';
import 'package:cocoon_service/src/foundation/appengine_utils.dart';
import 'package:cocoon_service/src/foundation/providers.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 All @@ -24,6 +25,8 @@ Future<void> main() async {
await withAppEngineServices(() async {
useLoggingPackageAdaptor();

Providers.contextProvider = () => AppEngineClientContext(context);

// This is bad, and I should feel bad, but I won't because the logging system
// is inherently bad. We're allocating the logger (or getting back one) and
// then turning it off - there is no way to "filter". Luckily; the library
Expand Down
3 changes: 3 additions & 0 deletions app_dart/lib/cocoon_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

export 'src/foundation/context.dart';
export 'src/foundation/utils.dart';
export 'src/request_handlers/check_flaky_builders.dart';
export 'src/request_handlers/create_branch.dart';
Expand Down Expand Up @@ -32,6 +33,8 @@ export 'src/request_handlers/update_existing_flaky_issues.dart';
export 'src/request_handlers/vacuum_github_commits.dart';
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/pubsub.dart';
export 'src/request_handling/pubsub_authentication.dart';
export 'src/request_handling/request_handler.dart';
Expand Down
15 changes: 15 additions & 0 deletions app_dart/lib/src/foundation/appengine_utils.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// 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 'package:appengine/appengine.dart' as gae;

import 'context.dart';

class AppEngineClientContext implements ClientContext {
final gae.ClientContext _context;
AppEngineClientContext(this._context);

@override
bool get isDevelopmentEnvironment => _context.isDevelopmentEnvironment;
}
12 changes: 12 additions & 0 deletions app_dart/lib/src/foundation/context.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// 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.

/// A context for the current request.
///
/// This abstracts the underlying App Engine context to avoid direct dependencies
/// on package:appengine in core logic.
abstract class ClientContext {
/// Whether the application is running in the development environment.
bool get isDevelopmentEnvironment;
}
15 changes: 7 additions & 8 deletions app_dart/lib/src/foundation/providers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:appengine/appengine.dart' as gae;
import 'package:http/http.dart' as http;

import 'context.dart';
import 'typedefs.dart';

/// Class that holds static default providers.
Expand All @@ -18,17 +18,16 @@ class Providers {
/// * [HttpClientProvider], which defines this interface.
static http.Client freshHttpClient() => http.Client();

/// Default [gae.Logging] provider.
/// Initializes the [ClientContext] provider.
///
/// See also:
///
/// * [LoggingProvider], which defines this interface.
static gae.Logging serviceScopeLogger() => gae.loggingService;
/// This must be called before [serviceScopeContext] is used.
static ClientContextProvider contextProvider = () =>
throw UnimplementedError('ClientContext provider not initialized');

/// Default [gae.ClientContext] provider.
/// Default [ClientContext] provider.
///
/// See also:
///
/// * [ClientContextProvider], which defines this interface.
static gae.ClientContext serviceScopeContext() => gae.context;
static ClientContext serviceScopeContext() => contextProvider();
}
3 changes: 2 additions & 1 deletion app_dart/lib/src/foundation/typedefs.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:appengine/appengine.dart';
import 'package:http/http.dart' as http;

import 'context.dart';

/// Signature for a function that returns an App Engine [ClientContext].
///
/// This is used in [AuthenticationProvider] to provide the client context
Expand Down
2 changes: 1 addition & 1 deletion app_dart/lib/src/request_handling/authentication.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import 'dart:async';
import 'dart:io';

import 'package:appengine/appengine.dart';
import 'package:meta/meta.dart';

import '../foundation/context.dart';
import 'exceptions.dart';

@immutable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import 'dart:async';
import 'dart:io';

import 'package:appengine/appengine.dart';
import 'package:cocoon_server/logging.dart';
import 'package:github/github.dart';
import 'package:meta/meta.dart';
Expand All @@ -15,7 +14,6 @@ import '../foundation/providers.dart';
import '../foundation/typedefs.dart';
import '../model/google/token_info.dart';
import '../service/firebase_jwt_validator.dart';
import 'dashboard_authentication.dart';
import 'exceptions.dart';

/// Class capable of authenticating [HttpRequest]s from the Checkrun page.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import 'dart:async';
import 'dart:io';

import 'package:appengine/appengine.dart';
import 'package:cocoon_server/logging.dart';
import 'package:meta/meta.dart';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import 'dart:async';
import 'dart:io';

import 'package:appengine/appengine.dart';
import 'package:cocoon_server/logging.dart';
import 'package:googleapis/oauth2/v2.dart';
import 'package:meta/meta.dart';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import 'dart:async';
import 'dart:convert';
import 'dart:io';

import 'package:appengine/appengine.dart';
import 'package:cocoon_server/logging.dart';
import 'package:meta/meta.dart';

Expand Down
2 changes: 2 additions & 0 deletions app_dart/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ dev_dependencies:
build_runner: ^2.4.15
cocoon_common_test:
path: ../packages/cocoon_common_test
cocoon_integration_test:
path: ../packages/cocoon_integration_test
cocoon_server_test:
path: ../packages/cocoon_server_test
dart_flutter_team_lints: 3.5.2
Expand Down
4 changes: 1 addition & 3 deletions app_dart/test/foundation/utils_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'dart:io';

import 'package:cocoon_common/cocoon_common.dart';
import 'package:cocoon_common_test/cocoon_common_test.dart';
import 'package:cocoon_integration_test/testing.dart';
import 'package:cocoon_server/logging.dart';
import 'package:cocoon_server_test/test_logging.dart';
import 'package:cocoon_service/src/foundation/utils.dart';
Expand All @@ -18,9 +19,6 @@ import 'package:http/testing.dart';
import 'package:retry/retry.dart';
import 'package:test/test.dart';

import '../src/bigquery/fake_tabledata_resource.dart';
import '../src/utilities/entity_generators.dart';

const String branchRegExp = '''
master
flutter-1.1-candidate.1
Expand Down
4 changes: 1 addition & 3 deletions app_dart/test/model/ci_yaml/ci_yaml_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:cocoon_integration_test/testing.dart';
import 'package:cocoon_server_test/test_logging.dart';
import 'package:cocoon_service/protos.dart' as pb;
import 'package:cocoon_service/src/model/ci_yaml/ci_yaml.dart';
Expand All @@ -10,9 +11,6 @@ import 'package:cocoon_service/src/service/config.dart';
import 'package:cocoon_service/src/service/flags/ci_yaml_flags.dart';
import 'package:test/test.dart';

import '../../src/model/ci_yaml_matcher.dart';
import '../../src/service/fake_scheduler.dart';

void main() {
useTestLoggerPerTest();

Expand Down
4 changes: 1 addition & 3 deletions app_dart/test/model/ci_yaml/target_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:cocoon_integration_test/testing.dart';
import 'package:cocoon_server_test/test_logging.dart';
import 'package:cocoon_service/src/model/proto/internal/scheduler.pbenum.dart';
import 'package:cocoon_service/src/model/proto/protos.dart' as pb;
Expand All @@ -10,9 +11,6 @@ import 'package:cocoon_service/src/service/scheduler/policy.dart';
import 'package:github/github.dart' as github;
import 'package:test/test.dart';

import '../../src/model/ci_yaml_matcher.dart';
import '../../src/utilities/entity_generators.dart';

void main() {
useTestLoggerPerTest();

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

import 'package:cocoon_integration_test/testing.dart';
import 'package:cocoon_server_test/test_logging.dart';
import 'package:cocoon_service/src/model/common/presubmit_guard_conclusion.dart';
import 'package:cocoon_service/src/model/firestore/base.dart';
Expand All @@ -11,8 +12,6 @@ import 'package:github/github.dart';
import 'package:googleapis/firestore/v1.dart';
import 'package:test/test.dart';

import '../../src/service/fake_firestore_service.dart';

void main() {
useTestLoggerPerTest();

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

import 'package:cocoon_integration_test/testing.dart';
import 'package:cocoon_server_test/test_logging.dart';
import 'package:cocoon_service/src/model/firestore/commit.dart';
import 'package:test/test.dart';

import '../../src/service/fake_firestore_service.dart';
import '../../src/utilities/entity_generators.dart';

void main() {
useTestLoggerPerTest();

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

import 'package:cocoon_integration_test/testing.dart';
import 'package:cocoon_server_test/test_logging.dart';
import 'package:cocoon_service/src/model/firestore/github_build_status.dart';
import 'package:test/test.dart';

import '../../src/service/fake_firestore_service.dart';
import '../../src/utilities/entity_generators.dart';

void main() {
useTestLoggerPerTest();

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

import 'package:cocoon_integration_test/testing.dart';
import 'package:cocoon_server_test/test_logging.dart';
import 'package:cocoon_service/src/model/firestore/github_gold_status.dart';
import 'package:test/test.dart';

import '../../src/service/fake_firestore_service.dart';
import '../../src/utilities/entity_generators.dart';

void main() {
useTestLoggerPerTest();

Expand Down
4 changes: 1 addition & 3 deletions app_dart/test/model/firestore/pr_check_runs_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,14 @@

import 'dart:convert';

import 'package:cocoon_integration_test/testing.dart';
import 'package:cocoon_server_test/test_logging.dart';
import 'package:cocoon_service/src/model/common/firestore_extensions.dart';
import 'package:cocoon_service/src/model/firestore/pr_check_runs.dart';
import 'package:github/github.dart';
import 'package:googleapis/firestore/v1.dart';
import 'package:test/test.dart';

import '../../src/service/fake_firestore_service.dart';
import '../../src/utilities/entity_generators.dart';

void main() {
useTestLoggerPerTest();

Expand Down
3 changes: 1 addition & 2 deletions app_dart/test/model/firestore/presubmit_check_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@

import 'package:buildbucket/buildbucket_pb.dart' as bbv2;
import 'package:cocoon_common/task_status.dart';
import 'package:cocoon_integration_test/testing.dart';
import 'package:cocoon_server_test/test_logging.dart';
import 'package:cocoon_service/src/model/firestore/presubmit_check.dart';
import 'package:fixnum/fixnum.dart';
import 'package:googleapis/firestore/v1.dart';
import 'package:test/test.dart';

import '../../src/service/fake_firestore_service.dart';

void main() {
useTestLoggerPerTest();

Expand Down
4 changes: 1 addition & 3 deletions app_dart/test/model/firestore/task_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@ import 'dart:convert';

import 'package:buildbucket/buildbucket_pb.dart' as bbv2;
import 'package:cocoon_common/task_status.dart';
import 'package:cocoon_integration_test/testing.dart';
import 'package:cocoon_server_test/test_logging.dart';
import 'package:cocoon_service/src/model/firestore/task.dart';
import 'package:test/test.dart';

import '../../src/service/fake_firestore_service.dart';
import '../../src/utilities/entity_generators.dart';

void main() {
useTestLoggerPerTest();

Expand Down
3 changes: 1 addition & 2 deletions app_dart/test/model/ref_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@
// found in the LICENSE file.

import 'package:cocoon_common/task_status.dart';
import 'package:cocoon_integration_test/testing.dart';
import 'package:cocoon_server_test/test_logging.dart';
import 'package:cocoon_service/src/model/commit_ref.dart';
import 'package:cocoon_service/src/model/task_ref.dart';
import 'package:github/github.dart';
import 'package:test/test.dart';

import '../src/model/ref_matcher.dart';

void main() {
useTestLoggerPerTest();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import 'dart:convert';
import 'dart:io' as io;

import 'package:cocoon_integration_test/testing.dart';
import 'package:cocoon_server_test/mocks.dart';
import 'package:cocoon_server_test/test_logging.dart';
import 'package:cocoon_service/ci_yaml.dart';
Expand All @@ -20,11 +21,7 @@ import 'package:path/path.dart' as p;
import 'package:test/test.dart';
import 'package:yaml/yaml.dart';

import '../src/fake_config.dart';
import '../src/request_handling/api_request_handler_tester.dart';
import '../src/request_handling/fake_dashboard_authentication.dart';
import '../src/request_handling/fake_http.dart';
import '../src/utilities/mocks.dart';
import 'check_flaky_builders_test_data.dart';

const String kThreshold = '0.02';
Expand Down
Loading
Loading