chore(🐙): factorize android emulator creation step #701
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: CI Graphite | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - next | |
| pull_request: | |
| branches: | |
| - main | |
| - next | |
| merge_group: | |
| types: | |
| - checks_requested | |
| concurrency: | |
| group: ${{ github.ref }}-graphite | |
| cancel-in-progress: true | |
| jobs: | |
| build-android-ubuntu-graphite: | |
| runs-on: ubuntu-latest | |
| continue-on-error: true | |
| env: | |
| TURBO_CACHE_DIR: .turbo/android | |
| steps: | |
| - name: Free Disk Space (Ubuntu) | |
| run: | | |
| # Before cleanup | |
| echo "Disk usage before cleanup:" | |
| df -h | |
| # Remove large packages that are typically not needed | |
| sudo rm -rf /usr/share/dotnet | |
| sudo rm -rf /opt/ghc | |
| sudo rm -rf /usr/local/share/boost | |
| sudo rm -rf /usr/local/.ghcup | |
| sudo rm -rf /usr/share/swift | |
| # Clean apt cache | |
| sudo apt-get clean | |
| # After cleanup | |
| echo "Disk usage after cleanup:" | |
| df -h | |
| - name: Checkout | |
| uses: actions/checkout@ff7abcd0c3c05ccf6adc123a8cd1fd4fb30fb493 # v5.0.0 | |
| with: | |
| submodules: recursive | |
| - name: Setup | |
| uses: ./.github/actions/setup | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| graphite: true | |
| - name: Cache turborepo for Android | |
| uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 | |
| with: | |
| path: ${{ env.TURBO_CACHE_DIR }} | |
| key: ${{ runner.os }}-turborepo-android-${{ hashFiles('yarn.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-turborepo-android | |
| - name: Install JDK | |
| uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0 | |
| with: | |
| distribution: 'zulu' | |
| java-version: '17' | |
| - name: Install NDK | |
| uses: nttld/setup-ndk@afb4c9964b521afb97c864b7d40b11e6911bd410 # v1.5.0 | |
| id: setup-ndk | |
| with: | |
| ndk-version: r27d | |
| - name: Set ANDROID_NDK | |
| run: echo "ANDROID_NDK=$ANDROID_HOME/ndk-bundle" >> $GITHUB_ENV | |
| - name: Finalize Android SDK | |
| run: | | |
| /bin/bash -c "yes | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --licenses > /dev/null" | |
| - name: Install Android SDK | |
| run: | | |
| echo "sdk.dir=$ANDROID_HOME" > $GITHUB_WORKSPACE/apps/example/android/local.properties | |
| - name: Cache Gradle | |
| uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 | |
| with: | |
| path: | | |
| ~/.gradle/wrapper | |
| ~/.gradle/caches | |
| key: ${{ runner.os }}-gradle-${{ hashFiles('./apps/example/android/gradle/wrapper/gradle-wrapper.properties') }} | |
| restore-keys: | | |
| ${{ runner.os }}-gradle- | |
| - name: Build example for Android | |
| env: | |
| JAVA_OPTS: "-XX:MaxHeapSize=6g" | |
| run: | | |
| yarn turbo run build:android --concurrency 1 --filter=example | |
| build-android-graphite: | |
| runs-on: macos-latest-large | |
| continue-on-error: true | |
| env: | |
| TURBO_CACHE_DIR: .turbo/android | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@ff7abcd0c3c05ccf6adc123a8cd1fd4fb30fb493 # v5.0.0 | |
| with: | |
| submodules: recursive | |
| - name: Setup | |
| uses: ./.github/actions/setup | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| graphite: true | |
| - name: Cache turborepo for Android | |
| uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 | |
| with: | |
| path: ${{ env.TURBO_CACHE_DIR }} | |
| key: ${{ runner.os }}-turborepo-android-${{ hashFiles('yarn.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-turborepo-android | |
| - name: Install JDK | |
| uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0 | |
| with: | |
| distribution: 'zulu' | |
| java-version: '17' | |
| - name: Install NDK | |
| uses: nttld/setup-ndk@afb4c9964b521afb97c864b7d40b11e6911bd410 # v1.5.0 | |
| id: setup-ndk | |
| with: | |
| ndk-version: r26d | |
| - name: Set ANDROID_NDK | |
| run: echo "ANDROID_NDK=$ANDROID_HOME/ndk-bundle" >> $GITHUB_ENV | |
| - name: Finalize Android SDK | |
| run: | | |
| /bin/bash -c "yes | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --licenses > /dev/null" | |
| - name: Install Android SDK | |
| run: | | |
| echo "sdk.dir=$ANDROID_HOME" > $GITHUB_WORKSPACE/apps/example/android/local.properties | |
| - name: Cache Gradle | |
| uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 | |
| with: | |
| path: | | |
| ~/.gradle/wrapper | |
| ~/.gradle/caches | |
| key: ${{ runner.os }}-gradle-${{ hashFiles('./apps/example/android/gradle/wrapper/gradle-wrapper.properties') }} | |
| restore-keys: | | |
| ${{ runner.os }}-gradle- | |
| - name: Build example for Android | |
| env: | |
| JAVA_OPTS: "-XX:MaxHeapSize=16g" | |
| run: | | |
| yarn turbo run build:android --concurrency 1 | |
| - name: Cache apk | |
| uses: actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 | |
| env: | |
| cache-name: cache-apk | |
| with: | |
| path: apps/example/android/app/build/outputs/apk/debug/app-debug.apk | |
| key: apk-${{ github.sha }} | |
| test-android-graphite: | |
| needs: build-android-graphite | |
| runs-on: macos-latest-xlarge | |
| timeout-minutes: 60 | |
| env: | |
| TURBO_CACHE_DIR: .turbo/android | |
| steps: | |
| - name: checkout | |
| uses: actions/checkout@ff7abcd0c3c05ccf6adc123a8cd1fd4fb30fb493 # v5.0.0 | |
| with: | |
| submodules: recursive | |
| - name: Setup | |
| uses: ./.github/actions/setup | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| graphite: true | |
| - name: Restore APK | |
| id: cache-apk | |
| uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 | |
| with: | |
| path: apps/example/android/app/build/outputs/apk/debug/app-debug.apk | |
| key: apk-${{ github.sha }} | |
| - name: Setup Android Emulator | |
| uses: ./.github/actions/setup-android-emulator | |
| with: | |
| api_level: '30' | |
| device: 'Nexus 5X' | |
| gpu_mode: 'angle_indirect' | |
| avd_name: 'Pixel_API_30' | |
| - name: Start Package Manager | |
| working-directory: apps/example/ | |
| run: E2E=true yarn start & | |
| - name: Check APK existence | |
| uses: andstor/file-existence-action@076e0072799f4942c8bc574a82233e1e4d13e9d6 # v3.0.0 | |
| with: | |
| files: apps/example/android/app/build/outputs/apk/debug/app-debug.apk | |
| fail: true | |
| - name: Install APK | |
| run: adb install -r apps/example/android/app/build/outputs/apk/debug/app-debug.apk | |
| # - name: Set up environment | |
| # run: echo "PACKAGE_NAME=${{ env.PACKAGE_NAME }}" >> $GITHUB_ENV | |
| - name: Launch APK | |
| env: | |
| PACKAGE_NAME: 'com.microsoft.reacttestapp' | |
| run: adb shell monkey -p ${{ env.PACKAGE_NAME }} 1 | |
| # On fabric, the system fonts are slightly different | |
| # so wont run the paragraph tests there for now | |
| - name: Run e2e Tests | |
| working-directory: packages/skia | |
| run: | | |
| CI=true E2E=true yarn test -i Paths --testPathIgnorePatterns Paragraphs | |
| - uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0 | |
| if: failure() | |
| with: | |
| path: packages/skia/src/__tests__/snapshots/ | |
| name: tests-snapshots-screenshots | |
| - uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0 | |
| if: failure() | |
| with: | |
| path: apps/docs/static/ | |
| name: tests-docs-screenshots | |
| build-test-ios-graphite: | |
| runs-on: macos-latest-xlarge | |
| env: | |
| TURBO_CACHE_DIR: .turbo/ios | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@ff7abcd0c3c05ccf6adc123a8cd1fd4fb30fb493 # v5.0.0 | |
| with: | |
| submodules: recursive | |
| - name: Setup | |
| uses: ./.github/actions/setup | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| graphite: true | |
| - name: Cache turborepo for iOS | |
| uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 | |
| with: | |
| path: ${{ env.TURBO_CACHE_DIR }} | |
| key: ${{ runner.os }}-turborepo-ios-${{ hashFiles('yarn.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-turborepo-ios- | |
| - name: Check turborepo cache for iOS | |
| run: | | |
| TURBO_CACHE_STATUS=$(node -p "($(yarn turbo run build:ios --cache-dir=\"${{ env.TURBO_CACHE_DIR }}\" --dry=json)).tasks.find(t => t.task === 'build:ios').cache.status") | |
| if [[ $TURBO_CACHE_STATUS == "HIT" ]]; then | |
| echo "turbo_cache_hit=1" >> $GITHUB_ENV | |
| fi | |
| - name: Install CocoaPods | |
| working-directory: apps/example/ios | |
| run: pod install | |
| - name: Start Package Manager | |
| working-directory: apps/example | |
| run: E2E=true yarn start & | |
| - name: Build example for iOS | |
| working-directory: apps/example | |
| run: yarn ios --simulator 'iPhone 16 Pro' | |
| - name: Run e2e tests | |
| working-directory: packages/skia | |
| run: CI=true E2E=true yarn test -i Paths |