name: Runtime tests Android env: YARN_ENABLE_HARDENED_MODE: 0 on: workflow_call: inputs: bundleMode: required: false type: boolean default: false configuration: required: false type: string default: Debug full: required: false type: boolean default: false workflow_dispatch: inputs: bundleMode: required: false type: boolean default: false configuration: required: false type: string default: Debug full: required: false type: boolean default: false permissions: contents: read jobs: runtime-tests-android: if: github.repository == 'software-mansion/react-native-reanimated' name: ${{ matrix.bundleMode && 'Bundle Mode' || 'Legacy Eval' }} runs-on: ubuntu-latest timeout-minutes: 90 strategy: fail-fast: false matrix: bundleMode: ${{ fromJSON(format('[{0}]', inputs.bundleMode)) }} env: WORKING_DIRECTORY: apps/fabric-example REANIMATED_DIR: packages/react-native-reanimated CONFIGURATION: ${{ inputs.configuration || 'Debug' }} concurrency: group: runtime-tests-android-${{ github.workflow }}-${{ github.ref }}-${{ matrix.bundleMode }}-${{ inputs.configuration || 'Debug' }} cancel-in-progress: true steps: - name: Check out Git repository uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 with: persist-credentials: false - 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: Setup Java 17 uses: actions/setup-java@17f84c3641ba7b8f6deff6309fc4c864478f5d62 with: distribution: 'zulu' java-version: 17 - name: Set up Gradle network access uses: $/.github/actions/setup-gradle-network - name: Install Android NDK uses: $/.github/actions/install-android-ndk - name: Use Node.js id: setup-node uses: $/.github/actions/setup-node-yarn with: node-version-file: '.nvmrc' - name: Install monorepo node dependencies run: yarn install --immutable - name: Save Yarn cache uses: $/.github/actions/save-yarn-cache with: cache-hit: ${{ steps.setup-node.outputs.cache-hit }} cache-primary-key: ${{ steps.setup-node.outputs.cache-primary-key }} cache-path: ${{ steps.setup-node.outputs.cache-path }} - name: Toggle Bundle Mode off (Legacy Eval) if: ${{ !matrix.bundleMode }} run: yarn toggle-bundle-mode - name: Build Reanimated package working-directory: ${{ env.REANIMATED_DIR }} run: yarn build - name: Build app working-directory: ${{ env.WORKING_DIRECTORY }}/android # Temporary: GWP-ASan is disabled on the x86_64 emulator because its backtrace recorder can crash # the app. Remove -PruntimeTestsDisableGwpAsan when # https://github.com/software-mansion/react-native-reanimated/issues/10960 is resolved. run: ./gradlew "assemble$CONFIGURATION" --build-cache -PreactNativeArchitectures=x86_64 -PruntimeTestsDisableGwpAsan=true - name: AVD cache id: avd-cache uses: actions/cache@6f8efc29b200d32929f49075959781ed54ec270c with: path: | ~/.android/avd/* ~/.android/adb* key: avd-34-x86_64 - name: Install Android Emulator uses: $/.github/actions/install-android-emulator with: api-level: 34 arch: x86_64 - name: Create AVD and generate a boot snapshot if: steps.avd-cache.outputs.cache-hit != 'true' uses: reactivecircus/android-emulator-runner@a421e43855164a8197daf9d8d40fe71c6996bb0d with: api-level: 34 arch: x86_64 force-avd-creation: false emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none disable-animations: false working-directory: apps/fabric-example script: echo "Generated AVD snapshot for caching." - name: Run runtime tests on the emulator uses: reactivecircus/android-emulator-runner@a421e43855164a8197daf9d8d40fe71c6996bb0d env: RUNTIME_TESTS_ARGS: --launch --platform android --configuration ${{ env.CONFIGURATION }} --skip-build --connect-timeout 900 --idle-timeout 900 ${{ inputs.full && '--full' || '' }} with: api-level: 34 arch: x86_64 force-avd-creation: false emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none disable-animations: false working-directory: apps/fabric-example script: | echo "::group::ReJest self-tests"; node --experimental-strip-types scripts/runtime-tests-server.mts $RUNTIME_TESTS_ARGS --library self-tests; status=$?; echo "::endgroup::"; exit $status echo "::group::Verify CI catches failing tests"; if RUNTIME_TESTS_CI_REPORT=0 node --experimental-strip-types scripts/runtime-tests-server.mts $RUNTIME_TESTS_ARGS --library self-tests --only "intentional failures"; then echo "A failing suite did not fail the runner"; status=1; else echo "Failing tests correctly failed the runner"; status=0; fi; echo "::endgroup::"; exit $status echo "::group::Worklets runtime tests"; node --experimental-strip-types scripts/runtime-tests-server.mts $RUNTIME_TESTS_ARGS --library worklets; status=$?; echo "::endgroup::"; exit $status echo "::group::Worklets runtime tests in a headless JS task"; node --experimental-strip-types scripts/runtime-tests-server.mts $RUNTIME_TESTS_ARGS --library worklets --headless-task; status=$?; echo "::endgroup::"; exit $status echo "::group::Reanimated runtime tests"; node --experimental-strip-types scripts/runtime-tests-server.mts $RUNTIME_TESTS_ARGS --library reanimated; status=$?; echo "::endgroup::"; exit $status - name: Show disk usage if: always() run: df -h / - name: Upload crash reports if: failure() uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 with: name: android-crash-reports-${{ inputs.configuration || 'Debug' }}-${{ matrix.bundleMode && 'bundle-mode' || 'legacy-eval' }} path: apps/fabric-example/crash-reports if-no-files-found: ignore retention-days: 14