From 6c0561f089588f91c29b67f25018a9cfc39745f1 Mon Sep 17 00:00:00 2001 From: Abdurrahman SASTIM Date: Tue, 14 Jan 2025 10:44:18 +0100 Subject: [PATCH 1/2] test: add possibility to target production firebase on Detox tests --- apps/ledger-live-mobile/.env.mock.prerelease | 12 +++++ .../android/app/build.gradle | 6 +++ .../src/detoxPreRelease/google-services.json | 46 +++++++++++++++++++ apps/ledger-live-mobile/detox.config.js | 20 ++++++++ 4 files changed, 84 insertions(+) create mode 100644 apps/ledger-live-mobile/.env.mock.prerelease create mode 100644 apps/ledger-live-mobile/android/app/src/detoxPreRelease/google-services.json diff --git a/apps/ledger-live-mobile/.env.mock.prerelease b/apps/ledger-live-mobile/.env.mock.prerelease new file mode 100644 index 000000000000..28a5d451192f --- /dev/null +++ b/apps/ledger-live-mobile/.env.mock.prerelease @@ -0,0 +1,12 @@ +APP_NAME="LLmock" +MOCK=1 +DETOX=1 +DISABLE_YELLOW_BOX=1 +GOOGLE_SERVICE_INFO_NAME="GoogleService-Info-Production" +FORCE_DEBUG_VISIBLE=1 +BRAZE_ANDROID_API_KEY="be5e1bc8-43f1-4864-b097-076a3c693a43" +BRAZE_IOS_API_KEY="e0a7dfaf-fc30-48f6-b998-01dbebbb73a4" +BRAZE_CUSTOM_ENDPOINT="sdk.fra-02.braze.eu" +FEATURE_FLAGS={"ratingsPrompt":{"enabled":false},"brazePushNotifications":{"enabled":false}} +# Fix random iOS app crash https://github.com/wix/Detox/pull/3135 +SIMCTL_CHILD_NSZombieEnabled=YES \ No newline at end of file diff --git a/apps/ledger-live-mobile/android/app/build.gradle b/apps/ledger-live-mobile/android/app/build.gradle index 6e4839a8d8ec..76c7f682b3ec 100644 --- a/apps/ledger-live-mobile/android/app/build.gradle +++ b/apps/ledger-live-mobile/android/app/build.gradle @@ -9,6 +9,7 @@ project.ext.envConfigFiles = [ release: ".env.android.release", stagingrelease: ".env.android.staging", detox: ".env.mock", + detoxprerelease: ".env.mock.prerelease", ] apply from: project(':react-native-config').projectDir.getPath() + "/dotenv.gradle" @@ -190,6 +191,11 @@ android { applicationIdSuffix ".detox" matchingFallbacks = ['stagingRelease', 'release'] } + detoxPreRelease { + initWith(buildTypes.release) + signingConfig signingConfigs.stagingRelease + matchingFallbacks = ['release'] + } } } diff --git a/apps/ledger-live-mobile/android/app/src/detoxPreRelease/google-services.json b/apps/ledger-live-mobile/android/app/src/detoxPreRelease/google-services.json new file mode 100644 index 000000000000..2f4c5126c7e1 --- /dev/null +++ b/apps/ledger-live-mobile/android/app/src/detoxPreRelease/google-services.json @@ -0,0 +1,46 @@ +{ + "project_info": { + "project_number": "212042068804", + "project_id": "ledger-live-production", + "storage_bucket": "ledger-live-production.appspot.com" + }, + "client": [ + { + "client_info": { + "mobilesdk_app_id": "1:212042068804:android:cdf1f537910a5066b51d11", + "android_client_info": { + "package_name": "com.ledger.live" + } + }, + "oauth_client": [ + { + "client_id": "212042068804-drh6m4ulmedj9kd0q6337avsuuhhchmg.apps.googleusercontent.com", + "client_type": 3 + } + ], + "api_key": [ + { + "current_key": "AIzaSyCe9QrkYnsxCfnBilRFxnpC-uqgoF5IIyA" + } + ], + "services": { + "appinvite_service": { + "other_platform_oauth_client": [ + { + "client_id": "212042068804-drh6m4ulmedj9kd0q6337avsuuhhchmg.apps.googleusercontent.com", + "client_type": 3 + }, + { + "client_id": "212042068804-n7rglq1e800k8fo9urt70etkbh2tia8l.apps.googleusercontent.com", + "client_type": 2, + "ios_info": { + "bundle_id": "ledgerlivemobile" + } + } + ] + } + } + } + ], + "configuration_version": "1" +} diff --git a/apps/ledger-live-mobile/detox.config.js b/apps/ledger-live-mobile/detox.config.js index 26576e94bd51..9e171eeb916e 100644 --- a/apps/ledger-live-mobile/detox.config.js +++ b/apps/ledger-live-mobile/detox.config.js @@ -44,6 +44,11 @@ module.exports = { build: `export ENVFILE=.env.mock && xcodebuild ARCHS=${iosArch} ONLY_ACTIVE_ARCH=YES -workspace ios/ledgerlivemobile.xcworkspace -scheme ledgerlivemobile -configuration Release -sdk iphonesimulator -derivedDataPath ios/build`, binaryPath: "ios/build/Build/Products/Release-iphonesimulator/ledgerlivemobile.app", }, + "ios.prerelease": { + type: "ios.app", + build: `export ENVFILE=.env.mock.prerelease && xcodebuild ARCHS=${iosArch} ONLY_ACTIVE_ARCH=YES -workspace ios/ledgerlivemobile.xcworkspace -scheme ledgerlivemobile -configuration Release -sdk iphonesimulator -derivedDataPath ios/build`, + binaryPath: "ios/build/Build/Products/Release-iphonesimulator/ledgerlivemobile.app", + }, "android.debug": { type: "android.apk", build: `cd android && ENVFILE=.env.mock ./gradlew app:assembleDebug app:assembleAndroidTest -DtestBuildType=debug -PreactNativeArchitectures=${androidArch} && cd ..`, @@ -56,6 +61,13 @@ module.exports = { binaryPath: `android/app/build/outputs/apk/detox/app-${androidArch}-detox.apk`, testBinaryPath: "android/app/build/outputs/apk/androidTest/detox/app-detox-androidTest.apk", }, + "android.prerelease": { + type: "android.apk", + build: `cd android && ENVFILE=.env.mock.prerelease ./gradlew app:assembleDetoxPreRelease app:assembleAndroidTest -DtestBuildType=detoxPreRelease -PreactNativeArchitectures=${androidArch} && cd ..`, + binaryPath: `android/app/build/outputs/apk/detoxPreRelease/app-${androidArch}-detoxPreRelease.apk`, + testBinaryPath: + "android/app/build/outputs/apk/androidTest/detoxPreRelease/app-detoxPreRelease-androidTest.apk", + }, }, devices: { simulator: { @@ -87,6 +99,10 @@ module.exports = { device: "simulator", app: "ios.release", }, + "ios.sim.prerelease": { + device: "simulator", + app: "ios.prerelease", + }, "android.emu.debug": { device: "emulator", app: "android.debug", @@ -95,5 +111,9 @@ module.exports = { device: "emulator", app: "android.release", }, + "android.emu.prerelease": { + device: "emulator", + app: "android.prerelease", + }, }, }; From 89070b1135b5fd0d7cdd8962d32005d3dac88fef Mon Sep 17 00:00:00 2001 From: Abdurrahman SASTIM Date: Tue, 14 Jan 2025 10:45:18 +0100 Subject: [PATCH 2/2] ci: add possibility to launch test targeting production firebase --- .github/workflows/test-mobile-e2e-reusable.yml | 12 ++++++++++-- .github/workflows/test-mobile-e2e.yml | 5 +++++ apps/ledger-live-mobile/scripts/e2e-ci.mjs | 10 +++++++--- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test-mobile-e2e-reusable.yml b/.github/workflows/test-mobile-e2e-reusable.yml index c78a2a0c6545..1a825bfe046c 100644 --- a/.github/workflows/test-mobile-e2e-reusable.yml +++ b/.github/workflows/test-mobile-e2e-reusable.yml @@ -49,6 +49,11 @@ on: required: false type: boolean default: false + production_firebase: + description: "Target Production Firebase environment" + required: false + type: boolean + default: false # Uncomment to have log-level: trace on detox run and build # (cf: apps/ledger-live-mobile/detox.config.js) @@ -266,7 +271,9 @@ jobs: shell: bash - name: Build Android app for Detox test run run: | - pnpm mobile e2e:ci -p android -b + pnpm mobile e2e:ci -p android -b $([[ "$PRODUCTION" == "true" ]] && printf %s '--production') + env: + PRODUCTION: ${{ inputs.production_firebase }} - name: cache android emulator timeout-minutes: 5 uses: tespkg/actions-cache@v1 @@ -316,12 +323,13 @@ jobs: schedule_cron: ${{ github.event.schedule.cron }} - name: Run Android Tests id: detox - run: pnpm mobile e2e:ci -p android -t $([[ "$INPUT_SPECULOS" == "true" ]] && printf %s '--speculos') --shard ${{ matrix.shardIndex }}/${{ matrix.shardTotal }} + run: pnpm mobile e2e:ci -p android -t $([[ "$INPUT_SPECULOS" == "true" ]] && printf %s '--speculos') $([[ "$PRODUCTION" == "true" ]] && printf %s '--production') --shard ${{ matrix.shardIndex }}/${{ matrix.shardTotal }} timeout-minutes: ${{ env.SPECULOS_RUN && 120 || 45 }} env: DETOX_INSTALL_TIMEOUT: 120000 SEED: ${{ secrets.SEED_QAA_B2C }} INPUT_SPECULOS: ${{ env.SPECULOS_RUN }} + PRODUCTION: ${{ inputs.production_firebase }} - name: Upload test artifacts uses: actions/upload-artifact@v4 if: ${{ !cancelled() || steps.detox.outcome == 'cancelled' }} diff --git a/.github/workflows/test-mobile-e2e.yml b/.github/workflows/test-mobile-e2e.yml index 48bb732715a5..e4ad964f0744 100644 --- a/.github/workflows/test-mobile-e2e.yml +++ b/.github/workflows/test-mobile-e2e.yml @@ -43,6 +43,11 @@ on: required: false type: boolean default: false + production_firebase: + description: "Target Production Firebase environment" + required: false + type: boolean + default: false # Uncomment to have log-level: trace on detox run and build # (cf: apps/ledger-live-mobile/detox.config.js) diff --git a/apps/ledger-live-mobile/scripts/e2e-ci.mjs b/apps/ledger-live-mobile/scripts/e2e-ci.mjs index 01071b0b4a6a..39412d4d9ca4 100755 --- a/apps/ledger-live-mobile/scripts/e2e-ci.mjs +++ b/apps/ledger-live-mobile/scripts/e2e-ci.mjs @@ -5,12 +5,13 @@ let platform, test, build, bundle; let speculos = ""; let cache = true; let shard = ""; +let target = "release"; const usage = (exitCode = 1) => { console.log( `Usage: ${basename( __filename, - )} -p --platform [-h --help] [-t --test] [-b --build] [--bundle] [--cache | --no-cache] [--speculos] [--shard]`, + )} -p --platform [-h --help] [-t --test] [-b --build] [--bundle] [--cache | --no-cache] [--speculos] [--shard] [--production]`, ); process.exit(exitCode); }; @@ -51,12 +52,12 @@ const test_ios = async () => { }; const build_android = async () => { - await $`pnpm mobile e2e:build -c android.emu.release`; + await $`pnpm mobile e2e:build -c android.emu.${target}`; }; const test_android = async () => { await $`pnpm mobile e2e:test${speculos} \\ - -c android.emu.release \\ + -c android.emu.${target} \\ --loglevel error \\ --record-logs all \\ --take-screenshots all \\ @@ -117,6 +118,9 @@ for (const argName in argv) { case "shard": shard = argv[argName]; break; + case "production": + target = "prerelease"; + break; default: usage(42); break;