Skip to content

Commit

Permalink
feat: upgrade to dart 3 compatible dependencies (#10890)
Browse files Browse the repository at this point in the history
* ci: check if compatible with dart 3

* ci: check if compatible with dart 3

* feat: upgrade deprecated setMockMethodCallHandler

* feat: remove deprecated code

* feat: remove deprecated code

* feat: remove deprecated code

* feat: remove deprecated code

* feat: update ODM to support new fields

* feat: update web tests

* feat: update web tests

* feat: go back to stable channel

* feat: downgrade meta to be compatible with 2.19 and 3.0

* feat: add optionnal access to defaultBinaryMessenger

* feat: fix some compatibility issues with dart 2.19 in tests

* feat: fix some compatibility issues with dart 2.19 in tests
  • Loading branch information
Lyokone authored May 4, 2023
1 parent 2d616b5 commit 4bd7e59
Show file tree
Hide file tree
Showing 82 changed files with 1,260 additions and 284 deletions.
94 changes: 49 additions & 45 deletions .github/workflows/e2e_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,40 +7,41 @@ concurrency:
on:
pull_request:
paths-ignore:
- "docs/**"
- "website/**"
- "**/example/**"
- "**/flutterfire_ui/**"
- "**/cloud_firestore_odm/**"
- "**.md"
- 'docs/**'
- 'website/**'
- '**/example/**'
- '**/flutterfire_ui/**'
- '**/cloud_firestore_odm/**'
- '**.md'
push:
branches:
- master
paths-ignore:
- "docs/**"
- "website/**"
- "**/example/**"
- "**/flutterfire_ui/**"
- "**/cloud_firestore_odm/**"
- "**.md"
- 'docs/**'
- 'website/**'
- '**/example/**'
- '**/flutterfire_ui/**'
- '**/cloud_firestore_odm/**'
- '**.md'

jobs:
android:
runs-on: macos-13
timeout-minutes: 45
strategy:
matrix:
working_directory: ['tests', 'packages/cloud_firestore/cloud_firestore/example']
working_directory:
['tests', 'packages/cloud_firestore/cloud_firestore/example']
steps:
- uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3
- uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c
name: Install Node.js 16
with:
node-version: "16"
node-version: '16'
- uses: actions/setup-java@3f07048e3d294f56e9b90ac5ea2c6f74e9ad0f98
with:
distribution: "temurin"
java-version: "11"
distribution: 'temurin'
java-version: '11'
- uses: actions/cache@69d9d449aced6a2ede0bc19182fadc3a0a42d2b0
name: Gradle Cache
with:
Expand Down Expand Up @@ -69,9 +70,9 @@ jobs:
with:
run-bootstrap: false
melos-version: '3.0.1'
- name: "Bootstrap package"
- name: 'Bootstrap package'
run: melos bootstrap --scope tests
- name: "Install Tools"
- name: 'Install Tools'
run: |
sudo npm i -g firebase-tools
- name: Start Firebase Emulator
Expand All @@ -81,37 +82,38 @@ jobs:
run: |
echo "List installed packages"
$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager --list_installed
echo "Installing system image"
echo "y" | $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager "system-images;android-33;google_apis;x86_64"
echo "Creating AVD"
echo "no" | $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/avdmanager create avd -n test_emulator -k "system-images;android-33;google_apis;x86_64" --force
echo "Starting emulator"
$ANDROID_SDK_ROOT/emulator/emulator -avd test_emulator -no-audio -no-boot-anim -no-window &
adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done; input keyevent 82'
- name: "E2E Tests"
- name: 'E2E Tests'
working-directory: ${{ matrix.working_directory }}
run: |
flutter test integration_test/e2e_test.dart --dart-define=CI=true
flutter test integration_test/e2e_test.dart --dart-define=CI=true
ios:
runs-on: macos-13
timeout-minutes: 45
strategy:
matrix:
working_directory: ['tests', 'packages/cloud_firestore/cloud_firestore/example']
working_directory:
['tests', 'packages/cloud_firestore/cloud_firestore/example']
steps:
- uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3
- uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c
name: Install Node.js 16
with:
node-version: "16"
node-version: '16'
- uses: actions/setup-java@3f07048e3d294f56e9b90ac5ea2c6f74e9ad0f98
with:
distribution: "temurin"
java-version: "11"
distribution: 'temurin'
java-version: '11'
- uses: hendrikmuhs/ccache-action@fba817f3c0db4f854d7a3ee688241d6754da166e
name: Xcode Compile Cache
with:
Expand All @@ -138,12 +140,12 @@ jobs:
with:
run-bootstrap: false
melos-version: '3.0.1'
- name: "Bootstrap package"
- name: 'Bootstrap package'
run: melos bootstrap --scope tests
- name: "Install Tools"
- name: 'Install Tools'
run: |
sudo npm i -g firebase-tools
- name: "Build Application"
- name: 'Build Application'
working-directory: ${{ matrix.working_directory }}
run: |
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
Expand All @@ -156,7 +158,7 @@ jobs:
ccache -s
- name: Start Firebase Emulator
run: cd ./.github/workflows/scripts && ./start-firebase-emulator.sh
- name: "E2E Tests"
- name: 'E2E Tests'
working-directory: ${{ matrix.working_directory }}
run: |
# Boot simulator and wait for System app to be ready.
Expand All @@ -178,17 +180,18 @@ jobs:
timeout-minutes: 45
strategy:
matrix:
working_directory: ['tests', 'packages/cloud_firestore/cloud_firestore/example']
working_directory:
['tests', 'packages/cloud_firestore/cloud_firestore/example']
steps:
- uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3
- uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c
name: Install Node.js 16
with:
node-version: "16"
node-version: '16'
- uses: actions/setup-java@3f07048e3d294f56e9b90ac5ea2c6f74e9ad0f98
with:
distribution: "temurin"
java-version: "11"
distribution: 'temurin'
java-version: '11'
- uses: hendrikmuhs/ccache-action@fba817f3c0db4f854d7a3ee688241d6754da166e
name: Xcode Compile Cache
with:
Expand All @@ -215,12 +218,12 @@ jobs:
with:
run-bootstrap: false
melos-version: '3.0.1'
- name: "Bootstrap package"
- name: 'Bootstrap package'
run: melos bootstrap --scope tests
- name: "Install Tools"
- name: 'Install Tools'
run: |
sudo npm i -g firebase-tools
- name: "Build Application"
- name: 'Build Application'
working-directory: ${{ matrix.working_directory }}
run: |
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
Expand All @@ -233,7 +236,7 @@ jobs:
ccache -s
- name: Start Firebase Emulator
run: cd ./.github/workflows/scripts && ./start-firebase-emulator.sh
- name: "E2E Tests"
- name: 'E2E Tests'
working-directory: ${{ matrix.working_directory }}
run: |
flutter test \
Expand All @@ -246,17 +249,18 @@ jobs:
timeout-minutes: 15
strategy:
matrix:
working_directory: ['tests', 'packages/cloud_firestore/cloud_firestore/example']
working_directory:
['tests', 'packages/cloud_firestore/cloud_firestore/example']
steps:
- uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3
- uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c
name: Install Node.js 16
with:
node-version: "16"
node-version: '16'
- uses: actions/setup-java@3f07048e3d294f56e9b90ac5ea2c6f74e9ad0f98
with:
distribution: "temurin"
java-version: "11"
distribution: 'temurin'
java-version: '11'
- uses: subosito/flutter-action@dbf1fa04f4d2e52c33185153d06cdb5443aa189d
with:
channel: 'stable'
Expand All @@ -265,9 +269,9 @@ jobs:
with:
run-bootstrap: false
melos-version: '3.0.1'
- name: "Bootstrap package"
- name: 'Bootstrap package'
run: melos bootstrap --scope tests
- name: "Install Tools"
- name: 'Install Tools'
run: |
sudo npm i -g firebase-tools
- name: Cache Firebase Emulator
Expand All @@ -278,7 +282,7 @@ jobs:
restore-keys: firebase-emulators-v1
- name: Start Firebase Emulator
run: cd ./.github/workflows/scripts && ./start-firebase-emulator.sh
- name: "E2E Tests"
- name: 'E2E Tests'
working-directory: ${{ matrix.working_directory }}
# Web devices are not supported for the `flutter test` command yet. As a
# workaround we can use the `flutter drive` command. Tracking issue:
Expand Down
28 changes: 14 additions & 14 deletions .github/workflows/firebase_firestore_odm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ concurrency:
on:
pull_request:
paths:
- "packages/cloud_firestore/**"
- "packages/cloud_firestore_odm/**"
- ".github/workflows/firebase_firestore_odm.yaml"
- 'packages/cloud_firestore/**'
- 'packages/cloud_firestore_odm/**'
- '.github/workflows/firebase_firestore_odm.yaml'
push:
branches:
- master
paths-ignore:
- "docs/**"
- "**.md"
- 'docs/**'
- '**.md'

env:
FLUTTERFIRE_PLUGIN_SCOPE: "*cloud_firestore*"
FLUTTERFIRE_PLUGIN_SCOPE_EXAMPLE: "*cloud_firestore_odm_example*"
FLUTTERFIRE_PLUGIN_SCOPE: '*cloud_firestore*'
FLUTTERFIRE_PLUGIN_SCOPE_EXAMPLE: '*cloud_firestore_odm_example*'

jobs:
test:
Expand All @@ -37,14 +37,14 @@ jobs:
with:
run-bootstrap: false
melos-version: '3.0.1'
- name: "Bootstrap Workspace"
- name: 'Bootstrap Workspace'
run: |
melos bootstrap --scope="*firebase_core*" --scope="$FLUTTERFIRE_PLUGIN_SCOPE"
melos run odm:example_build_runner:build
melos run odm:generator_test_build_runner:build
- name: "Flutter Test"
- name: 'Flutter Test'
run: melos run odm:test:flutter --no-select
- name: "Dart Test"
- name: 'Dart Test'
run: melos run odm:test:dart --no-select

integration_test:
Expand All @@ -57,7 +57,7 @@ jobs:
- uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c
name: Install Node.js 16
with:
node-version: "16"
node-version: '16'
- uses: actions/setup-java@3f07048e3d294f56e9b90ac5ea2c6f74e9ad0f98
with:
distribution: 'temurin'
Expand All @@ -70,17 +70,17 @@ jobs:
with:
run-bootstrap: false
melos-version: '3.0.1'
- name: "Install Tools"
- name: 'Install Tools'
run: |
sudo npm i -g firebase-tools
- name: "Bootstrap Workspace"
- name: 'Bootstrap Workspace'
run: |
melos bootstrap --scope="*firebase_core*" --scope="$FLUTTERFIRE_PLUGIN_SCOPE"
melos run odm:example_build_runner:build
melos run odm:generator_test_build_runner:build
- name: Start Firebase Emulator
run: cd ./.github/workflows/scripts && ./start-firebase-emulator.sh
- name: "E2E Tests"
- name: 'E2E Tests'
working-directory: packages/cloud_firestore_odm/cloud_firestore_odm/example
# Web devices are not supported for the `flutter test` command yet. As a
# workaround we can use the `flutter drive` command. Tracking issue:
Expand Down
2 changes: 1 addition & 1 deletion packages/_flutterfire_internals/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ dependencies:
firebase_core_platform_interface: ^4.6.0
flutter:
sdk: flutter
meta: ^1.3.0
meta: ^1.8.0

dev_dependencies:
flutter_test:
Expand Down
6 changes: 3 additions & 3 deletions packages/cloud_firestore/cloud_firestore/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ false_secrets:
- dartpad/**

environment:
sdk: ">=2.18.0 <3.0.0"
flutter: ">=1.12.13+hotfix.5"
sdk: '>=2.18.0 <3.0.0'
flutter: '>=1.12.13+hotfix.5'

dependencies:
cloud_firestore_platform_interface: ^5.12.1
Expand All @@ -22,7 +22,7 @@ dependencies:
firebase_core_platform_interface: ^4.6.0
flutter:
sdk: flutter
meta: ^1.3.0
meta: ^1.8.0

dev_dependencies:
flutter_test:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import 'package:cloud_firestore_platform_interface/src/method_channel/method_cha
import 'package:cloud_firestore_platform_interface/src/method_channel/method_channel_query.dart';
import 'package:cloud_firestore_platform_interface/src/method_channel/utils/firestore_message_codec.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';

import './mock.dart';

Expand All @@ -21,7 +21,9 @@ void main() {
StandardMethodCodec(AggregateQueryMessageCodec()),
);

MethodChannelFirebaseFirestore.channel.setMockMethodCallHandler((call) async {
TestDefaultBinaryMessengerBinding.instance?.defaultBinaryMessenger
.setMockMethodCallHandler(MethodChannelFirebaseFirestore.channel,
(call) async {
if (call.method == 'AggregateQuery#count') {
return {
'count': kCount,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
// BSD-style license that can be found in the LICENSE file.

import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:cloud_firestore_platform_interface/src/method_channel/method_channel_firestore.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';

Expand All @@ -16,9 +16,14 @@ void main() {
MethodChannelFirebaseFirestore.channel = const MethodChannel(
'plugins.flutter.io/firebase_firestore',
StandardMethodCodec(TestFirestoreMessageCodec()),
)..setMockMethodCallHandler((call) async {
return null;
});
);

TestDefaultBinaryMessengerBinding.instance?.defaultBinaryMessenger
.setMockMethodCallHandler(MethodChannelFirebaseFirestore.channel,
(call) async {
return null;
});

late FirebaseFirestore firestore;
late FirebaseFirestore firestoreSecondary;

Expand Down
Loading

0 comments on commit 4bd7e59

Please sign in to comment.