Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(fdc): Initial Release of Data Connect #13313

Merged
merged 4 commits into from
Sep 17, 2024
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
230 changes: 230 additions & 0 deletions .github/workflows/e2e_tests_fdc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,230 @@
name: e2e-fdc

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

on:
pull_request:
paths-ignore:
- 'docs/**'
- 'website/**'
- '**/example/**'
- '**/flutterfire_ui/**'
- '**.md'
push:
branches:
- master
paths-ignore:
- 'docs/**'
- 'website/**'
- '**/example/**'
- '**.md'

jobs:
android:
runs-on: ubuntu-latest
timeout-minutes: 45
strategy:
fail-fast: false
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8
name: Install Node.js 20
with:
node-version: '20'
- uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9
with:
distribution: 'temurin'
java-version: '17'
- name: Firebase Emulator Cache
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9
with:
path: ~/.cache/firebase/emulators
key: firebase-emulators-v3-fdc-${{ runner.os }}
restore-keys: firebase-emulators-v3
- uses: subosito/flutter-action@44ac965b96f18d999802d4b807e3256d5a3f9fa1
with:
channel: 'stable'
cache: true
- name: Setup PostgreSQL for Linux/macOS/Windows
uses: ikalnytskyi/action-setup-postgres@v6
- uses: bluefireteam/melos-action@6085791af7036f6366c9a4b9d55105c0ef9c6388
with:
run-bootstrap: false
melos-version: '5.3.0'
- name: 'Bootstrap package'
run: melos bootstrap --scope "firebase_data_connect*"
- name: 'Install Tools'
run: |
sudo npm i -g firebase-tools
- name: Start Firebase Emulator
run: |
cd ./packages/firebase_data_connect/firebase_data_connect/example
unset PGSERVICEFILE
firebase experiments:enable dataconnect
./start-firebase-emulator.sh
- name: Enable KVM
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- name: Gradle cache
uses: gradle/actions/setup-gradle@v3
- name: AVD cache
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-${{ runner.os }}
- name: Start AVD then run E2E tests
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 34
target: google_apis
arch: x86_64
working-directory: 'packages/firebase_data_connect/firebase_data_connect/example'
script: |
flutter test integration_test/e2e_test.dart --dart-define=CI=true -d emulator-5554

ios:
runs-on: macos-14
timeout-minutes: 45
strategy:
fail-fast: false
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8
name: Install Node.js 20
with:
node-version: '20'
- uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9
with:
distribution: 'temurin'
java-version: '17'
- name: Setup PostgreSQL for Linux/macOS/Windows
uses: ikalnytskyi/action-setup-postgres@v6
- uses: hendrikmuhs/ccache-action@c92f40bee50034e84c763e33b317c77adaa81c92
name: Xcode Compile Cache
with:
key: xcode-cache-${{ runner.os }}
max-size: 700M
- uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9
name: Pods Cache
id: pods-cache
with:
path: tests/ios/Pods
key: ${{ runner.os }}-fdc-pods-v3-${{ hashFiles('tests/ios/Podfile.lock') }}
restore-keys: ${{ runner.os }}-ios-pods-v2
- name: Firebase Emulator Cache
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9
with:
path: ~/.cache/firebase/emulators
key: firebase-emulators-v3-fdc-${{ runner.os }}
restore-keys: firebase-emulators-v3
- uses: subosito/flutter-action@44ac965b96f18d999802d4b807e3256d5a3f9fa1
with:
channel: 'stable'
cache: true
- uses: bluefireteam/melos-action@6085791af7036f6366c9a4b9d55105c0ef9c6388
with:
run-bootstrap: false
melos-version: '5.3.0'
- name: 'Bootstrap package'
run: melos bootstrap --scope "firebase_data_connect*"
- name: 'Install Tools'
run: |
sudo npm i -g firebase-tools
- name: 'Build Application'
working-directory: 'packages/firebase_data_connect/firebase_data_connect/example'
run: |
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
export CCACHE_SLOPPINESS=clang_index_store,file_stat_matches,include_file_ctime,include_file_mtime,ivfsoverlay,pch_defines,modules,system_headers,time_macros
export CCACHE_FILECLONE=true
export CCACHE_DEPEND=true
export CCACHE_INODECACHE=true
ccache -s
flutter build ios --no-codesign --simulator --debug --target=./integration_test/e2e_test.dart --dart-define=CI=true
ccache -s
- name: Start Firebase Emulator
run: |
sudo chown -R 501:20 "/Users/runner/.npm"
cd ./packages/firebase_data_connect/firebase_data_connect/example
unset PGSERVICEFILE
firebase experiments:enable dataconnect
./start-firebase-emulator.sh
- name: 'E2E Tests'
working-directory: 'packages/firebase_data_connect/firebase_data_connect/example'
run: |
# Boot simulator and wait for System app to be ready.
# List of available simulators: https://github.com/actions/runner-images/blob/main/images/macos/macos-14-Readme.md#installed-simulators
SIMULATOR="iPhone 15"
xcrun simctl bootstatus "$SIMULATOR" -b
xcrun simctl logverbose "$SIMULATOR" enable
# Sleep to allow simulator to settle.
sleep 15
# Uncomment following line to have simulator logs printed out for debugging purposes.
# xcrun simctl spawn booted log stream --predicate 'eventMessage contains "flutter"' &
flutter test integration_test/e2e_test.dart -d "$SIMULATOR" --dart-define=CI=true

web:
runs-on: macos-latest
timeout-minutes: 15
strategy:
fail-fast: false
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8
name: Install Node.js 20
with:
node-version: '20'
- uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9
with:
distribution: 'temurin'
java-version: '17'
- name: Setup PostgreSQL for Linux/macOS/Windows
uses: ikalnytskyi/action-setup-postgres@v6
- uses: subosito/flutter-action@44ac965b96f18d999802d4b807e3256d5a3f9fa1
with:
channel: 'stable'
cache: true
- uses: bluefireteam/melos-action@6085791af7036f6366c9a4b9d55105c0ef9c6388
with:
run-bootstrap: false
melos-version: '5.3.0'
- name: 'Bootstrap package'
run: melos bootstrap --scope "firebase_data_connect*"
- name: 'Install Tools'
run: sudo npm i -g firebase-tools
- name: Cache Firebase Emulator
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9
with:
path: ~/.cache/firebase/emulators
key: firebase-emulators-v3-fdc-${{ runner.os }}
restore-keys: firebase-emulators-v3
- name: Start Firebase Emulator
run: |
sudo chown -R 501:20 "/Users/runner/.npm"
cd ./packages/firebase_data_connect/firebase_data_connect/example
unset PGSERVICEFILE
firebase experiments:enable dataconnect
./start-firebase-emulator.sh
- name: 'E2E Tests'
working-directory: 'packages/firebase_data_connect/firebase_data_connect/example'
# Web devices are not supported for the `flutter test` command yet. As a
# workaround we can use the `flutter drive` command. Tracking issue:
# https://github.com/flutter/flutter/issues/66264
run: |
chromedriver --port=4444 --trace-buffer-size=100000 &
flutter drive --target=./integration_test/e2e_test.dart --driver=./test_driver/integration_test.dart -d chrome --dart-define=CI=true | tee output.log
# We have to check the output for failed tests matching the string "[E]"
output=$(<output.log)
if [[ "$output" =~ \[E\] ]]; then
# You will see "All tests passed." in the logs even when tests failed.
echo "All tests did not pass. Please check the logs for more information."
exit 1
fi
shell: bash

10 changes: 5 additions & 5 deletions .github/workflows/scripts/firebase.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@
},
"emulators": {
"firestore": {
"port": "8080"
"port": 8080
},
"auth": {
"port": "9099"
"port": 9099
},
"storage": {
"port": "9199"
"port": 9199
},
"database": {
"port": "9000"
"port": 9000
},
"ui": {
"enabled": true,
Expand All @@ -31,4 +31,4 @@
"storage": {
"rules": "storage.rules"
}
}
}
2 changes: 2 additions & 0 deletions melos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ scripts:
--ignore "**/FlutterMultiDexApplication.java" \
--ignore "**/GeneratedPluginRegistrant.swift" \
--ignore "**/Pods/**" \
--ignore "**/generated/**" \
--ignore "**/flutter/generated_plugin_registrant.h" \
--ignore "**/flutter/generated_plugin_registrant.cc" \
.
Expand Down Expand Up @@ -317,6 +318,7 @@ scripts:
--ignore "**/FlutterMultiDexApplication.java" \
--ignore "**/GeneratedPluginRegistrant.swift" \
--ignore "**/Pods/**" \
--ignore "**/generated/**" \
--ignore "**/flutter/generated_plugin_registrant.h" \
--ignore "**/flutter/generated_plugin_registrant.cc" \
.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@
"client_info": {
"mobilesdk_app_id": "1:406099696497:android:3ef965ff044efc0b3574d0",
"android_client_info": {
"package_name": "io.flutter.plugins.firebase.database.example"
"package_name": "io.flutter.plugins.firebase.dataconnect.example"
}
},
"oauth_client": [
Expand Down
11 changes: 1 addition & 10 deletions packages/firebase_auth/firebase_auth/lib/src/firebase_auth.dart
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,7 @@ class FirebaseAuth extends FirebasePluginPlatform {
/// Do not use with production credentials as emulator traffic is not encrypted.
Future<void> useAuthEmulator(String host, int port,
{bool automaticHostMapping = true}) async {
String mappedHost = host;

if (!kIsWeb && defaultTargetPlatform == TargetPlatform.android) {
if ((mappedHost == 'localhost' || mappedHost == '127.0.0.1') &&
automaticHostMapping) {
// ignore: avoid_print
print('Mapping Auth Emulator host "$mappedHost" to "10.0.2.2".');
mappedHost = '10.0.2.2';
}
}
String mappedHost = automaticHostMapping ? getMappedHost(host) : host;

await _delegate.useAuthEmulator(mappedHost, port);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@
"client_info": {
"mobilesdk_app_id": "1:406099696497:android:3ef965ff044efc0b3574d0",
"android_client_info": {
"package_name": "io.flutter.plugins.firebase.database.example"
"package_name": "io.flutter.plugins.firebase.dataconnect.example"
}
},
"oauth_client": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ export 'package:firebase_core_platform_interface/firebase_core_platform_interfac

part 'src/firebase.dart';
part 'src/firebase_app.dart';
part 'src/port_mapping.dart';
18 changes: 18 additions & 0 deletions packages/firebase_core/firebase_core/lib/src/port_mapping.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright 2024, the Chromium project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

part of firebase_core;

String getMappedHost(String originalHost) {
String mappedHost = originalHost;

if (!kIsWeb && defaultTargetPlatform == TargetPlatform.android) {
if (mappedHost == 'localhost' || mappedHost == '127.0.0.1') {
// ignore: avoid_print
print('Mapping Auth Emulator host "$mappedHost" to "10.0.2.2".');
mappedHost = '10.0.2.2';
}
}
return mappedHost;
}
Loading
Loading