Skip to content

Run Firestore tests against Emulators where possible. #549

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

Merged
merged 24 commits into from
Aug 17, 2021
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
51 changes: 41 additions & 10 deletions .github/workflows/integration_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ on:
mobile_test_on:
description: 'Run mobile tests on real and/or virtual devices? (separated by commas)'
default: 'real,virtual'
required: true
required: true
use_expanded_matrix:
description: 'Use an expanded matrix? Note: above config will be ignored.'
default: '0'
Expand All @@ -52,8 +52,8 @@ jobs:
check_trigger:
### This job runs when the workflow was triggered by 1) PR getting labeled
### 2) PR merged & closed 3) or manumlly triggered with Pull request #.
### If triggered by label, then checks whether the label is a test-request
### trigger (cancelling the workflow if not).
### If triggered by label, then checks whether the label is a test-request
### trigger (cancelling the workflow if not).
### It sets outputs to control the build_* matrix (full or quick) and to tell
### subsequent steps to update the labels as well.
runs-on: ubuntu-latest
Expand Down Expand Up @@ -461,7 +461,7 @@ jobs:
--artifact_name "android-${{ matrix.os }}" \
--noadd_timestamp \
--short_output_paths \
${additional_flags[*]}
${additional_flags[*]}
- name: Prepare results summary artifact
if: ${{ !cancelled() }}
shell: bash
Expand Down Expand Up @@ -566,7 +566,7 @@ jobs:
--artifact_name "ios-macos-latest" \
--noadd_timestamp \
--short_output_paths \
${additional_flags[*]}
${additional_flags[*]}
- name: Prepare results summary artifact
if: ${{ !cancelled() }}
shell: bash
Expand Down Expand Up @@ -670,7 +670,7 @@ jobs:
--artifact_name "tvos-macos-latest" \
--noadd_timestamp \
--short_output_paths \
${additional_flags[*]}
${additional_flags[*]}
- name: Prepare results summary artifact
if: ${{ !cancelled() }}
shell: bash
Expand Down Expand Up @@ -739,12 +739,21 @@ jobs:
uses: actions/setup-python@v2
with:
python-version: ${{ env.pythonVersion }}
- name: Set up Node (12)
uses: actions/setup-node@v2
with:
node-version: 12.x
- name: Setup Firestore Emulator
run: |
npm install -g firebase-tools
- name: Setup integration test deps
run: |
pip install -r scripts/gha/requirements.txt
python scripts/gha/restore_secrets.py --passphrase "${{ secrets.TEST_SECRET }}" --artifact testapps
- name: Run Desktop integration tests
run: python scripts/gha/desktop_tester.py --testapp_dir testapps --logfile_name "desktop-${{ matrix.os }}-${{ matrix.ssl_variant }}"
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 }}"'
env:
USE_FIRESTORE_EMULATOR: true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know all the detail. But I was wondering why Non-windows need this env.
Isn't intent.putExtra("USE_FIRESTORE_EMULATOR", "true") enough to set the env?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is enough for Android. This is running desktop tests.

Copy link
Contributor

@sunmou99 sunmou99 Aug 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad. Then why Windows doesn't test agains Firestore emulator?

- name: Prepare results summary artifact
if: ${{ !cancelled() }}
shell: bash
Expand Down Expand Up @@ -773,7 +782,7 @@ jobs:
--issue_number ${{needs.check_trigger.outputs.pr_number}}\
--actor ${{github.actor}} \
--commit ${{needs.prepare_matrix.outputs.github_ref}} \
--run_id ${{github.run_id}}
--run_id ${{github.run_id}}
- name: Summarize test results
if: ${{ !cancelled() }}
shell: bash
Expand Down Expand Up @@ -811,6 +820,15 @@ jobs:
- id: get-device-type
run: |
echo "::set-output name=device_type::$( python scripts/gha/print_matrix_configuration.py -d -k ${{ matrix.android_device }} )"
- name: Set up Node (12)
uses: actions/setup-node@v2
with:
node-version: 12.x
- name: Setup Firestore Emulator
if: steps.get-device-type.outputs.device_type == 'virtual'
run: |
npm install -g firebase-tools
firebase emulators:start --only firestore --project demo-example &
- name: Run Android integration tests on Emulator locally
timeout-minutes: 60
if: steps.get-device-type.outputs.device_type == 'virtual'
Expand Down Expand Up @@ -896,6 +914,15 @@ jobs:
- id: get-device-type
run: |
echo "::set-output name=device_type::$( python scripts/gha/print_matrix_configuration.py -d -k ${{ matrix.ios_device }} )"
- name: Set up Node (12)
uses: actions/setup-node@v2
with:
node-version: 12.x
- name: Setup Firestore Emulator
if: steps.get-device-type.outputs.device_type == 'virtual'
run: |
npm install -g firebase-tools
firebase emulators:start --only firestore --project demo-example &
- name: Run iOS integration tests on Simulator locally
timeout-minutes: 60
if: steps.get-device-type.outputs.device_type == 'virtual'
Expand Down Expand Up @@ -929,7 +956,7 @@ jobs:
with:
name: log-artifact
path: testapps/test-results-ios-macos-latest-${{ matrix.ios_device }}*
retention-days: ${{ env.artifactRetentionDays }}
retention-days: ${{ env.artifactRetentionDays }}
- name: Download log artifacts
if: ${{ needs.check_trigger.outputs.should_update_pr && failure() && !cancelled() }}
uses: actions/[email protected]
Expand Down Expand Up @@ -978,6 +1005,10 @@ jobs:
python-version: ${{ env.pythonVersion }}
- name: Install python deps
run: pip install -r scripts/gha/requirements.txt
- name: Setup Firebase Emulators
run: |
npm install -g firebase-tools
firebase emulators:start --only firestore --project demo-example &
- name: Run tvOS integration tests on Simulator locally
timeout-minutes: 60
run: |
Expand All @@ -998,7 +1029,7 @@ jobs:
with:
name: log-artifact
path: testapps/test-results-tvos-macos-latest-${{ matrix.tvos_device }}*
retention-days: ${{ env.artifactRetentionDays }}
retention-days: ${{ env.artifactRetentionDays }}
- name: Download log artifacts
if: ${{ needs.check_trigger.outputs.should_update_pr && failure() && !cancelled() }}
uses: actions/[email protected]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ class MainActivity : AppCompatActivity(R.layout.activity_main) {
intent.setPackage(gamePackageName)
.setDataAndType(fileUri, "application/javascript").flags = Intent.FLAG_GRANT_WRITE_URI_PERMISSION

if (android.os.Build.FINGERPRINT.contains("generic")) {
intent.putExtra("USE_FIRESTORE_EMULATOR", "true")
}

startActivityForResult(intent, TEST_LOOP_REQUEST_CODE)
}

Expand Down
5 changes: 5 additions & 0 deletions testing/sample_framework/src/ios/ios_app_framework.mm
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#import <UIKit/UIKit.h>

#include <pthread.h>
#include <stdlib.h>
#include <unistd.h>

#include <cassert>
Expand Down Expand Up @@ -333,6 +334,10 @@ @implementation AppDelegate
- (BOOL)application:(UIApplication *)app
openURL:(NSURL *)url
options:(NSDictionary<UIApplicationOpenURLOptionsKey, id> *)options {
#if TARGET_OS_SIMULATOR
setenv("USE_FIRESTORE_EMULATOR","true",1);
#endif

if ([url.scheme isEqual:kGameLoopUrlPrefix]) {
g_gameloop_launch = true;
app_framework::StartLoggingToFile(GAMELOOP_DEFAULT_LOG_FILE);
Expand Down