chore(ci): implement best practices for CI caching #2110
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-web | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| 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' | |
| jobs: | |
| web: | |
| runs-on: macos-latest | |
| timeout-minutes: 15 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| working_directory: | |
| ['tests', 'packages/cloud_firestore/cloud_firestore/example'] | |
| 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' | |
| - uses: subosito/flutter-action@f2c4f6686ca8e8d6e6d0f28410eeef506ed66aff | |
| with: | |
| channel: 'stable' | |
| cache: true | |
| cache-key: flutter-${{ runner.os }} | |
| pub-cache-key: pub-${{ runner.os }} | |
| - uses: bluefireteam/melos-action@c7dcb921b23cc520cace360b95d02b37bf09cdaa | |
| with: | |
| run-bootstrap: false | |
| 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 | |
| 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-${{ env.FIREBASE_TOOLS_VERSION }} | |
| restore-keys: firebase-emulators-v3 | |
| - name: Start Firebase Emulator | |
| run: sudo chown -R 501:20 "/Users/runner/.npm" && cd ./.github/workflows/scripts && ./start-firebase-emulator.sh | |
| - name: 'E2E Tests' | |
| working-directory: ${{ matrix.working_directory }} | |
| # 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 | |
| - 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' | |
| continue-on-error: true | |
| 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 | |
| web-app-check: | |
| runs-on: macos-latest | |
| timeout-minutes: 15 | |
| 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' | |
| - uses: subosito/flutter-action@f2c4f6686ca8e8d6e6d0f28410eeef506ed66aff | |
| with: | |
| channel: 'stable' | |
| cache: true | |
| cache-key: flutter-${{ runner.os }} | |
| pub-cache-key: pub-${{ runner.os }} | |
| - uses: bluefireteam/melos-action@c7dcb921b23cc520cace360b95d02b37bf09cdaa | |
| with: | |
| run-bootstrap: false | |
| melos-version: '5.3.0' | |
| - name: 'Bootstrap package' | |
| run: melos bootstrap --scope tests | |
| - 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@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-${{ env.FIREBASE_TOOLS_VERSION }} | |
| restore-keys: firebase-emulators-v3 | |
| - name: Start Firebase Emulator | |
| run: sudo chown -R 501:20 "/Users/runner/.npm" && cd ./.github/workflows/scripts && ./start-firebase-emulator.sh | |
| - name: 'E2E Tests' | |
| working-directory: tests | |
| # 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 --dart-define=APP_CHECK_E2E=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 | |
| - 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 | |
| web-wasm: | |
| runs-on: macos-latest | |
| timeout-minutes: 15 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| working_directory: | |
| ['tests', 'packages/cloud_firestore/cloud_firestore/example'] | |
| 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' | |
| - uses: subosito/flutter-action@f2c4f6686ca8e8d6e6d0f28410eeef506ed66aff | |
| with: | |
| channel: 'stable' | |
| cache: true | |
| cache-key: flutter-${{ runner.os }} | |
| pub-cache-key: pub-${{ runner.os }} | |
| - uses: bluefireteam/melos-action@c7dcb921b23cc520cace360b95d02b37bf09cdaa | |
| with: | |
| run-bootstrap: false | |
| 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 | |
| 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-${{ env.FIREBASE_TOOLS_VERSION }} | |
| restore-keys: firebase-emulators-v3 | |
| - name: Start Firebase Emulator | |
| run: sudo chown -R 501:20 "/Users/runner/.npm" && cd ./.github/workflows/scripts && ./start-firebase-emulator.sh | |
| - name: 'E2E Tests' | |
| working-directory: ${{ matrix.working_directory }} | |
| # 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 & | |
| mv ./web/wasm_index.html ./web/index.html | |
| flutter drive --target=./integration_test/e2e_test.dart --driver=./test_driver/integration_test.dart -d chrome --wasm --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 | |
| - 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 |