diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index 41ccc750f..bd9437090 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -460,6 +460,94 @@ jobs: android/app/build/outputs/logs/ retention-days: 90 + # NOTE: this single cAT integration test is just to make sure cAT isn't broken + # if we revert back to cAT as the main integration test, we can remove this job + verify-connected-android-test-working-single-integration-test: + name: "Verify Connected Android Test Still Works (Working Single Integration Test)" + needs: [set_build_datetime] + runs-on: ubuntu-latest + strategy: + matrix: + arch: [x86_64] # Only test on x86_64 to save time and resources + fail-fast: false + env: + ENTRY_FILE: "index.tsx" + GRADLE_ABI: ${{ matrix.arch }} + BUILD_ARCH: ${{ matrix.arch }} + timeout-minutes: 30 + + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 1 + + # Execute the common setup with emulator configuration + - name: Common Setup + id: common-setup + uses: ./.github/actions/common-setup + with: + optional_cache_key: "integration-test" + gradle_max_workers: "4" + node_version: "22.x" + arch: ${{ matrix.arch }} + android_api_level: ${{ env.ANDROID_API_LEVEL }} + android_target: ${{ env.ANDROID_TARGET }} + android_profile: ${{ env.ANDROID_PROFILE }} + run_emulator_setup: "true" + + - name: Make scripts executable + run: | + chmod +x scripts/wait_for_emulator.sh + chmod +x scripts/run_verify_connected_android_test.sh + + - name: Debug directory structure + run: | + echo "Directory structure after download:" + if [ -d "android/${{ env.main_project_module }}/build/" ]; then + find android/${{ env.main_project_module }}/build/ -type d + else + echo "Directory android/${{ env.main_project_module }}/build/ doesn't exist" + fi + + - name: Run Android Tests + id: run_tests + uses: reactivecircus/android-emulator-runner@v2 + with: + api-level: ${{ env.ANDROID_API_LEVEL }} + target: ${{ env.ANDROID_TARGET }} + arch: ${{ matrix.arch }} + profile: ${{ env.ANDROID_PROFILE }} + force-avd-creation: false + emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none -no-snapshot -memory 2048 + disable-animations: true + # TODO: make a PR so this thing can properly take a multiline script call + # too easy to make mistakes with line this long + # super annoying to have to make yet another script to forget to chmod +x on accident + script: ./scripts/wait_for_emulator.sh && ./scripts/run_verify_connected_android_test.sh ${{ matrix.arch }} ${{ env.main_project_module }} ${{ env.ANDROID_EMULATOR_WAIT_TIME_BEFORE_KILL }} + + # Publish integration test results + - name: Publish Integration Test Results + uses: dorny/test-reporter@v2 + if: always() + with: + name: 'Integration Tests' + path: android/app/build/outputs/*.xml,android/app/build/outputs/**/*.xml + reporter: java-junit + fail-on-error: true + + - name: Upload Emulator Log + if: always() + uses: actions/upload-artifact@v4 + with: + name: verify-connected-android-test-emulator-log + path: verify-connected-android-test-emulator.log + retention-days: 90 + + - name: Setup tmate session + if: ${{ failure() }} + uses: mxschmitt/action-tmate@v3 + with: + limit-access-to-actor: true # connected-android-integration-test: # name: Test Android App @@ -636,7 +724,11 @@ jobs: - name: Debug directory structure run: | echo "Directory structure after download:" - find android/${{ env.main_project_module }}/build/ -type d + if [ -d "android/${{ env.main_project_module }}/build/" ]; then + find android/${{ env.main_project_module }}/build/ -type d + else + echo "Directory android/${{ env.main_project_module }}/build/ doesn't exist" + fi - name: Run Android Tests id: run_tests diff --git a/scripts/deprecated_run_android_tests.sh b/scripts/deprecated_run_android_tests.sh index 64f6f0942..18139d7bf 100755 --- a/scripts/deprecated_run_android_tests.sh +++ b/scripts/deprecated_run_android_tests.sh @@ -30,6 +30,6 @@ export BUILD_ARCH=$ARCH ./gradlew -PBUILD_ARCH="$ARCH" \ -PreactNativeArchitectures="$ARCH" \ :"$MAIN_PROJECT_MODULE":connected${ARCH_SUFFIX}DebugAndroidTest \ - --parallel --max-workers=4 --build-cache + --parallel --max-workers=$(nproc) --build-cache echo "Android tests completed successfully!" \ No newline at end of file diff --git a/scripts/run_verify_connected_android_test.sh b/scripts/run_verify_connected_android_test.sh new file mode 100644 index 000000000..7fc56e858 --- /dev/null +++ b/scripts/run_verify_connected_android_test.sh @@ -0,0 +1,36 @@ +#!/bin/bash +set -e + +# Script to run Android tests in CI + +echo "Starting Android tests..." + +# Get the architecture from command line or default to x86_64 +ARCH=${1:-x86_64} +MAIN_PROJECT_MODULE=${2:-app} +ANDROID_EMULATOR_WAIT_TIME_BEFORE_KILL=${3:-5} + +# Determine the build variant suffix based on architecture +if [ "$ARCH" == "arm64-v8a" ]; then + ARCH_SUFFIX="Arm64V8a" +else + ARCH_SUFFIX="X8664" +fi + +echo "Running tests for architecture: $ARCH (using suffix: $ARCH_SUFFIX)" + +# Navigate to the Android directory +cd android + +# Set environment variables +export ANDROID_EMULATOR_WAIT_TIME_BEFORE_KILL=$ANDROID_EMULATOR_WAIT_TIME_BEFORE_KILL +export BUILD_ARCH=$ARCH + +# Run the tests with the appropriate architecture suffix +./gradlew -PBUILD_ARCH="$ARCH" \ + -PreactNativeArchitectures="$ARCH" \ + :"$MAIN_PROJECT_MODULE":connected${ARCH_SUFFIX}DebugAndroidTest \ + -Pandroid.testInstrumentationRunnerArguments.class=com.github.quarck.calnotify.calendarmonitor.ComponentIsolationTest \ + --parallel --max-workers=$(nproc) --build-cache + +echo "Android tests completed successfully!" \ No newline at end of file