chore(ci): implement best practices for CI caching #1756
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: e2e-fdc | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| on: | |
| pull_request: | |
| paths-ignore: | |
| - 'docs/**' | |
| - 'website/**' | |
| - '**/example/**' | |
| - '**/flutterfire_ui/**' | |
| - '**.md' | |
| push: | |
| branches: | |
| - master | |
| paths-ignore: | |
| - 'docs/**' | |
| - 'website/**' | |
| - '**/example/**' | |
| - '**.md' | |
| jobs: | |
| android: | |
| runs-on: ubuntu-latest | |
| 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 | |
| name: Install Node.js 20 | |
| with: | |
| node-version: '20' | |
| - uses: actions/setup-java@8df1039502a15bceb9433410b1a100fbe190c53b | |
| 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 | |
| continue-on-error: true | |
| with: | |
| # Branches can read main cache but main cannot read branch cache. Avoid LRU eviction with main-only cache. | |
| cache-read-only: ${{ github.ref != 'refs/heads/main' }} | |
| # The firebase emulators are pure javascript and java, OS-independent | |
| enableCrossOsArchive: true | |
| path: ~/.cache/firebase/emulators | |
| key: firebase-emulators-v3-${{ env.FIREBASE_TOOLS_VERSION }} | |
| restore-keys: firebase-emulators-v3 | |
| - uses: subosito/flutter-action@f2c4f6686ca8e8d6e6d0f28410eeef506ed66aff | |
| with: | |
| channel: 'stable' | |
| cache: true | |
| - name: Setup PostgreSQL for Linux/macOS/Windows | |
| uses: ikalnytskyi/action-setup-postgres@v7 | |
| - uses: bluefireteam/melos-action@c7dcb921b23cc520cace360b95d02b37bf09cdaa | |
| with: | |
| run-bootstrap: false | |
| melos-version: '5.3.0' | |
| - name: 'Bootstrap package' | |
| run: melos bootstrap --scope "firebase_data_connect*" | |
| - name: Start Firebase Emulator | |
| run: | | |
| cd ./packages/firebase_data_connect/firebase_data_connect/example | |
| unset PGSERVICEFILE | |
| firebase experiments:enable dataconnect | |
| ./start-firebase-emulator.sh | |
| - name: Enable KVM | |
| run: | | |
| echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules | |
| sudo udevadm control --reload-rules | |
| sudo udevadm trigger --name-match=kvm | |
| - name: Gradle cache | |
| uses: gradle/actions/setup-gradle@v4 | |
| - name: Free Disk Space (Ubuntu) | |
| uses: AdityaGarg8/remove-unwanted-software@90e01b21170618765a73370fcc3abbd1684a7793 | |
| with: | |
| remove-dotnet: true | |
| remove-haskell: true | |
| remove-codeql: true | |
| remove-docker-images: true | |
| remove-large-packages: true | |
| - name: AVD cache | |
| uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 | |
| continue-on-error: true | |
| id: avd-cache | |
| with: | |
| # Branches can read main cache but main cannot read branch cache. Avoid LRU eviction with main-only cache. | |
| cache-read-only: ${{ github.ref != 'refs/heads/main' }} | |
| path: | | |
| ~/.android/avd/* | |
| ~/.android/adb* | |
| 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: ${{ 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 | |
| ios: | |
| runs-on: macos-15 | |
| timeout-minutes: 45 | |
| strategy: | |
| fail-fast: false | |
| steps: | |
| - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 | |
| - uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a | |
| name: Install Node.js 20 | |
| with: | |
| node-version: '20' | |
| - name: Xcode | |
| run: sudo xcode-select -s /Applications/Xcode_16.4.app/Contents/Developer | |
| - uses: actions/setup-java@8df1039502a15bceb9433410b1a100fbe190c53b | |
| with: | |
| distribution: 'temurin' | |
| java-version: '17' | |
| - name: Setup PostgreSQL for Linux/macOS/Windows | |
| uses: ikalnytskyi/action-setup-postgres@v7 | |
| - uses: hendrikmuhs/ccache-action@c92f40bee50034e84c763e33b317c77adaa81c92 | |
| name: Xcode Compile Cache | |
| with: | |
| key: xcode-cache-${{ runner.os }} | |
| max-size: 700M | |
| - uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 | |
| continue-on-error: true | |
| name: Pods Cache | |
| id: pods-cache | |
| with: | |
| # Branches can read main cache but main cannot read branch cache. Avoid LRU eviction with main-only cache. | |
| cache-read-only: ${{ github.ref != 'refs/heads/main' }} | |
| 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 | |
| continue-on-error: true | |
| with: | |
| # Branches can read main cache but main cannot read branch cache. Avoid LRU eviction with main-only cache. | |
| cache-read-only: ${{ github.ref != 'refs/heads/main' }} | |
| # The firebase emulators are pure javascript and java, OS-independent | |
| enableCrossOsArchive: true | |
| path: ~/.cache/firebase/emulators | |
| key: firebase-emulators-v3-${{ env.FIREBASE_TOOLS_VERSION }} | |
| restore-keys: firebase-emulators-v3 | |
| - uses: subosito/flutter-action@f2c4f6686ca8e8d6e6d0f28410eeef506ed66aff | |
| with: | |
| channel: 'stable' | |
| cache: true | |
| - uses: bluefireteam/melos-action@c7dcb921b23cc520cace360b95d02b37bf09cdaa | |
| with: | |
| run-bootstrap: false | |
| melos-version: '5.3.0' | |
| - name: 'Bootstrap package' | |
| run: melos bootstrap --scope "firebase_data_connect*" | |
| - name: 'Build Application' | |
| working-directory: 'packages/firebase_data_connect/firebase_data_connect/example' | |
| run: | | |
| export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" | |
| export CCACHE_SLOPPINESS=clang_index_store,file_stat_matches,include_file_ctime,include_file_mtime,ivfsoverlay,pch_defines,modules,system_headers,time_macros | |
| export CCACHE_FILECLONE=true | |
| export CCACHE_DEPEND=true | |
| export CCACHE_INODECACHE=true | |
| ccache -s | |
| flutter build ios --no-codesign --simulator --debug --target=./integration_test/e2e_test.dart --dart-define=CI=true | |
| ccache -s | |
| - name: Start Firebase Emulator | |
| run: | | |
| sudo chown -R 501:20 "/Users/runner/.npm" | |
| cd ./packages/firebase_data_connect/firebase_data_connect/example | |
| unset PGSERVICEFILE | |
| firebase experiments:enable dataconnect | |
| ./start-firebase-emulator.sh | |
| - name: 'E2E Tests' | |
| working-directory: 'packages/firebase_data_connect/firebase_data_connect/example' | |
| run: | | |
| # Boot simulator and wait for System app to be ready. | |
| # List of available simulators: https://github.com/actions/runner-images/blob/main/images/macos/macos-14-Readme.md#installed-simulators | |
| SIMULATOR="iPhone 16" | |
| xcrun simctl bootstatus "$SIMULATOR" -b | |
| xcrun simctl logverbose "$SIMULATOR" enable | |
| # Sleep to allow simulator to settle. | |
| sleep 15 | |
| # 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 | |
| web: | |
| runs-on: macos-latest | |
| timeout-minutes: 15 | |
| strategy: | |
| fail-fast: false | |
| steps: | |
| - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 | |
| - uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a | |
| name: Install Node.js 20 | |
| with: | |
| node-version: '20' | |
| - uses: actions/setup-java@8df1039502a15bceb9433410b1a100fbe190c53b | |
| with: | |
| distribution: 'temurin' | |
| java-version: '17' | |
| - name: Setup PostgreSQL for Linux/macOS/Windows | |
| uses: ikalnytskyi/action-setup-postgres@v7 | |
| - uses: subosito/flutter-action@f2c4f6686ca8e8d6e6d0f28410eeef506ed66aff | |
| with: | |
| channel: 'stable' | |
| cache: true | |
| - uses: bluefireteam/melos-action@c7dcb921b23cc520cace360b95d02b37bf09cdaa | |
| with: | |
| run-bootstrap: false | |
| 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 | |
| echo "FIREBASE_TOOLS_VERSION=$(npm firebase --version)" >> $GITHUB_ENV | |
| - name: Cache Firebase Emulator | |
| uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 | |
| continue-on-error: true | |
| with: | |
| # Branches can read main cache but main cannot read branch cache. Avoid LRU eviction with main-only cache. | |
| cache-read-only: ${{ github.ref != 'refs/heads/main' }} | |
| # The firebase emulators are pure javascript and java, OS-independent | |
| enableCrossOsArchive: true | |
| path: ~/.cache/firebase/emulators | |
| key: firebase-emulators-v3-${{ env.FIREBASE_TOOLS_VERSION }} | |
| restore-keys: firebase-emulators-v3 | |
| - name: Start Firebase Emulator | |
| run: | | |
| sudo chown -R 501:20 "/Users/runner/.npm" | |
| cd ./packages/firebase_data_connect/firebase_data_connect/example | |
| unset PGSERVICEFILE | |
| firebase experiments:enable dataconnect | |
| ./start-firebase-emulator.sh | |
| - name: 'E2E Tests' | |
| working-directory: 'packages/firebase_data_connect/firebase_data_connect/example' | |
| # Web devices are not supported for the `flutter test` command yet. As a | |
| # workaround we can use the `flutter drive` command. Tracking issue: | |
| # https://github.com/flutter/flutter/issues/66264 | |
| run: | | |
| chromedriver --port=4444 --trace-buffer-size=100000 & | |
| flutter drive --target=./integration_test/e2e_test.dart --driver=./test_driver/integration_test.dart -d chrome --dart-define=CI=true | tee output.log | |
| # We have to check the output for failed tests matching the string "[E]" | |
| output=$(<output.log) | |
| if [[ "$output" =~ \[E\] ]]; then | |
| # You will see "All tests passed." in the logs even when tests failed. | |
| echo "All tests did not pass. Please check the logs for more information." | |
| exit 1 | |
| fi | |
| shell: bash |