Skip to content
Closed
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
52 changes: 41 additions & 11 deletions .github/workflows/android.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ jobs:
matrix:
working_directory:
['tests', 'packages/cloud_firestore/cloud_firestore/example']
env:
AVD_ARCH: x86_64
AVD_API_LEVEL: 34
AVD_TARGET: google_apis
Copy link
Contributor Author

Choose a reason for hiding this comment

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

env var used to follow "Don't Repeat Yourself" programming law since these values will be used both for cache key and emulator action now

steps:
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938
- uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a
Expand All @@ -43,11 +47,20 @@ jobs:
with:
distribution: 'temurin'
java-version: '17'
- name: 'Install Tools'
run: |
sudo npm i -g firebase-tools
echo "FIREBASE_TOOLS_VERSION=$(npm firebase --version)" >> $GITHUB_ENV
Copy link
Contributor Author

@mikehardy mikehardy Nov 24, 2025

Choose a reason for hiding this comment

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

discussion on how to share information between workflow steps, including syntax for command interpolation while setting an environment variable: https://stackoverflow.com/a/57989070/9910298

example output of command executed so you may verify it is valid for an environment variable (no spaces or similar):

mike@krakatoa:~/work/invertase/react-native-firebase (main) % yarn firebase --version
14.24.2

- name: Firebase Emulator Cache
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57
id: firebase-emulator-cache
uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57
Copy link
Contributor Author

Choose a reason for hiding this comment

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

splitting to the separate restore/save actions vs the combo 'cache' action so we may restore every time but only save conditionally

continue-on-error: true
with:
# The firebase emulators are pure javascript and java, OS-independent
enableCrossOsArchive: true
Copy link
Contributor Author

Choose a reason for hiding this comment

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

documentation if interested https://github.com/actions/cache/blob/main/tips-and-workarounds.md#cross-os-cache

complete listing of files in ~/.cache/firebase/emulators for verification:

mike@krakatoa:~/work/invertase/flutterfire (fix-avd-storage) % find /Users/mike/.cache/firebase/emulators
/Users/mike/.cache/firebase/emulators
/Users/mike/.cache/firebase/emulators/ui-v1.15.0.zip
/Users/mike/.cache/firebase/emulators/firebase-database-emulator-v4.11.2.jar
/Users/mike/.cache/firebase/emulators/cloud-storage-rules-runtime-v1.1.3.jar
/Users/mike/.cache/firebase/emulators/cloud-firestore-emulator-v1.19.8.jar
/Users/mike/.cache/firebase/emulators/ui-v1.15.0
/Users/mike/.cache/firebase/emulators/ui-v1.15.0/server
/Users/mike/.cache/firebase/emulators/ui-v1.15.0/server/server.mjs.map
/Users/mike/.cache/firebase/emulators/ui-v1.15.0/server/server.mjs
/Users/mike/.cache/firebase/emulators/ui-v1.15.0/client
/Users/mike/.cache/firebase/emulators/ui-v1.15.0/client/favicon-16x16.png
/Users/mike/.cache/firebase/emulators/ui-v1.15.0/client/safari-pinned-tab.svg
/Users/mike/.cache/firebase/emulators/ui-v1.15.0/client/favicon.ico
/Users/mike/.cache/firebase/emulators/ui-v1.15.0/client/index.html
/Users/mike/.cache/firebase/emulators/ui-v1.15.0/client/android-chrome-192x192.png
/Users/mike/.cache/firebase/emulators/ui-v1.15.0/client/apple-touch-icon.png
/Users/mike/.cache/firebase/emulators/ui-v1.15.0/client/android-chrome-512x512.png
/Users/mike/.cache/firebase/emulators/ui-v1.15.0/client/manifest.json
/Users/mike/.cache/firebase/emulators/ui-v1.15.0/client/robots.txt
/Users/mike/.cache/firebase/emulators/ui-v1.15.0/client/mstile-150x150.png
/Users/mike/.cache/firebase/emulators/ui-v1.15.0/client/assets
/Users/mike/.cache/firebase/emulators/ui-v1.15.0/client/assets/index-BX-A56oj.js
/Users/mike/.cache/firebase/emulators/ui-v1.15.0/client/assets/index-CjB9C900.css
/Users/mike/.cache/firebase/emulators/ui-v1.15.0/client/assets/index-BX-A56oj.js.map
/Users/mike/.cache/firebase/emulators/ui-v1.15.0/client/assets/extensions
/Users/mike/.cache/firebase/emulators/ui-v1.15.0/client/assets/extensions/default-extension.png
/Users/mike/.cache/firebase/emulators/ui-v1.15.0/client/assets/img
/Users/mike/.cache/firebase/emulators/ui-v1.15.0/client/assets/img/database.png
/Users/mike/.cache/firebase/emulators/ui-v1.15.0/client/assets/provider-icons
/Users/mike/.cache/firebase/emulators/ui-v1.15.0/client/assets/provider-icons/auth_service_saml.svg
/Users/mike/.cache/firebase/emulators/ui-v1.15.0/client/assets/provider-icons/auth_service_phone.svg
/Users/mike/.cache/firebase/emulators/ui-v1.15.0/client/assets/provider-icons/auth_service_facebook.svg
/Users/mike/.cache/firebase/emulators/ui-v1.15.0/client/assets/provider-icons/auth_service_game_center.svg
/Users/mike/.cache/firebase/emulators/ui-v1.15.0/client/assets/provider-icons/auth_service_apple.svg
/Users/mike/.cache/firebase/emulators/ui-v1.15.0/client/assets/provider-icons/auth_service_github.svg
/Users/mike/.cache/firebase/emulators/ui-v1.15.0/client/assets/provider-icons/auth_service_mslive.svg
/Users/mike/.cache/firebase/emulators/ui-v1.15.0/client/assets/provider-icons/auth_service_yahoo.svg
/Users/mike/.cache/firebase/emulators/ui-v1.15.0/client/assets/provider-icons/auth_service_twitter.svg
/Users/mike/.cache/firebase/emulators/ui-v1.15.0/client/assets/provider-icons/auth_service_play_games.svg
/Users/mike/.cache/firebase/emulators/ui-v1.15.0/client/assets/provider-icons/auth_service_email.svg
/Users/mike/.cache/firebase/emulators/ui-v1.15.0/client/assets/provider-icons/auth_service_google.svg
/Users/mike/.cache/firebase/emulators/ui-v1.15.0/client/assets/provider-icons/auth_service_oidc.svg
/Users/mike/.cache/firebase/emulators/ui-v1.15.0/client/browserconfig.xml
/Users/mike/.cache/firebase/emulators/ui-v1.15.0/client/favicon-32x32.png
mike@krakatoa:~/work/invertase/flutterfire (@mikehardy/ci-caching-best-practices) % 

# Must match the save path exactly
path: ~/.cache/firebase/emulators
key: firebase-emulators-v3-${{ runner.os }}
key: firebase-emulators-v3-${{ env.FIREBASE_TOOLS_VERSION }}
restore-keys: firebase-emulators-v3
- uses: subosito/flutter-action@f2c4f6686ca8e8d6e6d0f28410eeef506ed66aff
with:
Expand All @@ -61,9 +74,6 @@ jobs:
melos-version: '5.3.0'
- name: 'Bootstrap package'
run: melos bootstrap --scope tests && melos bootstrap --scope "cloud_firestore*"
- name: 'Install Tools'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Had to move tools install above tools cache restore so it could get the version for cache key
The tools install makes no use of the cache, so the move should do no harm

run: |
sudo npm i -g firebase-tools
- name: Start Firebase Emulator
run: cd ./.github/workflows/scripts && ./start-firebase-emulator.sh
- name: Enable KVM
Expand All @@ -82,19 +92,21 @@ jobs:
remove-docker-images: true
remove-large-packages: true
- name: AVD cache
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57
uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57
continue-on-error: true
id: avd-cache
with:
# Must match the save path exactly
path: |
~/.android/avd/*
~/.android/adb*
key: avd-${{ runner.os }}
key: avd-${{ runner.os }}-${{ env.AVD_API_LEVEL }}-${{ env.AVD_TARGET }}-${{ env.AVD_ARCH }}
- name: Start AVD then run E2E tests
uses: reactivecircus/android-emulator-runner@v2
uses: reactivecircus/android-emulator-runner@b530d96654c385303d652368551fb075bc2f0b6b
Copy link
Contributor Author

Choose a reason for hiding this comment

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

verify visually by noticing the v2 tag is currently attached to this SHA here: ReactiveCircus/android-emulator-runner@b530d96

with:
api-level: 34
target: google_apis
arch: x86_64
api-level: ${{ env.AVD_API_LEVEL }}
target: ${{ env.AVD_TARGET }}
arch: ${{ env.AVD_ARCH }}
working-directory: ${{ matrix.working_directory }}
script: |
flutter test integration_test/e2e_test.dart --ignore-timeouts --dart-define=CI=true -d emulator-5554
Expand All @@ -103,3 +115,21 @@ jobs:
# https://github.com/ReactiveCircus/android-emulator-runner/issues/385
run: |
pgrep -f appium && pkill -f appium || echo "No Appium process found"
- name: Save Firestore Emulator Cache
# Branches can read main cache but main cannot read branch cache. Avoid LRU eviction with main-only cache.
if: github.ref == 'refs/heads/main'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

example of conditional step based on branch ref https://stackoverflow.com/a/58142412/9910298

uses: actions/cache/save@1bd1e32a3bdc45362d1e726936510720a7c30a57
with:
key: ${{ steps.firebase-emulator-cache.outputs.cache-primary-key }}
# Must match the restore path exactly
path: ~/.cache/firebase/emulators
- name: Save Android Emulator Cache
# Branches can read main cache but main cannot read branch cache. Avoid LRU eviction with main-only cache.
if: github.ref == 'refs/heads/main'
uses: actions/cache/save@1bd1e32a3bdc45362d1e726936510720a7c30a57
with:
key: ${{ steps.avd-cache.outputs.cache-primary-key }}
# Must match the restore path exactly
path: |
~/.android/avd/*
~/.android/adb*
123 changes: 103 additions & 20 deletions .github/workflows/e2e_tests_fdc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ jobs:
timeout-minutes: 45
strategy:
fail-fast: false
env:
AVD_ARCH: x86_64
AVD_API_LEVEL: 34
AVD_TARGET: google_apis
steps:
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938
- uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a
Expand All @@ -37,11 +41,20 @@ jobs:
with:
distribution: 'temurin'
java-version: '17'
- name: 'Install Tools'
run: |
sudo npm i -g firebase-tools
echo "FIREBASE_TOOLS_VERSION=$(npm firebase --version)" >> $GITHUB_ENV
- name: Firebase Emulator Cache
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57
id: firebase-emulator-cache
uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57
continue-on-error: true
with:
# The firebase emulators are pure javascript and java, OS-independent
enableCrossOsArchive: true
# Must match the save path exactly
path: ~/.cache/firebase/emulators
key: firebase-emulators-v3-fdc-${{ runner.os }}
key: firebase-emulators-v3-${{ env.FIREBASE_TOOLS_VERSION }}
restore-keys: firebase-emulators-v3
- uses: subosito/flutter-action@f2c4f6686ca8e8d6e6d0f28410eeef506ed66aff
with:
Expand All @@ -55,9 +68,6 @@ jobs:
melos-version: '5.3.0'
- name: 'Bootstrap package'
run: melos bootstrap --scope "firebase_data_connect*"
- name: 'Install Tools'
run: |
sudo npm i -g firebase-tools
- name: Start Firebase Emulator
run: |
cd ./packages/firebase_data_connect/firebase_data_connect/example
Expand All @@ -80,22 +90,44 @@ jobs:
remove-docker-images: true
remove-large-packages: true
- name: AVD cache
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57
uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57
id: avd-cache
continue-on-error: true
with:
# Must match the save path exactly
path: |
~/.android/avd/*
~/.android/adb*
key: avd-${{ runner.os }}
key: avd-${{ runner.os }}-${{ env.AVD_API_LEVEL }}-${{ env.AVD_TARGET }}-${{ env.AVD_ARCH }}
- name: Start AVD then run E2E tests
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 34
target: google_apis
arch: x86_64
api-level: ${{ env.AVD_API_LEVEL }}
target: ${{ env.AVD_TARGET }}
arch: ${{ env.AVD_ARCH }}
working-directory: 'packages/firebase_data_connect/firebase_data_connect/example'
script: |
flutter test integration_test/e2e_test.dart --dart-define=CI=true -d emulator-5554
- name: Save Android Emulator Cache
# Branches can read main cache but main cannot read branch cache. Avoid LRU eviction with main-only cache.
if: github.ref == 'refs/heads/main'
uses: actions/cache/save@1bd1e32a3bdc45362d1e726936510720a7c30a57
continue-on-error: true
with:
key: ${{ steps.avd-cache.outputs.cache-primary-key }}
# Must match the restore path exactly
path: |
~/.android/avd/*
~/.android/adb*
- name: Save Firestore Emulator Cache
# Branches can read main cache but main cannot read branch cache. Avoid LRU eviction with main-only cache.
if: github.ref == 'refs/heads/main'
uses: actions/cache/save@1bd1e32a3bdc45362d1e726936510720a7c30a57
continue-on-error: true
with:
key: ${{ steps.firebase-emulator-cache.outputs.cache-primary-key }}
# Must match the restore path exactly
path: ~/.cache/firebase/emulators

ios:
runs-on: macos-15
Expand All @@ -121,18 +153,29 @@ jobs:
with:
key: xcode-cache-${{ runner.os }}
max-size: 700M
- uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57
- uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57
continue-on-error: true
name: Pods Cache
id: pods-cache
with:
# Must match the save path exactly
path: tests/ios/Pods
key: ${{ runner.os }}-fdc-pods-v3-${{ hashFiles('tests/ios/Podfile.lock') }}
restore-keys: ${{ runner.os }}-ios-pods-v2
- name: 'Install Tools'
run: |
sudo npm i -g firebase-tools
echo "FIREBASE_TOOLS_VERSION=$(npm firebase --version)" >> $GITHUB_ENV
- name: Firebase Emulator Cache
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57
id: firebase-emulator-cache
uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57
continue-on-error: true
with:
# The firebase emulators are pure javascript and java, OS-independent
enableCrossOsArchive: true
# Must match the save path exactly
path: ~/.cache/firebase/emulators
key: firebase-emulators-v3-fdc-${{ runner.os }}
key: firebase-emulators-v3-${{ env.FIREBASE_TOOLS_VERSION }}
restore-keys: firebase-emulators-v3
- uses: subosito/flutter-action@f2c4f6686ca8e8d6e6d0f28410eeef506ed66aff
with:
Expand All @@ -144,9 +187,6 @@ jobs:
melos-version: '5.3.0'
- name: 'Bootstrap package'
run: melos bootstrap --scope "firebase_data_connect*"
- name: 'Install Tools'
run: |
sudo npm i -g firebase-tools
- name: 'Build Application'
working-directory: 'packages/firebase_data_connect/firebase_data_connect/example'
run: |
Expand Down Expand Up @@ -178,6 +218,24 @@ jobs:
# Uncomment following line to have simulator logs printed out for debugging purposes.
# xcrun simctl spawn booted log stream --predicate 'eventMessage contains "flutter"' &
flutter test integration_test/e2e_test.dart -d "$SIMULATOR" --dart-define=CI=true
- name: Save Firestore Emulator Cache
# Branches can read main cache but main cannot read branch cache. Avoid LRU eviction with main-only cache.
if: github.ref == 'refs/heads/main'
uses: actions/cache/save@1bd1e32a3bdc45362d1e726936510720a7c30a57
continue-on-error: true
with:
key: ${{ steps.firebase-emulator-cache.outputs.cache-primary-key }}
# Must match the restore path exactly
path: ~/.cache/firebase/emulators
- name: Save Pods Cache
# Branches can read main cache but main cannot read branch cache. Avoid LRU eviction with main-only cache.
if: github.ref == 'refs/heads/main'
uses: actions/cache/save@1bd1e32a3bdc45362d1e726936510720a7c30a57
continue-on-error: true
with:
key: ${{ steps.pods-cache.outputs.cache-primary-key }}
# Must match the restore paths exactly
path: tests/ios/Pods

web:
runs-on: macos-latest
Expand Down Expand Up @@ -207,12 +265,19 @@ jobs:
- name: 'Bootstrap package'
run: melos bootstrap --scope "firebase_data_connect*"
- name: 'Install Tools'
run: sudo npm i -g firebase-tools
- name: Cache Firebase Emulator
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57
run: |
sudo npm i -g firebase-tools
echo "FIREBASE_TOOLS_VERSION=$(npm firebase --version)" >> $GITHUB_ENV
- name: Firebase Emulator Cache
id: firebase-emulator-cache
uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57
continue-on-error: true
with:
# The firebase emulators are pure javascript and java, OS-independent
enableCrossOsArchive: true
# Must match the save path exactly
path: ~/.cache/firebase/emulators
key: firebase-emulators-v3-fdc-${{ runner.os }}
key: firebase-emulators-v3-${{ env.FIREBASE_TOOLS_VERSION }}
restore-keys: firebase-emulators-v3
- name: Start Firebase Emulator
run: |
Expand All @@ -237,3 +302,21 @@ jobs:
exit 1
fi
shell: bash
- name: Save Firestore Emulator Cache
# Branches can read main cache but main cannot read branch cache. Avoid LRU eviction with main-only cache.
if: github.ref == 'refs/heads/main'
uses: actions/cache/save@1bd1e32a3bdc45362d1e726936510720a7c30a57
continue-on-error: true
with:
key: ${{ steps.firebase-emulator-cache.outputs.cache-primary-key }}
# Must match the restore path exactly
path: ~/.cache/firebase/emulators
- name: Save Pods Cache
# Branches can read main cache but main cannot read branch cache. Avoid LRU eviction with main-only cache.
if: github.ref == 'refs/heads/main'
uses: actions/cache/save@1bd1e32a3bdc45362d1e726936510720a7c30a57
continue-on-error: true
with:
key: ${{ steps.pods-cache.outputs.cache-primary-key }}
# Must match the restore paths exactly
path: tests/ios/Pods
38 changes: 32 additions & 6 deletions .github/workflows/ios.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,29 @@ jobs:
with:
key: xcode-cache-${{ runner.os }}
max-size: 700M
- uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57
- uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57
continue-on-error: true
name: Pods Cache
id: pods-cache
with:
# Must match the save path exactly
path: tests/ios/Pods
key: pods-v3-${{ runner.os }}-${{ hashFiles('tests/ios/Podfile.lock') }}
restore-keys: pods-v3-${{ runner.os }}
- name: 'Install Tools'
run: |
sudo npm i -g firebase-tools
echo "FIREBASE_TOOLS_VERSION=$(npm firebase --version)" >> $GITHUB_ENV
- name: Firebase Emulator Cache
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57
id: firebase-emulator-cache
uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57
continue-on-error: true
with:
# The firebase emulators are pure javascript and java, OS-independent
enableCrossOsArchive: true
# Must match the save path exactly
path: ~/.cache/firebase/emulators
key: firebase-emulators-v3-${{ runner.os }}
key: firebase-emulators-v3-${{ env.FIREBASE_TOOLS_VERSION }}
restore-keys: firebase-emulators-v3
- uses: subosito/flutter-action@f2c4f6686ca8e8d6e6d0f28410eeef506ed66aff
with:
Expand All @@ -75,9 +86,6 @@ jobs:
melos-version: '5.3.0'
- name: 'Bootstrap package'
run: melos bootstrap --scope tests && melos bootstrap --scope "cloud_firestore*"
- name: 'Install Tools'
run: |
sudo npm i -g firebase-tools
- name: 'Free up space'
run: |
sudo rm -rf \
Expand Down Expand Up @@ -118,3 +126,21 @@ jobs:
# Uncomment following line to have simulator logs printed out for debugging purposes.
# xcrun simctl spawn booted log stream --predicate 'eventMessage contains "flutter"' &
flutter test integration_test/e2e_test.dart -d "$SIMULATOR" --ignore-timeouts --dart-define=CI=true
- name: Save Firestore Emulator Cache
# Branches can read main cache but main cannot read branch cache. Avoid LRU eviction with main-only cache.
if: github.ref == 'refs/heads/main'
uses: actions/cache/save@1bd1e32a3bdc45362d1e726936510720a7c30a57
continue-on-error: true
with:
key: ${{ steps.firebase-emulator-cache.outputs.cache-primary-key }}
# Must match the restore paths exactly
path: ~/.cache/firebase/emulators
- name: Save Pods Cache
# Branches can read main cache but main cannot read branch cache. Avoid LRU eviction with main-only cache.
if: github.ref == 'refs/heads/main'
uses: actions/cache/save@1bd1e32a3bdc45362d1e726936510720a7c30a57
continue-on-error: true
with:
key: ${{ steps.pods-cache.outputs.cache-primary-key }}
# Must match the restore paths exactly
path: tests/ios/Pods
Loading