chore(🐙): Factorize use of the Android emulator #2068
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: CI | ||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| - next | ||
| pull_request: | ||
| branches: | ||
| - main | ||
| - next | ||
| merge_group: | ||
| types: | ||
| - checks_requested | ||
| concurrency: | ||
| group: ${{ github.ref }} | ||
| cancel-in-progress: true | ||
| jobs: | ||
| lint: | ||
| runs-on: ubuntu-latest | ||
| 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 }} | ||
| - uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0 | ||
| - run: pip install cpplint | ||
| - run: cpplint --linelength=230 --filter=-legal/copyright,-whitespace/indent,-whitespace/comments,-whitespace/ending_newline,-build/include_order,-runtime/references,-readability/todo,-whitespace/blank_line,-whitespace/todo,-runtime/int,-build/c++11,-whitespace/parens --exclude=package/cpp/skia --exclude=package/apple --exclude=package/android/build --exclude=package/node_modules --recursive package | ||
| - name: Install clang-format | ||
| run: sudo apt-get update && sudo apt-get install -y clang-format-18 | ||
| # - name: Clang Format Check | ||
| # working-directory: packages/skia | ||
| # run: | | ||
| # yarn clang-format | ||
| # if [[ `git status --porcelain` ]]; then | ||
| # echo "ERROR: clang-format would modify files. Please run 'yarn clang-format' and commit the changes." | ||
| # echo "Files that would be modified:" | ||
| # git status --porcelain | ||
| # echo "Diff of changes:" | ||
| # git diff | ||
| # exit 1 | ||
| # fi | ||
| - name: Lint files | ||
| run: yarn lint | ||
| - name: Typecheck files | ||
| run: yarn tsc | ||
| test: | ||
| runs-on: macos-latest | ||
| 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 }} | ||
| - name: Test | ||
| run: yarn test | ||
| build-library: | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| run_id: ${{ github.run_id }} | ||
| 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 }} | ||
| - name: Build package | ||
| run: yarn build | ||
| - name: Pack package | ||
| working-directory: packages/skia | ||
| run: yarn pack | ||
| - name: Upload package artifact | ||
| uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0 | ||
| with: | ||
| name: package-tgz | ||
| path: packages/skia/package.tgz | ||
| - name: Build dry run release | ||
| working-directory: packages/skia | ||
| run: | | ||
| npx semantic-release --dry-run | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| YARN_NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
| test-package-e2e: | ||
| needs: build-library | ||
| uses: ./.github/workflows/test-skia-package.yml | ||
|
Check failure on line 113 in .github/workflows/ci.yml
|
||
| with: | ||
| skia_version: artifact:${{ needs.build-library.outputs.run_id }} | ||
| test_ios: true | ||
| test_android: true | ||
| test_web: true | ||
| build-windows-library: | ||
| runs-on: windows-latest | ||
| 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 }} | ||
| - name: Build package | ||
| run: yarn build | ||
| build-android-ubuntu: | ||
| runs-on: ubuntu-latest | ||
| 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 }} | ||
| - 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') }} | ||
| ${{ 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: | ||
| runs-on: macos-latest-large | ||
| 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 }} | ||
| - 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: | ||
| needs: build-android | ||
| runs-on: ubuntu-latest | ||
| 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 }} | ||
| - 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: 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: Run Android tests | ||
| uses: ./.github/actions/android-emulator | ||
| with: | ||
| api-level: '30' | ||
| target: 'default' | ||
| arch: 'x86_64' | ||
| profile: 'Nexus 5X' | ||
| avd-name: 'Pixel_API_30' | ||
| emulator-options: '-no-snapshot -no-window -gpu angle_indirect -noaudio -no-boot-anim -memory 4096' | ||
| script: | | ||
| set -euxo pipefail | ||
| PACKAGE_NAME='com.microsoft.reacttestapp' | ||
| APK_PATH='apps/example/android/app/build/outputs/apk/debug/app-debug.apk' | ||
| test -f "${APK_PATH}" | ||
| # Start the Metro bundler for E2E tests. | ||
| pushd apps/example | ||
| E2E=true yarn start & | ||
| METRO_PID=$! | ||
| popd | ||
| cleanup() { | ||
| kill "${METRO_PID}" 2>/dev/null || true | ||
| } | ||
| trap cleanup EXIT | ||
| # Give Metro a moment to start accepting connections. | ||
| sleep 25 | ||
| adb install -r "${APK_PATH}" | ||
| adb shell monkey -p "${PACKAGE_NAME}" 1 | ||
| pushd packages/skia | ||
| CI=true yarn e2e --testPathIgnorePatterns Paragraphs | ||
| popd | ||
| - 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: | ||
| 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 }} | ||
| - 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 yarn e2e | ||
| build-test-macos: | ||
| runs-on: macos-latest | ||
| env: | ||
| TURBO_CACHE_DIR: .turbo/macos | ||
| 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 }} | ||
| - name: Cache turborepo for macOS | ||
| uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 | ||
| with: | ||
| path: ${{ env.TURBO_CACHE_DIR }} | ||
| key: ${{ runner.os }}-turborepo-macos-${{ hashFiles('yarn.lock') }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-turborepo-macos- | ||
| - name: Build example for macOS | ||
| run: yarn turbo run build:macos --concurrency 1 | ||
| build-test-macos-catalyst: | ||
| runs-on: macos-latest | ||
| 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 }} | ||
| - name: Install CocoaPods and enable Catalyst | ||
| working-directory: apps/example | ||
| run: yarn pod:install:catalyst | ||
| - name: Build example for macOS Catalyst | ||
| working-directory: apps/example/ios | ||
| run: xcodebuild -workspace example.xcworkspace -scheme ReactTestApp -destination 'platform=macOS,arch=arm64,variant=Mac Catalyst' -configuration Debug build CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=NO | ||