Skip to content

Commit b5504d2

Browse files
authored
Run Firestore tests against Emulators where possible. (#549)
1 parent 92db798 commit b5504d2

File tree

3 files changed

+50
-10
lines changed

3 files changed

+50
-10
lines changed

.github/workflows/integration_tests.yml

Lines changed: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ on:
2727
mobile_test_on:
2828
description: 'Run mobile tests on real and/or virtual devices? (separated by commas)'
2929
default: 'real,virtual'
30-
required: true
30+
required: true
3131
use_expanded_matrix:
3232
description: 'Use an expanded matrix? Note: above config will be ignored.'
3333
default: '0'
@@ -52,8 +52,8 @@ jobs:
5252
check_trigger:
5353
### This job runs when the workflow was triggered by 1) PR getting labeled
5454
### 2) PR merged & closed 3) or manumlly triggered with Pull request #.
55-
### If triggered by label, then checks whether the label is a test-request
56-
### trigger (cancelling the workflow if not).
55+
### If triggered by label, then checks whether the label is a test-request
56+
### trigger (cancelling the workflow if not).
5757
### It sets outputs to control the build_* matrix (full or quick) and to tell
5858
### subsequent steps to update the labels as well.
5959
runs-on: ubuntu-latest
@@ -461,7 +461,7 @@ jobs:
461461
--artifact_name "android-${{ matrix.os }}" \
462462
--noadd_timestamp \
463463
--short_output_paths \
464-
${additional_flags[*]}
464+
${additional_flags[*]}
465465
- name: Prepare results summary artifact
466466
if: ${{ !cancelled() }}
467467
shell: bash
@@ -566,7 +566,7 @@ jobs:
566566
--artifact_name "ios-macos-latest" \
567567
--noadd_timestamp \
568568
--short_output_paths \
569-
${additional_flags[*]}
569+
${additional_flags[*]}
570570
- name: Prepare results summary artifact
571571
if: ${{ !cancelled() }}
572572
shell: bash
@@ -670,7 +670,7 @@ jobs:
670670
--artifact_name "tvos-macos-latest" \
671671
--noadd_timestamp \
672672
--short_output_paths \
673-
${additional_flags[*]}
673+
${additional_flags[*]}
674674
- name: Prepare results summary artifact
675675
if: ${{ !cancelled() }}
676676
shell: bash
@@ -739,12 +739,21 @@ jobs:
739739
uses: actions/setup-python@v2
740740
with:
741741
python-version: ${{ env.pythonVersion }}
742+
- name: Set up Node (12)
743+
uses: actions/setup-node@v2
744+
with:
745+
node-version: 12.x
746+
- name: Setup Firestore Emulator
747+
run: |
748+
npm install -g firebase-tools
742749
- name: Setup integration test deps
743750
run: |
744751
pip install -r scripts/gha/requirements.txt
745752
python scripts/gha/restore_secrets.py --passphrase "${{ secrets.TEST_SECRET }}" --artifact testapps
746753
- name: Run Desktop integration tests
747-
run: python scripts/gha/desktop_tester.py --testapp_dir testapps --logfile_name "desktop-${{ matrix.os }}-${{ matrix.ssl_variant }}"
754+
run: firebase emulators:exec --only firestore --project demo-example 'python scripts/gha/desktop_tester.py --testapp_dir testapps --logfile_name "desktop-${{ matrix.os }}-${{ matrix.ssl_variant }}"'
755+
env:
756+
USE_FIRESTORE_EMULATOR: true
748757
- name: Prepare results summary artifact
749758
if: ${{ !cancelled() }}
750759
shell: bash
@@ -773,7 +782,7 @@ jobs:
773782
--issue_number ${{needs.check_trigger.outputs.pr_number}}\
774783
--actor ${{github.actor}} \
775784
--commit ${{needs.prepare_matrix.outputs.github_ref}} \
776-
--run_id ${{github.run_id}}
785+
--run_id ${{github.run_id}}
777786
- name: Summarize test results
778787
if: ${{ !cancelled() }}
779788
shell: bash
@@ -811,6 +820,15 @@ jobs:
811820
- id: get-device-type
812821
run: |
813822
echo "::set-output name=device_type::$( python scripts/gha/print_matrix_configuration.py -d -k ${{ matrix.android_device }} )"
823+
- name: Set up Node (12)
824+
uses: actions/setup-node@v2
825+
with:
826+
node-version: 12.x
827+
- name: Setup Firestore Emulator
828+
if: steps.get-device-type.outputs.device_type == 'virtual'
829+
run: |
830+
npm install -g firebase-tools
831+
firebase emulators:start --only firestore --project demo-example &
814832
- name: Run Android integration tests on Emulator locally
815833
timeout-minutes: 60
816834
if: steps.get-device-type.outputs.device_type == 'virtual'
@@ -896,6 +914,15 @@ jobs:
896914
- id: get-device-type
897915
run: |
898916
echo "::set-output name=device_type::$( python scripts/gha/print_matrix_configuration.py -d -k ${{ matrix.ios_device }} )"
917+
- name: Set up Node (12)
918+
uses: actions/setup-node@v2
919+
with:
920+
node-version: 12.x
921+
- name: Setup Firestore Emulator
922+
if: steps.get-device-type.outputs.device_type == 'virtual'
923+
run: |
924+
npm install -g firebase-tools
925+
firebase emulators:start --only firestore --project demo-example &
899926
- name: Run iOS integration tests on Simulator locally
900927
timeout-minutes: 60
901928
if: steps.get-device-type.outputs.device_type == 'virtual'
@@ -929,7 +956,7 @@ jobs:
929956
with:
930957
name: log-artifact
931958
path: testapps/test-results-ios-macos-latest-${{ matrix.ios_device }}*
932-
retention-days: ${{ env.artifactRetentionDays }}
959+
retention-days: ${{ env.artifactRetentionDays }}
933960
- name: Download log artifacts
934961
if: ${{ needs.check_trigger.outputs.should_update_pr && failure() && !cancelled() }}
935962
uses: actions/[email protected]
@@ -978,6 +1005,10 @@ jobs:
9781005
python-version: ${{ env.pythonVersion }}
9791006
- name: Install python deps
9801007
run: pip install -r scripts/gha/requirements.txt
1008+
- name: Setup Firebase Emulators
1009+
run: |
1010+
npm install -g firebase-tools
1011+
firebase emulators:start --only firestore --project demo-example &
9811012
- name: Run tvOS integration tests on Simulator locally
9821013
timeout-minutes: 60
9831014
run: |
@@ -998,7 +1029,7 @@ jobs:
9981029
with:
9991030
name: log-artifact
10001031
path: testapps/test-results-tvos-macos-latest-${{ matrix.tvos_device }}*
1001-
retention-days: ${{ env.artifactRetentionDays }}
1032+
retention-days: ${{ env.artifactRetentionDays }}
10021033
- name: Download log artifacts
10031034
if: ${{ needs.check_trigger.outputs.should_update_pr && failure() && !cancelled() }}
10041035
uses: actions/[email protected]

scripts/gha/integration_testing/gameloop_android/app/src/main/java/com/google/firebase/gameloop/MainActivity.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ class MainActivity : AppCompatActivity(R.layout.activity_main) {
4242
intent.setPackage(gamePackageName)
4343
.setDataAndType(fileUri, "application/javascript").flags = Intent.FLAG_GRANT_WRITE_URI_PERMISSION
4444

45+
if (android.os.Build.FINGERPRINT.contains("generic")) {
46+
intent.putExtra("USE_FIRESTORE_EMULATOR", "true")
47+
}
48+
4549
startActivityForResult(intent, TEST_LOOP_REQUEST_CODE)
4650
}
4751

testing/sample_framework/src/ios/ios_app_framework.mm

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#import <UIKit/UIKit.h>
1616

1717
#include <pthread.h>
18+
#include <stdlib.h>
1819
#include <unistd.h>
1920

2021
#include <cassert>
@@ -333,6 +334,10 @@ @implementation AppDelegate
333334
- (BOOL)application:(UIApplication *)app
334335
openURL:(NSURL *)url
335336
options:(NSDictionary<UIApplicationOpenURLOptionsKey, id> *)options {
337+
#if TARGET_OS_SIMULATOR
338+
setenv("USE_FIRESTORE_EMULATOR","true",1);
339+
#endif
340+
336341
if ([url.scheme isEqual:kGameLoopUrlPrefix]) {
337342
g_gameloop_launch = true;
338343
app_framework::StartLoggingToFile(GAMELOOP_DEFAULT_LOG_FILE);

0 commit comments

Comments
 (0)