Skip to content
Draft
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
76 changes: 76 additions & 0 deletions .github/actions/start-emulator/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Copyright 2026 The Ground Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: Start Firebase emulator for Android tests

inputs:
platform-repository:
description: "ground-platform repository under test"
default: google/ground-platform

runs:
using: "composite"
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
repository: ${{ inputs.platform-repository }}

- name: Load cached Firebase emulator
uses: actions/cache@v4
with:
path: ~/.cache/firebase/emulators
key: ${{ runner.os }}-firebase-emulators-${{ github.sha }}
restore-keys: |
${{ runner.os }}-firebase-emulators-

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: "20"

- name: Load cached Node modules
id: cache-npm
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-

- if: ${{ steps.cache-npm.outputs.cache-hit != 'true' }}
name: List the state of Node modules
continue-on-error: true
shell: bash
run: npm list

- name: Install nx-linux-x64-gnu
shell: bash
run: npm install @nx/nx-linux-x64-gnu

- name: Install dependencies
shell: bash
run: npm install

- name: Build project and local deps
shell: bash
run: npx nx build

- name: Start Firebase emulator with Android test data
shell: bash
run: npx nx start-android-test-data
2 changes: 1 addition & 1 deletion data/local/auth_export/accounts.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"kind":"identitytoolkit#DownloadAccountResponse","users":[{"localId":"OSpCUZYAGPvDJn8n7rgYz9YfIrD9","createdAt":"1719838206834","lastLoginAt":"1719838206834","validSince":"1724424200","emailVerified":false,"disabled":false},{"localId":"dZWReItHKWIaMi4GJPxszWb0VCnN","createdAt":"1719841155698","lastLoginAt":"1719841155698","validSince":"1724424200","emailVerified":false,"disabled":false},{"localId":"xyNMqyb9LPp0xXtdEa6DQk3ymHLa","createdAt":"1719841321507","lastLoginAt":"1719841321507","validSince":"1724424200","emailVerified":false,"disabled":false}]}
{"kind":"identitytoolkit#DownloadAccountResponse","users":[{"localId":"OSpCUZYAGPvDJn8n7rgYz9YfIrD9","createdAt":"1719838206834","lastLoginAt":"1719838206834","validSince":"1767633238","emailVerified":false,"disabled":false},{"localId":"dZWReItHKWIaMi4GJPxszWb0VCnN","createdAt":"1719841155698","lastLoginAt":"1719841155698","validSince":"1767633238","emailVerified":false,"disabled":false},{"localId":"xyNMqyb9LPp0xXtdEa6DQk3ymHLa","createdAt":"1719841321507","lastLoginAt":"1719841321507","validSince":"1767633238","emailVerified":false,"disabled":false}]}
6 changes: 3 additions & 3 deletions data/local/firebase-export-metadata.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"version": "13.6.0",
"version": "14.27.0",
"firestore": {
"version": "1.19.4",
"version": "1.19.8",
"path": "firestore_export",
"metadata_file": "firestore_export/firestore_export.overall_export_metadata"
},
"auth": {
"version": "13.6.0",
"version": "14.27.0",
"path": "auth_export"
}
}
Binary file not shown.
Binary file modified data/local/firestore_export/all_namespaces/all_kinds/output-0
Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions data/test-android/auth_export/accounts.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"kind":"identitytoolkit#DownloadAccountResponse","users":[{"localId":"OSpCUZYAGPvDJn8n7rgYz9YfIrD9","createdAt":"1719838206834","lastLoginAt":"1719838206834","validSince":"1724424200","emailVerified":false,"disabled":false},{"localId":"dZWReItHKWIaMi4GJPxszWb0VCnN","createdAt":"1719841155698","lastLoginAt":"1719841155698","validSince":"1724424200","emailVerified":false,"disabled":false},{"localId":"xyNMqyb9LPp0xXtdEa6DQk3ymHLa","createdAt":"1719841321507","lastLoginAt":"1719841321507","validSince":"1724424200","emailVerified":false,"disabled":false}]}
1 change: 1 addition & 0 deletions data/test-android/auth_export/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"signIn":{"allowDuplicateEmails":false},"emailPrivacyConfig":{"enableImprovedEmailPrivacy":false}}
12 changes: 12 additions & 0 deletions data/test-android/firebase-export-metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"version": "13.35.1",
"firestore": {
"version": "1.19.8",
"path": "firestore_export",
"metadata_file": "firestore_export/firestore_export.overall_export_metadata"
},
"auth": {
"version": "13.35.1",
"path": "auth_export"
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
3 changes: 3 additions & 0 deletions firebase.local.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
]
},
"emulators": {
"auth": {
"port": 9099
},
Comment on lines +16 to +18
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I see that this has been removed in #2338 but it's needed for running the android project with the local firebase emulator so I'm re-adding it here. @gino-m could you please confirm if this is ok?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Are you sure it's needed? Isn't auth disabled in the local version? I can't see how it would work today, since we never set up a test account in the auth emulator.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

without this the Android app crashes with : com.google.firebase.FirebaseException: An internal error has occurred. [ Failed to connect to /10.0.2.2:9099 ]

The Android app needs FirebaseAuth to initialize successfully when running against the local emulator. For local builds we rely on anonymous sign-in, which still requires the auth emulator to be configured, which currently is done like this:

    val auth = FirebaseAuth.getInstance()
    if (USE_EMULATORS) {
      // Use the auth emulator so we can sign-in anonymously during dev.
      auth.useEmulator(EMULATOR_HOST, AUTH_EMULATOR_PORT)
    }

Copy link
Collaborator

Choose a reason for hiding this comment

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

Interesting.. I'm surprised it's needed for anonymous sign in. Sure, please re-enable it!

"functions": {
"port": 5001
},
Expand Down
14 changes: 13 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,18 @@
"build"
]
},
"start-android-test-data": {
"executor": "nx:run-commands",
"options": {
"commands": [
"firebase experiments:enable webframeworks",
"firebase emulators:start --project demo-local --config firebase.local.json --import data/test-android"
]
},
"dependsOn": [
"build"
]
},
"deploy": {
"executor": "nx:run-commands",
"configurations": {
Expand Down Expand Up @@ -120,4 +132,4 @@
"overrides": {
"eslint-plugin-n": "^17.0.0"
}
}
}