ci: run Harness in CI #14
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 | |
| pull_request: | |
| branches: | |
| - main | |
| merge_group: | |
| types: | |
| - checks_requested | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| env: | |
| # Android emulator configuration | |
| ANDROID_API_LEVEL: '35' | |
| ANDROID_ARCH: 'x86_64' | |
| ANDROID_PROFILE: 'pixel_6' | |
| ANDROID_AVD_NAME: 'Pixel_8_API_35' | |
| # iOS simulator configuration | |
| IOS_DEVICE_MODEL: 'iPhone 17 Pro' | |
| IOS_VERSION: '26.0' | |
| XCODE_VERSION: '26.1.1' | |
| jobs: | |
| lint: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| - name: Setup | |
| uses: ./.github/actions/setup | |
| - name: Lint files | |
| run: yarn lint | |
| - name: Typecheck files | |
| run: yarn typecheck | |
| build-library: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| - name: Setup | |
| uses: ./.github/actions/setup | |
| - name: Build package | |
| run: yarn prepare | |
| harness-android: | |
| runs-on: ubuntu-latest | |
| env: | |
| TURBO_CACHE_DIR: .turbo/android | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| - name: Setup | |
| uses: ./.github/actions/setup | |
| - name: Cache turborepo for Android | |
| uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 | |
| with: | |
| path: ${{ env.TURBO_CACHE_DIR }} | |
| key: ${{ runner.os }}-turborepo-android-${{ hashFiles('yarn.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-turborepo-android- | |
| - name: Check turborepo cache status | |
| run: | | |
| # Check if harness tests can be skipped entirely | |
| HARNESS_CACHE_STATUS=$(node -p "($(yarn turbo run test:harness:android --cache-dir="${{ env.TURBO_CACHE_DIR }}" --dry=json)).tasks.find(t => t.task === 'test:harness:android').cache.status") | |
| if [[ $HARNESS_CACHE_STATUS == "HIT" ]]; then | |
| echo "harness_cache_hit=1" >> $GITHUB_ENV | |
| fi | |
| # Check if native build can be skipped (to avoid installing JDK/Gradle) | |
| BUILD_CACHE_STATUS=$(node -p "($(yarn turbo run build:android --cache-dir="${{ env.TURBO_CACHE_DIR }}" --dry=json)).tasks.find(t => t.task === 'build:android').cache.status") | |
| if [[ $BUILD_CACHE_STATUS == "HIT" ]]; then | |
| echo "build_cache_hit=1" >> $GITHUB_ENV | |
| fi | |
| - name: Reclaim disk space | |
| if: env.harness_cache_hit != 1 | |
| uses: AdityaGarg8/remove-unwanted-software@v5 | |
| with: | |
| remove-dotnet: true | |
| remove-haskell: true | |
| remove-codeql: true | |
| remove-docker-images: true | |
| - name: Install JDK | |
| if: env.harness_cache_hit != 1 && env.build_cache_hit != 1 | |
| uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1 | |
| with: | |
| distribution: 'zulu' | |
| java-version: '17' | |
| - name: Finalize Android SDK | |
| if: env.harness_cache_hit != 1 && env.build_cache_hit != 1 | |
| run: | | |
| /bin/bash -c "yes | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --licenses > /dev/null" | |
| - name: Cache Gradle | |
| if: env.harness_cache_hit != 1 && env.build_cache_hit != 1 | |
| uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 | |
| with: | |
| path: | | |
| ~/.gradle/wrapper | |
| ~/.gradle/caches | |
| key: ${{ runner.os }}-gradle-${{ hashFiles('example/android/gradle/wrapper/gradle-wrapper.properties') }} | |
| restore-keys: | | |
| ${{ runner.os }}-gradle- | |
| - name: Build example for Android | |
| if: env.harness_cache_hit != 1 | |
| env: | |
| JAVA_OPTS: "-XX:MaxHeapSize=6g" | |
| run: | | |
| yarn turbo run build:android --cache-dir="${{ env.TURBO_CACHE_DIR }}" | |
| - name: Enable KVM group perms | |
| if: env.harness_cache_hit != 1 | |
| 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 | |
| ls /dev/kvm | |
| - name: AVD cache | |
| if: env.harness_cache_hit != 1 | |
| uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 | |
| id: avd-cache | |
| with: | |
| path: | | |
| ~/.android/avd/* | |
| ~/.android/adb* | |
| key: avd-${{ env.ANDROID_API_LEVEL }}-${{ env.ANDROID_ARCH }} | |
| - name: Create AVD and generate snapshot for caching | |
| if: env.harness_cache_hit != 1 && steps.avd-cache.outputs.cache-hit != 'true' | |
| uses: reactivecircus/android-emulator-runner@v2 | |
| with: | |
| api-level: ${{ env.ANDROID_API_LEVEL }} | |
| arch: ${{ env.ANDROID_ARCH }} | |
| profile: ${{ env.ANDROID_PROFILE }} | |
| disk-size: 1G | |
| heap-size: 1G | |
| force-avd-creation: false | |
| avd-name: ${{ env.ANDROID_AVD_NAME }} | |
| disable-animations: true | |
| emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none | |
| script: echo "Generated AVD snapshot for caching." | |
| - name: Run Harness E2E tests | |
| if: env.harness_cache_hit != 1 | |
| uses: reactivecircus/android-emulator-runner@v2 | |
| with: | |
| working-directory: example | |
| api-level: ${{ env.ANDROID_API_LEVEL }} | |
| arch: ${{ env.ANDROID_ARCH }} | |
| force-avd-creation: false | |
| avd-name: ${{ env.ANDROID_AVD_NAME }} | |
| disable-animations: true | |
| emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none | |
| script: | | |
| adb install -r "./android/app/build/outputs/apk/debug/app-debug.apk" | |
| yarn turbo run test:harness:android --cache-dir="${{ env.TURBO_CACHE_DIR }}" | |
| harness-ios: | |
| runs-on: macos-latest | |
| env: | |
| TURBO_CACHE_DIR: .turbo/ios | |
| RCT_USE_RN_DEP: 1 | |
| RCT_USE_PREBUILT_RNCORE: 1 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| - name: Setup | |
| uses: ./.github/actions/setup | |
| - name: Cache turborepo for iOS | |
| uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 | |
| with: | |
| path: ${{ env.TURBO_CACHE_DIR }} | |
| key: ${{ runner.os }}-turborepo-ios-${{ hashFiles('yarn.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-turborepo-ios- | |
| - name: Check turborepo cache status | |
| run: | | |
| # Check if harness tests can be skipped entirely | |
| HARNESS_CACHE_STATUS=$(node -p "($(yarn turbo run test:harness:ios --cache-dir="${{ env.TURBO_CACHE_DIR }}" --dry=json)).tasks.find(t => t.task === 'test:harness:ios').cache.status") | |
| if [[ $HARNESS_CACHE_STATUS == "HIT" ]]; then | |
| echo "harness_cache_hit=1" >> $GITHUB_ENV | |
| fi | |
| # Check if native build can be skipped (to avoid installing Xcode/CocoaPods) | |
| BUILD_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 [[ $BUILD_CACHE_STATUS == "HIT" ]]; then | |
| echo "build_cache_hit=1" >> $GITHUB_ENV | |
| fi | |
| - name: Use appropriate Xcode version | |
| if: env.harness_cache_hit != 1 && env.build_cache_hit != 1 | |
| uses: maxim-lobanov/setup-xcode@60606e260d2fc5762a71e64e74b2174e8ea3c8bd # v1.6.0 | |
| with: | |
| xcode-version: ${{ env.XCODE_VERSION }} | |
| - name: Install cocoapods | |
| if: env.harness_cache_hit != 1 && env.build_cache_hit != 1 | |
| run: | | |
| cd example | |
| bundle install | |
| bundle exec pod repo update --verbose | |
| bundle exec pod install --project-directory=ios | |
| - name: Build example for iOS | |
| if: env.harness_cache_hit != 1 | |
| run: | | |
| yarn turbo run build:ios --cache-dir="${{ env.TURBO_CACHE_DIR }}" | |
| - name: Setup iOS Simulator | |
| if: env.harness_cache_hit != 1 | |
| uses: futureware-tech/simulator-action@v4 | |
| with: | |
| model: ${{ env.IOS_DEVICE_MODEL }} | |
| os: iOS | |
| os_version: ${{ env.IOS_VERSION }} | |
| wait_for_boot: true | |
| erase_before_boot: false | |
| - name: Install app on simulator | |
| if: env.harness_cache_hit != 1 | |
| run: | | |
| xcrun simctl install booted example/ios/build/Build/Products/Debug-iphonesimulator/WebworkerExample.app | |
| - name: Run Harness E2E tests | |
| if: env.harness_cache_hit != 1 | |
| run: | | |
| yarn turbo run test:harness:ios --cache-dir="${{ env.TURBO_CACHE_DIR }}" |