diff --git a/e2e/BITRISE.md b/e2e/BITRISE.md index 237ea9c12..5cb95b422 100644 --- a/e2e/BITRISE.md +++ b/e2e/BITRISE.md @@ -55,8 +55,19 @@ Each workflow's main `script` step sets its own wall-clock budget with the Bitri The `e2e-execute-browserstack-run` workflow fans out one parallel copy per BrowserStack run plan row. The `e2e-produce-browserstack-run-plan` workflow derives this count with `ruby e2e/scripts/e2e_matrix_to_browserstack_run_plan count` and publishes it as `E2E_BROWSERSTACK_RUN_PLAN_COUNT`, which the `e2e-execute-browserstack-run` `parallel` field reads, so it never needs manual alignment. +## Storefront secrets + +These secrets are configured in Bitrise.io; they cannot live in the repository. `scripts/setup_storefront_env` reads them to configure the sample app before builds. + +| Secret | Purpose | +|---|---| +| `STOREFRONT_DOMAIN` | Storefront domain for sample app builds. | +| `STOREFRONT_ACCESS_TOKEN` | Storefront access token for sample app builds. | + ## Caching +React Native Android E2E builds use the released native Maven artifact versions declared by the React Native sample and module configuration. Do not pass the React Native `--local` flag or set local native SDK override environment variables for these builds. + The pipeline uses Bitrise cache steps for key-based pnpm/CocoaPods/Gradle cache paths. Do not add `activate-build-cache-for-xcode` or `activate-build-cache-for-gradle`; the Bitrise Build Cache add-on is disabled for Shopify Bitrise apps. diff --git a/e2e/bitrise.yml b/e2e/bitrise.yml index 5cc8b1528..765f68ced 100644 --- a/e2e/bitrise.yml +++ b/e2e/bitrise.yml @@ -4,7 +4,7 @@ project_type: other meta: bitrise.io: - stack: ubuntu-noble-24.04-bitrise-2025-android + stack: &android_stack ubuntu-noble-24.04-bitrise-2025-android machine_type_id: g2.linux.medium app: @@ -39,6 +39,27 @@ pipelines: - e2e-execute-browserstack-run should_always_run: workflow +step_bundles: + install-node-modules: + steps: + - restore-cache@3: + inputs: + - key: &rn_node_modules_cache_key |- + rn-node-modules-{{ .OS }}-{{ .Arch }}-{{ checksum "platforms/react-native/pnpm-lock.yaml" }} + - script@1: + title: Install React Native dependencies + inputs: + - content: |- + set -euo pipefail + source e2e/scripts/bitrise_ci_helpers + e2e_enable_corepack + cd platforms/react-native + pnpm install --frozen-lockfile + - save-cache@1: + inputs: + - key: *rn_node_modules_cache_key + - paths: platforms/react-native/node_modules + workflows: e2e-produce-browserstack-run-plan: steps: @@ -99,30 +120,33 @@ workflows: platforms/react-native/sample/ios/Pods e2e-build-react-native-android: + meta: + bitrise.io: + stack: *android_stack + machine_type_id: g2.linux.large steps: - git-clone@8: {} + - bundle::install-node-modules: {} - restore-cache@3: inputs: - - key: |- - rn-android-{{ checksum "platforms/react-native/pnpm-lock.yaml" }}-{{ checksum "platforms/react-native/sample/android/**/*.gradle*" }} + - key: &rn_gradle_cache_key |- + rn-gradle-{{ .OS }}-{{ .Arch }}-{{ checksum "platforms/react-native/sample/android/**/*.gradle*" }} - script@1: - title: Create React Native Android artifact placeholder + title: Build React Native Android APK artifact + timeout: 3600 + no_output_timeout: 3600 inputs: - content: |- set -euo pipefail - mkdir -p "$BITRISE_DEPLOY_DIR/e2e" - echo "Phase 2 placeholder for React Native Android APK" > "$BITRISE_DEPLOY_DIR/e2e/react-native-android.apk" - envman add --key E2E_REACT_NATIVE_ANDROID_APP_PATH --value "$BITRISE_DEPLOY_DIR/e2e/react-native-android.apk" + e2e/scripts/build_react_native_android - deploy-to-bitrise-io@2: inputs: - pipeline_intermediate_files: |- $E2E_REACT_NATIVE_ANDROID_APP_PATH:E2E_REACT_NATIVE_ANDROID_APP_PATH - save-cache@1: inputs: - - key: |- - rn-android-{{ checksum "platforms/react-native/pnpm-lock.yaml" }}-{{ checksum "platforms/react-native/sample/android/**/*.gradle*" }} + - key: *rn_gradle_cache_key - paths: |- - platforms/react-native/node_modules ~/.gradle/caches ~/.gradle/wrapper diff --git a/e2e/scripts/bitrise_ci_helpers b/e2e/scripts/bitrise_ci_helpers index 1586baa8f..337bb953e 100755 --- a/e2e/scripts/bitrise_ci_helpers +++ b/e2e/scripts/bitrise_ci_helpers @@ -5,3 +5,16 @@ set -euo pipefail e2e_log() { printf '\n==> %s\n' "$*" } + +e2e_enable_corepack() { + e2e_log "Enabling Corepack" + corepack enable +} + +e2e_configure_storefront() { + e2e_log "Checking storefront configuration secrets" + : "${STOREFRONT_DOMAIN:?STOREFRONT_DOMAIN is required. Check https://app.bitrise.io/app/f51f9054-053e-40f1-81e9-ae727567ae76/workflow_editor#!/secrets and enable Expose for pull requests.}" + : "${STOREFRONT_ACCESS_TOKEN:?STOREFRONT_ACCESS_TOKEN is required. Check https://app.bitrise.io/app/f51f9054-053e-40f1-81e9-ae727567ae76/workflow_editor#!/secrets and enable Expose for pull requests.}" + e2e_log "Configuring storefront environment" + ./scripts/setup_storefront_env --skip-optional-prompts +} diff --git a/e2e/scripts/build_react_native_android b/e2e/scripts/build_react_native_android new file mode 100755 index 000000000..871e9f38e --- /dev/null +++ b/e2e/scripts/build_react_native_android @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +set -euo pipefail + +script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +source "$script_dir/bitrise_ci_helpers" + +e2e_enable_corepack +e2e_configure_storefront + +e2e_log "Building React Native module" +cd platforms/react-native +pnpm module build + +e2e_log "Building Android E2E APK" +cd sample/android +./gradlew assembleE2e --no-daemon --console=plain -PreactNativeArchitectures=arm64-v8a + +android_apk="$PWD/app/build/outputs/apk/e2e/app-e2e.apk" +test -f "$android_apk" + +e2e_log "Publishing Android APK path" +envman add --key E2E_REACT_NATIVE_ANDROID_APP_PATH --value "$android_apk" diff --git a/platforms/react-native/sample/android/app/build.gradle b/platforms/react-native/sample/android/app/build.gradle index cb7e61f83..ff6bf19fc 100644 --- a/platforms/react-native/sample/android/app/build.gradle +++ b/platforms/react-native/sample/android/app/build.gradle @@ -136,6 +136,12 @@ android { minifyEnabled true proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" } + e2e { + initWith release + matchingFallbacks = ['release'] + signingConfig signingConfigs.debug + minifyEnabled false + } } testOptions { @@ -153,6 +159,18 @@ android { } } +gradle.projectsEvaluated { + if (project.findProperty("newArchEnabled").toString() == "true") { + def codegenTasks = rootProject.subprojects.collect { subproject -> + subproject.tasks.findByName("generateCodegenArtifactsFromSchema") + }.findAll { task -> task != null } + + tasks.matching { task -> task.name.startsWith("configureCMake") }.configureEach { task -> + task.dependsOn(codegenTasks) + } + } +} + def checkoutKitPackageJsonFile = rootProject.file("../../modules/@shopify/checkout-kit-react-native/package.json") def checkoutKitPackageJson = new groovy.json.JsonSlurper().parse(checkoutKitPackageJsonFile) def shopifySdkVersion = checkoutKitPackageJson.checkoutKit?.nativeSdkVersions?.android as String diff --git a/platforms/react-native/sample/android/app/src/main/java/com/shopify/checkoutkit/reactnativedemo/MainApplication.kt b/platforms/react-native/sample/android/app/src/main/java/com/shopify/checkoutkit/reactnativedemo/MainApplication.kt index 3ebe2007e..223c96edc 100644 --- a/platforms/react-native/sample/android/app/src/main/java/com/shopify/checkoutkit/reactnativedemo/MainApplication.kt +++ b/platforms/react-native/sample/android/app/src/main/java/com/shopify/checkoutkit/reactnativedemo/MainApplication.kt @@ -22,6 +22,8 @@ class MainApplication : Application(), ReactApplication { override fun getJSMainModuleName(): String = "index" + override fun getBundleAssetName(): String = "CheckoutKitReactNativeDemo.android.bundle" + override fun getUseDeveloperSupport(): Boolean = BuildConfig.DEBUG override val isHermesEnabled: Boolean = BuildConfig.IS_HERMES_ENABLED