Skip to content

Commit 904249e

Browse files
authored
fix(fdc,web): add WASM support and improve CI (#18074)
* fix(fdc,web): add WASM support and improve CI * permissions clean * clean
1 parent ea1f309 commit 904249e

File tree

3 files changed

+97
-0
lines changed

3 files changed

+97
-0
lines changed

.github/workflows/e2e_tests_fdc.yaml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ on:
2121
- '**/example/**'
2222
- '**.md'
2323

24+
permissions:
25+
contents: read
26+
2427
jobs:
2528
android:
2629
runs-on: ubuntu-latest
@@ -333,3 +336,82 @@ jobs:
333336
key: ${{ steps.firebase-emulator-cache.outputs.cache-primary-key }}
334337
# Must match the restore path exactly
335338
path: ~/.cache/firebase/emulators
339+
340+
web-wasm:
341+
runs-on: macos-latest
342+
timeout-minutes: 15
343+
strategy:
344+
fail-fast: false
345+
steps:
346+
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938
347+
- uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a
348+
name: Install Node.js 20
349+
with:
350+
node-version: '20'
351+
- uses: actions/setup-java@8df1039502a15bceb9433410b1a100fbe190c53b
352+
with:
353+
distribution: 'temurin'
354+
java-version: '21'
355+
- name: Setup PostgreSQL for Linux/macOS/Windows
356+
uses: ikalnytskyi/action-setup-postgres@v7
357+
- uses: subosito/flutter-action@f2c4f6686ca8e8d6e6d0f28410eeef506ed66aff
358+
with:
359+
channel: 'stable'
360+
cache: true
361+
cache-key: "flutter-:os:-:channel:-:version:-:arch:-:hash:"
362+
pub-cache-key: "flutter-pub-:os:-:channel:-:version:-:arch:-:hash:"
363+
- uses: bluefireteam/melos-action@c7dcb921b23cc520cace360b95d02b37bf09cdaa
364+
with:
365+
run-bootstrap: false
366+
melos-version: '5.3.0'
367+
- name: 'Bootstrap package'
368+
run: melos bootstrap --scope "firebase_data_connect*"
369+
- name: 'Install Tools'
370+
run: |
371+
sudo npm i -g firebase-tools
372+
echo "FIREBASE_TOOLS_VERSION=$(npm firebase --version)" >> $GITHUB_ENV
373+
- name: Firebase Emulator Cache
374+
id: firebase-emulator-cache
375+
uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57
376+
continue-on-error: true
377+
with:
378+
# The firebase emulators are pure javascript and java, OS-independent
379+
enableCrossOsArchive: true
380+
# Must match the save path exactly
381+
path: ~/.cache/firebase/emulators
382+
key: firebase-emulators-v3-${{ env.FIREBASE_TOOLS_VERSION }}
383+
restore-keys: firebase-emulators-v3
384+
- name: Start Firebase Emulator
385+
run: |
386+
cd ./packages/firebase_data_connect/firebase_data_connect/example
387+
unset PGSERVICEFILE
388+
firebase experiments:enable dataconnect
389+
./start-firebase-emulator.sh
390+
- name: 'E2E Tests'
391+
working-directory: 'packages/firebase_data_connect/firebase_data_connect/example'
392+
# Web devices are not supported for the `flutter test` command yet. As a
393+
# workaround we can use the `flutter drive` command. Tracking issue:
394+
# https://github.com/flutter/flutter/issues/66264
395+
run: |
396+
chromedriver --port=4444 --trace-buffer-size=100000 &
397+
mv ./web/wasm_index.html ./web/index.html
398+
flutter drive --target=./integration_test/e2e_test.dart --driver=./test_driver/integration_test.dart -d chrome --wasm --dart-define=CI=true | tee output.log
399+
# We have to check the output for failed tests matching the string "[E]"
400+
output=$(<output.log)
401+
if [[ "$output" =~ \[E\] ]]; then
402+
# You will see "All tests passed." in the logs even when tests failed.
403+
echo "All tests did not pass. Please check the logs for more information."
404+
exit 1
405+
fi
406+
shell: bash
407+
- name: Save Firestore Emulator Cache
408+
# Branches can read main cache but main cannot read branch cache. Avoid LRU eviction with main-only cache.
409+
if: github.ref == 'refs/heads/main'
410+
uses: actions/cache/save@1bd1e32a3bdc45362d1e726936510720a7c30a57
411+
continue-on-error: true
412+
with:
413+
# The firebase emulators are pure javascript and java, OS-independent
414+
enableCrossOsArchive: true
415+
key: ${{ steps.firebase-emulator-cache.outputs.cache-primary-key }}
416+
# Must match the restore path exactly
417+
path: ~/.cache/firebase/emulators
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!DOCTYPE HTML>
2+
<html>
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Flutter web app</title>
6+
<script src="flutter.js"></script>
7+
</head>
8+
<body>
9+
<script>
10+
{{flutter_build_config}}
11+
_flutter.loader.load();
12+
</script>
13+
</body>
14+
</html>

packages/firebase_data_connect/firebase_data_connect/lib/src/firebase_data_connect.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import 'package:flutter/foundation.dart';
2222

2323
import './network/transport_library.dart'
2424
if (dart.library.io) './network/grpc_library.dart'
25+
if (dart.library.js_interop) './network/rest_library.dart'
2526
if (dart.library.html) './network/rest_library.dart';
2627

2728
import 'cache/cache_data_types.dart';

0 commit comments

Comments
 (0)