diff --git a/.github/actions/start-emulator/action.yml b/.github/actions/start-emulator/action.yml new file mode 100644 index 000000000..fb71e4321 --- /dev/null +++ b/.github/actions/start-emulator/action.yml @@ -0,0 +1,89 @@ +# 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 }} + path: ground-platform + + - 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@v4 + 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 }}- + + - name: Install nx-linux-x64-gnu + working-directory: ground-platform + shell: bash + run: npm install @nx/nx-linux-x64-gnu + + - name: Install dependencies + working-directory: ground-platform + shell: bash + run: npm install + + - name: Build project and local deps + working-directory: ground-platform + shell: bash + run: npx nx build + + - name: Start Firebase emulator with Android test data + working-directory: ground-platform + shell: bash + run: | + npx nx start-android-test-data > firebase-emulator.log 2>&1 & + + for i in {1..30}; do + if curl -s http://localhost:4000 > /dev/null 2>&1; then + echo "Firebase emulator started!" + exit 0 + fi + echo "Waiting for Firebase emulator to start... ($i/30)" + sleep 5 + done + + echo "Firebase Emulator failed to start" + cat firebase-emulator.log + exit 1 diff --git a/data/test-android/auth_export/accounts.json b/data/test-android/auth_export/accounts.json new file mode 100644 index 000000000..135e08db6 --- /dev/null +++ b/data/test-android/auth_export/accounts.json @@ -0,0 +1 @@ +{"kind":"identitytoolkit#DownloadAccountResponse","users":[]} \ No newline at end of file diff --git a/data/test-android/auth_export/config.json b/data/test-android/auth_export/config.json new file mode 100644 index 000000000..6f240f7e9 --- /dev/null +++ b/data/test-android/auth_export/config.json @@ -0,0 +1 @@ +{"signIn":{"allowDuplicateEmails":false},"emailPrivacyConfig":{"enableImprovedEmailPrivacy":false}} \ No newline at end of file diff --git a/data/test-android/firebase-export-metadata.json b/data/test-android/firebase-export-metadata.json new file mode 100644 index 000000000..947edb716 --- /dev/null +++ b/data/test-android/firebase-export-metadata.json @@ -0,0 +1,12 @@ +{ + "version": "14.27.0", + "firestore": { + "version": "1.19.8", + "path": "firestore_export", + "metadata_file": "firestore_export/firestore_export.overall_export_metadata" + }, + "auth": { + "version": "14.27.0", + "path": "auth_export" + } +} \ No newline at end of file diff --git a/data/test-android/firestore_export/all_namespaces/all_kinds/all_namespaces_all_kinds.export_metadata b/data/test-android/firestore_export/all_namespaces/all_kinds/all_namespaces_all_kinds.export_metadata new file mode 100644 index 000000000..a09ff55ea Binary files /dev/null and b/data/test-android/firestore_export/all_namespaces/all_kinds/all_namespaces_all_kinds.export_metadata differ diff --git a/data/test-android/firestore_export/all_namespaces/all_kinds/output-0 b/data/test-android/firestore_export/all_namespaces/all_kinds/output-0 new file mode 100644 index 000000000..799052f4a Binary files /dev/null and b/data/test-android/firestore_export/all_namespaces/all_kinds/output-0 differ diff --git a/data/test-android/firestore_export/firestore_export.overall_export_metadata b/data/test-android/firestore_export/firestore_export.overall_export_metadata new file mode 100644 index 000000000..958d2b23e Binary files /dev/null and b/data/test-android/firestore_export/firestore_export.overall_export_metadata differ diff --git a/firebase.local.json b/firebase.local.json index ad6da9a8f..d210970a4 100644 --- a/firebase.local.json +++ b/firebase.local.json @@ -13,6 +13,9 @@ ] }, "emulators": { + "auth": { + "port": 9099 + }, "functions": { "port": 5001 }, diff --git a/package.json b/package.json index bc89e6fd3..ea1068cc1 100644 --- a/package.json +++ b/package.json @@ -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": { @@ -110,4 +122,4 @@ "overrides": { "eslint-plugin-n": "^17.0.0" } -} +} \ No newline at end of file