ci: fix nightly builds (#18426) #3407
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-android | ||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }}-android | ||
| cancel-in-progress: true | ||
| permissions: | ||
| contents: read | ||
| on: | ||
| pull_request: | ||
| paths-ignore: | ||
| - 'docs/**' | ||
| - 'website/**' | ||
| - '**/example/**' | ||
| - '!**/example/integration_test/**' | ||
| - '**/flutterfire_ui/**' | ||
| - '**.md' | ||
| push: | ||
| branches: | ||
| - main | ||
| paths-ignore: | ||
| - 'docs/**' | ||
| - 'website/**' | ||
| - '**/example/**' | ||
| - '!**/example/integration_test/**' | ||
| - '**/flutterfire_ui/**' | ||
| - '**.md' | ||
| workflow_call: | ||
| inputs: | ||
| nightly_test_mode: | ||
| type: boolean | ||
| default: false | ||
| permissions: | ||
| contents: read | ||
| jobs: | ||
| android: | ||
| permissions: | ||
| contents: read | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: ${{ inputs.nightly_test_mode && 5 || 45 }} | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| working_directory: | ||
| ['tests', 'packages/cloud_firestore/cloud_firestore/example'] | ||
| exclude: | ||
| - working_directory: ${{ inputs.nightly_test_mode && 'packages/cloud_firestore/cloud_firestore/example' || 'none' }} | ||
| env: | ||
| AVD_ARCH: x86_64 | ||
| AVD_API_LEVEL: 34 | ||
| AVD_TARGET: google_apis | ||
| steps: | ||
| - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 | ||
| - uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a | ||
| name: Install Node.js 20 | ||
| with: | ||
| node-version: '20' | ||
| - uses: actions/setup-java@1bcf9fb12cf4aa7d266a90ae39939e61372fe520 | ||
| with: | ||
| distribution: 'temurin' | ||
| java-version: '21' | ||
| - name: 'Install Tools' | ||
| 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@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 | ||
| 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-${{ env.FIREBASE_TOOLS_VERSION }} | ||
| restore-keys: firebase-emulators-v3 | ||
| - uses: subosito/flutter-action@1a449444c387b1966244ae4d4f8c696479add0b2 | ||
| with: | ||
| channel: 'stable' | ||
| cache: true | ||
| cache-key: "flutter-:os:-:channel:-:version:-:arch:-:hash:" | ||
| pub-cache-key: "flutter-pub-:os:-:channel:-:version:-:arch:-:hash:" | ||
| - uses: bluefireteam/melos-action@705015c3d2bc4ab94201ac24accb2bbe070cf533 | ||
| with: | ||
| run-bootstrap: false | ||
| melos-version: '5.3.0' | ||
| - name: 'Bootstrap package' | ||
| run: melos bootstrap --scope tests && melos bootstrap --scope "cloud_firestore*" | ||
| - name: Start Firebase Emulator | ||
| run: cd ./.github/workflows/scripts && ./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@90ddb51e90a5fd9ba75f40cf85156b7b41bf76a3 | ||
| - 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: Prepare AVD home on /mnt | ||
| # GitHub-hosted runners mount a ~74GB volume at /mnt. Create it before AVD cache | ||
| # restore and android-emulator-runner (avdmanager needs the space at create time). | ||
| run: | | ||
| sudo mkdir -p /mnt/avd | ||
| sudo chown "$USER:$USER" /mnt/avd | ||
| df -h / /mnt | ||
| - name: AVD cache | ||
| uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 | ||
| continue-on-error: true | ||
| id: avd-cache | ||
| with: | ||
| # Must match the save path exactly | ||
| path: | | ||
| /mnt/avd/* | ||
| ~/.android/adb* | ||
| key: avd-${{ runner.os }}-${{ env.AVD_API_LEVEL }}-${{ env.AVD_TARGET }}-${{ env.AVD_ARCH }} | ||
| - name: Link AVD home to /mnt | ||
| # android-emulator-runner exportVariables ANDROID_AVD_HOME to $HOME/.android/avd | ||
| run: | | ||
| mkdir -p "$HOME/.android" | ||
| rm -rf "$HOME/.android/avd" | ||
| ln -s /mnt/avd "$HOME/.android/avd" | ||
| - name: Start AVD then run E2E tests | ||
| uses: reactivecircus/android-emulator-runner@e89f39f1abbbd05b1113a29cf4db69e7540cae5a | ||
| env: | ||
| ANDROID_AVD_HOME: /mnt/avd | ||
| with: | ||
| api-level: ${{ env.AVD_API_LEVEL }} | ||
| target: ${{ env.AVD_TARGET }} | ||
| arch: ${{ env.AVD_ARCH }} | ||
| emulator-build: 14214601 | ||
| working-directory: ${{ matrix.working_directory }} | ||
| script: | | ||
| flutter test integration_test/e2e_test.dart --timeout 10x --dart-define=CI=true -d emulator-5554 | ||
| - name: Ensure Appium is shut down | ||
| # Required because of below issue where emulator failing to shut down properly causes tests to fail | ||
| # 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' | ||
| uses: actions/cache/save@27d5ce7f107fe9357f9df03efb73ab90386fccae | ||
| with: | ||
| # The firebase emulators are pure javascript and java, OS-independent | ||
| enableCrossOsArchive: true | ||
| 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@27d5ce7f107fe9357f9df03efb73ab90386fccae | ||
| with: | ||
| key: ${{ steps.avd-cache.outputs.cache-primary-key }} | ||
| # Must match the restore path exactly | ||
| path: | | ||
| /mnt/avd/* | ||
| ~/.android/adb* | ||
| agp9-compatibility: | ||
| permissions: | ||
| contents: read | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 30 | ||
| steps: | ||
| - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 | ||
| - uses: actions/setup-java@1bcf9fb12cf4aa7d266a90ae39939e61372fe520 | ||
| with: | ||
| distribution: 'temurin' | ||
| java-version: '21' | ||
| - uses: subosito/flutter-action@1a449444c387b1966244ae4d4f8c696479add0b2 | ||
| with: | ||
| channel: 'stable' | ||
| cache: true | ||
| cache-key: "flutter-:os:-:channel:-:version:-:arch:-:hash:" | ||
| pub-cache-key: "flutter-pub-:os:-:channel:-:version:-:arch:-:hash:" | ||
| - uses: bluefireteam/melos-action@705015c3d2bc4ab94201ac24accb2bbe070cf533 | ||
| with: | ||
| run-bootstrap: false | ||
| melos-version: '5.3.0' | ||
| - name: 'Bootstrap tests package' | ||
| run: melos bootstrap --scope tests | ||
| - name: Gradle cache | ||
| uses: gradle/actions/setup-gradle@0b6dd653ba04f4f93bf581ec31e66cbd7dcb644d | ||
| - name: 'Build tests app with AGP 9' | ||
| run: bash ./.github/workflows/scripts/agp9-compatibility.sh | ||