Skip to content

Commit

Permalink
test(fdc): add e2e and unit tests to fdc (#13224)
Browse files Browse the repository at this point in the history
* First pass at dataconnect

* Got mutations to work

* Finished WIP

* Used generated SDK

* Removed unrelated chagnes

* Cleanup

* Updated deps

* Addressed comments

* Removed prints

* Removed unnecessary protos

* Removed user class

* Removed unnecessary class

* Removed unnecessary deps

* Added back config files

* Fixed formatting

* added index.html

* Added license files

* Fixed formatting

* Fixed linting issues

* Fixed formatting

* Added protobuf as dependency

* Added license

* Ignored example dir for secret checking

* Added changelog and readme

* Updated package version

* Implemented app check

* Removed key

* Revert "Removed key"

This reverts commit 6a643f1.

* Removed key again

* Added error catching implementation (#13163)

* feat(dataconnect): Added error handling (#13175)

* Added missing file
* Removed unnecessary changes

* Miscellaneous cleanup

* Removed macros experiment

* Removed .then statements

* Removed debug prints

* Addressed first pass of comments

* Added movie_insert gql file

* Added comments

* Renamed package

* Another package rename

* Removed common package

* Added missing files

* Updated readme

* Revert "Removed common package"

This reverts commit 422bd80.

* Various improvements

* Made changes per api proposal

* Fixed initialization issues with generated SDK

* Made changes according to api council review

* Addressed Comments.

Removed references to personal firebase projects
Moved mapped host logic to new firebase_common package

* Added missing license header to files

* /s/query/operation

* API Council Changes

* Included list movies changes

* API council updates

* Addressed comments

* Removed print

* Added license header

* Removed files that should be gitignored

* Removed requirement on firebase_options

* Added missing line

* Removed windows and linux folders, updated changelog and gitignore

* Updated version of firebase_data_connect

* test(fdc): add e2e tests to the FDC package

* add e2e tests to CI

* test generated content

* update

* test

* add postgres

* more generation tests

* update podfile

* fix analyze

* regenerate with latest version

* add more queries

* add more queries?

* removing not generated commands

* more unit tests

* timestamp

* licence

* analyze

* add dev dep

* update generated

* ignore generated for licence

* add .firebaserc for dataconnect setup

* fix ci

* fix setup

* test

* more testing

* improve

* unset PGSERVICE

* mote testing

* okay?

* maybe this?

* update pubignore

* update

* ??

* hop

* more

* hophophop

* more

* web

* tests

* test

* merge clean

* regenerate

* fix

* fix

* more tests

* remove GoogleInfo Plist

* fix options

* test

* fix emulator

* clear text

* wut?

* fix generated code

* public level

* fix

* fix generated

* test

* maybe

* alors peut etre

* tests done

* update caching

* e2e tests

* tests done

* fix

* fix concurrency

* fixes

* fix

* again

* tests update

* test

---------

Co-authored-by: Maneesh Tewani <[email protected]>
Co-authored-by: Maneesh Tewani <[email protected]>
  • Loading branch information
3 people authored Sep 12, 2024
1 parent 053a424 commit fa12459
Show file tree
Hide file tree
Showing 62 changed files with 3,445 additions and 363 deletions.
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
@@ -0,0 +1,12 @@
{
"projects": {
"default": "flutterfire-e2e-tests"
},
"targets": {},
"etags": {},
"dataconnectEmulatorConfig": {
"postgres": {
"localConnectionString": "postgresql://postgres:postgres@localhost:5432/postgres?sslmode=disable"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ app.*.map.json
/android/app/release
/android/app/google-services.json
/ios/firebase_app_id_file.json
/lib/firebase_options.dart
/macos/firebase_app_id_file.json

ios/Runner/GoogleService-Info.plist
.firebaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.firebaserc
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
plugins {
id "com.android.application"
// START: FlutterFire Configuration
id 'com.google.gms.google-services'
// END: FlutterFire Configuration
id "kotlin-android"
// The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
id "dev.flutter.flutter-gradle-plugin"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
<application
android:label="example"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher">
android:icon="@mipmap/ic_launcher"
android:usesCleartextTraffic="true">
<activity
android:name=".MainActivity"
android:exported="true"
Expand All @@ -17,12 +18,12 @@
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"
/>
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
Expand All @@ -38,8 +39,8 @@
In particular, this is used by the Flutter engine in io.flutter.plugin.text.ProcessTextPlugin. -->
<queries>
<intent>
<action android:name="android.intent.action.PROCESS_TEXT"/>
<data android:mimeType="text/plain"/>
<action android:name="android.intent.action.PROCESS_TEXT" />
<data android:mimeType="text/plain" />
</intent>
</queries>
</manifest>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ pluginManagement {
plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "7.3.0" apply false
// START: FlutterFire Configuration
id "com.google.gms.google-services" version "4.3.15" apply false
// END: FlutterFire Configuration
id "org.jetbrains.kotlin.android" version "1.7.10" apply false
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ input DirectedBy_ListFilter {
input DirectedBy_Order {
movieId: OrderDirection
directedbyId: OrderDirection
directedby: Person_Order
movie: Movie_Order
}
input Movie_Data {
id: UUID
Expand Down
Loading

0 comments on commit fa12459

Please sign in to comment.