Skip to content

Commit 19a9605

Browse files
committed
Merge branch 'firestore-pipelines-dart-api-v2' into firestore-pipelines-android
2 parents 0c1025b + a4fd6e9 commit 19a9605

File tree

5 files changed

+175
-9
lines changed

5 files changed

+175
-9
lines changed
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
name: pipeline-e2e
2+
3+
concurrency:
4+
group: ${{ github.workflow }}-${{ github.ref }}
5+
cancel-in-progress: true
6+
7+
on:
8+
pull_request:
9+
paths:
10+
- 'packages/cloud_firestore/cloud_firestore/pipeline_example/**'
11+
- 'packages/cloud_firestore/cloud_firestore/lib/**'
12+
push:
13+
branches:
14+
- main
15+
- firestore-pipelines-dart-api-v2
16+
- master
17+
paths:
18+
- 'packages/cloud_firestore/cloud_firestore/pipeline_example/**'
19+
- 'packages/cloud_firestore/cloud_firestore/lib/**'
20+
21+
jobs:
22+
pipeline-e2e-android:
23+
if: ${{ secrets.PIPELINE_E2E_FIREBASE_OPTIONS_DART != '' }}
24+
runs-on: ubuntu-latest
25+
timeout-minutes: 45
26+
env:
27+
AVD_ARCH: x86_64
28+
AVD_API_LEVEL: 34
29+
AVD_TARGET: google_apis
30+
steps:
31+
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938
32+
- uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a
33+
name: Install Node.js 20
34+
with:
35+
node-version: '20'
36+
- uses: actions/setup-java@8df1039502a15bceb9433410b1a100fbe190c53b
37+
with:
38+
distribution: 'temurin'
39+
java-version: '21'
40+
- uses: subosito/flutter-action@f2c4f6686ca8e8d6e6d0f28410eeef506ed66aff
41+
with:
42+
channel: 'stable'
43+
cache: true
44+
cache-key: "flutter-:os:-:channel:-:version:-:arch:-:hash:"
45+
pub-cache-key: "flutter-pub-:os:-:channel:-:version:-:arch:-:hash:"
46+
- uses: bluefireteam/melos-action@c7dcb921b23cc520cace360b95d02b37bf09cdaa
47+
with:
48+
run-bootstrap: false
49+
melos-version: '5.3.0'
50+
- name: Inject Firebase config for pipeline E2E
51+
env:
52+
FIREBASE_OPTIONS_DART: ${{ secrets.PIPELINE_E2E_FIREBASE_OPTIONS_DART }}
53+
GOOGLE_SERVICES_JSON: ${{ secrets.PIPELINE_E2E_GOOGLE_SERVICES_JSON }}
54+
GOOGLE_SERVICE_INFO_PLIST: ${{ secrets.PIPELINE_E2E_GOOGLE_SERVICE_INFO_PLIST }}
55+
run: |
56+
echo "$FIREBASE_OPTIONS_DART" > packages/cloud_firestore/cloud_firestore/pipeline_example/lib/firebase_options.dart
57+
echo "$GOOGLE_SERVICES_JSON" > packages/cloud_firestore/cloud_firestore/pipeline_example/android/app/google-services.json
58+
echo "$GOOGLE_SERVICE_INFO_PLIST" > packages/cloud_firestore/cloud_firestore/pipeline_example/ios/Runner/GoogleService-Info.plist
59+
- name: Bootstrap package
60+
run: melos bootstrap --scope "cloud_firestore*"
61+
- name: Enable KVM
62+
run: |
63+
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
64+
sudo udevadm control --reload-rules
65+
sudo udevadm trigger --name-match=kvm
66+
- name: Gradle cache
67+
uses: gradle/actions/setup-gradle@v4
68+
- name: Free Disk Space (Ubuntu)
69+
uses: AdityaGarg8/remove-unwanted-software@90e01b21170618765a73370fcc3abbd1684a7793
70+
with:
71+
remove-dotnet: true
72+
remove-haskell: true
73+
remove-codeql: true
74+
remove-docker-images: true
75+
remove-large-packages: true
76+
- name: AVD cache
77+
uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57
78+
continue-on-error: true
79+
id: avd-cache
80+
with:
81+
path: |
82+
~/.android/avd/*
83+
~/.android/adb*
84+
key: avd-${{ runner.os }}-${{ env.AVD_API_LEVEL }}-${{ env.AVD_TARGET }}-${{ env.AVD_ARCH }}
85+
- name: Start AVD then run pipeline E2E tests
86+
uses: reactivecircus/android-emulator-runner@b530d96654c385303d652368551fb075bc2f0b6b
87+
with:
88+
api-level: ${{ env.AVD_API_LEVEL }}
89+
target: ${{ env.AVD_TARGET }}
90+
arch: ${{ env.AVD_ARCH }}
91+
emulator-build: 14214601
92+
working-directory: packages/cloud_firestore/cloud_firestore/pipeline_example
93+
script: |
94+
flutter test integration_test/pipeline/pipeline_live_test.dart --timeout 10x --dart-define=CI=true -d emulator-5554
95+
- name: Ensure Appium is shut down
96+
run: |
97+
pgrep -f appium && pkill -f appium || echo "No Appium process found"
98+
- name: Save Android Emulator Cache
99+
if: github.ref == 'refs/heads/main'
100+
uses: actions/cache/save@1bd1e32a3bdc45362d1e726936510720a7c30a57
101+
continue-on-error: true
102+
with:
103+
key: ${{ steps.avd-cache.outputs.cache-primary-key }}
104+
path: |
105+
~/.android/avd/*
106+
~/.android/adb*
107+
108+
pipeline-e2e-web:
109+
if: ${{ secrets.PIPELINE_E2E_FIREBASE_OPTIONS_DART != '' }}
110+
runs-on: ubuntu-latest
111+
timeout-minutes: 25
112+
steps:
113+
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938
114+
- uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a
115+
name: Install Node.js 20
116+
with:
117+
node-version: '20'
118+
- uses: subosito/flutter-action@f2c4f6686ca8e8d6e6d0f28410eeef506ed66aff
119+
with:
120+
channel: 'stable'
121+
cache: true
122+
cache-key: "flutter-:os:-:channel:-:version:-:arch:-:hash:"
123+
pub-cache-key: "flutter-pub-:os:-:channel:-:version:-:arch:-:hash:"
124+
- uses: bluefireteam/melos-action@c7dcb921b23cc520cace360b95d02b37bf09cdaa
125+
with:
126+
run-bootstrap: false
127+
melos-version: '5.3.0'
128+
- name: Inject Firebase config for pipeline E2E
129+
env:
130+
FIREBASE_OPTIONS_DART: ${{ secrets.PIPELINE_E2E_FIREBASE_OPTIONS_DART }}
131+
GOOGLE_SERVICES_JSON: ${{ secrets.PIPELINE_E2E_GOOGLE_SERVICES_JSON }}
132+
GOOGLE_SERVICE_INFO_PLIST: ${{ secrets.PIPELINE_E2E_GOOGLE_SERVICE_INFO_PLIST }}
133+
run: |
134+
echo "$FIREBASE_OPTIONS_DART" > packages/cloud_firestore/cloud_firestore/pipeline_example/lib/firebase_options.dart
135+
echo "$GOOGLE_SERVICES_JSON" > packages/cloud_firestore/cloud_firestore/pipeline_example/android/app/google-services.json
136+
echo "$GOOGLE_SERVICE_INFO_PLIST" > packages/cloud_firestore/cloud_firestore/pipeline_example/ios/Runner/GoogleService-Info.plist
137+
- name: Bootstrap package
138+
run: melos bootstrap --scope "cloud_firestore*"
139+
- name: Run pipeline E2E tests (Chrome)
140+
working-directory: packages/cloud_firestore/cloud_firestore/pipeline_example
141+
run: |
142+
flutter test integration_test/pipeline/pipeline_live_test.dart --timeout 10x --dart-define=CI=true -d chrome

melos.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,13 @@ scripts:
172172
description: |
173173
Run all e2e tests for cloud_firestore.
174174
175+
test:e2e:pipeline:
176+
run: |
177+
cd packages/cloud_firestore/cloud_firestore/pipeline_example
178+
flutter test integration_test/pipeline/pipeline_live_test.dart
179+
description: |
180+
Run pipeline e2e tests.
181+
175182
test:e2e:firebase_performance:
176183
run: |
177184
cd packages/firebase_performance/firebase_performance/example

packages/cloud_firestore/cloud_firestore/pipeline_example/integration_test/pipeline/pipeline_execute_options_e2e.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
import 'package:cloud_firestore/cloud_firestore.dart';
66
import 'package:firebase_core/firebase_core.dart';
7-
import 'package:flutter/foundation.dart'
8-
show defaultTargetPlatform, TargetPlatform;
97
import 'package:flutter_test/flutter_test.dart';
108

119
import 'pipeline_test_helpers.dart';

packages/cloud_firestore/cloud_firestore/pipeline_example/lib/main.dart

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import 'dart:typed_data';
2+
13
import 'package:cloud_firestore/cloud_firestore.dart';
24
import 'package:firebase_core/firebase_core.dart';
35
import 'package:flutter/material.dart';
@@ -12,7 +14,6 @@ Future<void> main() async {
1214
WidgetsFlutterBinding.ensureInitialized();
1315
await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);
1416
if (shouldUseFirestoreEmulator) {
15-
print('Using Firestore emulator');
1617
FirebaseFirestore.instance.useFirestoreEmulator('localhost', 8080);
1718
}
1819
runApp(const PipelineExampleApp());
@@ -66,7 +67,7 @@ class _PipelineExamplePageState extends State<PipelineExamplePage> {
6667

6768
try {
6869
final col = _firestore.collection(_collectionId);
69-
70+
7071
final batch = _firestore.batch();
7172
_seedDocRefs = [];
7273

@@ -224,6 +225,22 @@ class _PipelineExamplePageState extends State<PipelineExamplePage> {
224225
.execute(),
225226
);
226227

228+
// 1b: execute with ExecuteOptions (indexMode: recommended)
229+
Future<void> _runPipelineExecuteOptions() => _runPipeline(
230+
'Pipeline 1b: same as 1 but execute(options: ExecuteOptions(indexMode: recommended))',
231+
() => _firestore
232+
.pipeline()
233+
.collection(_collectionId)
234+
.where(
235+
Expression.field('score').greaterThan(Expression.constant(10)))
236+
.limit(3)
237+
.execute(
238+
options: const ExecuteOptions(
239+
indexMode: IndexMode.recommended,
240+
),
241+
),
242+
);
243+
227244
// 2: select
228245
Future<void> _runPipeline2() => _runPipeline(
229246
'Pipeline 2: collection → where(year > 2022) → select(title, score, year) → limit(4)',
@@ -464,8 +481,8 @@ class _PipelineExamplePageState extends State<PipelineExamplePage> {
464481
Constant(const GeoPoint(37.7749, -122.4194)).as('c_geo_point'),
465482
// List<int> (raw bytes)
466483
Constant(<int>[72, 101, 108, 108, 111]).as('c_bytes'),
467-
// Blob
468-
Constant(Blob(Uint8List.fromList([1, 2, 3, 4, 5]))).as('c_blob'),
484+
// // Blob
485+
// Constant(Blob(Uint8List.fromList([1, 2, 3, 4, 5]))).as('c_blob'),
469486
// DocumentReference
470487
Constant(docRef).as('c_doc_ref'),
471488
)
@@ -521,7 +538,7 @@ class _PipelineExamplePageState extends State<PipelineExamplePage> {
521538
'Pipeline 21: collection → where(tags arrayContainsAny [x, z]) → select(title, tags) → limit(5)',
522539
() => _firestore
523540
.pipeline()
524-
.collection(_collectionId)
541+
.collection(_collectionId)
525542
.where(
526543
Expression.field('tags').arrayContainsAny(['x', 'z']),
527544
)
@@ -963,6 +980,7 @@ class _PipelineExamplePageState extends State<PipelineExamplePage> {
963980
runSpacing: 8,
964981
children: [
965982
_btn('1: where+limit', _runPipeline1),
983+
_btn('1b: execute(options)', _runPipelineExecuteOptions),
966984
_btn('2: select', _runPipeline2),
967985
_btn('3: aggregate', _runPipeline3),
968986
_btn('4: addFields', _runPipeline4),
@@ -988,6 +1006,7 @@ class _PipelineExamplePageState extends State<PipelineExamplePage> {
9881006
_btn('24: lower/upper', _runPipeline24),
9891007
_btn('25: trim', _runPipeline25),
9901008
_btn('26: substring', _runPipeline26),
1009+
// test comment
9911010
_btn('28: split', _runPipeline28),
9921011
_btn('29: join', _runPipeline29),
9931012
_btn('30: if_absent', _runPipeline30),
@@ -1056,4 +1075,4 @@ class PipelineExamplePage extends StatefulWidget {
10561075

10571076
@override
10581077
State<PipelineExamplePage> createState() => _PipelineExamplePageState();
1059-
}
1078+
}

packages/cloud_firestore/cloud_firestore/pipeline_example/test/widget_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import 'package:pipeline_example/main.dart';
1313
void main() {
1414
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
1515
// Build our app and trigger a frame.
16-
await tester.pumpWidget(const MyApp());
16+
await tester.pumpWidget(const PipelineExampleApp());
1717

1818
// Verify that our counter starts at 0.
1919
expect(find.text('0'), findsOneWidget);

0 commit comments

Comments
 (0)