Skip to content

Commit e2d2b87

Browse files
Build React Native Android E2E APK artifact
Assisted-By: devx/6c1e3ad5-96c8-4972-b087-da7ff7b195c3
1 parent 670a50e commit e2d2b87

3 files changed

Lines changed: 65 additions & 4 deletions

File tree

e2e/BITRISE.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,17 @@ The non-secret E2E defaults are defined in `e2e/bitrise.yml` under `app.envs`. D
5757
| `E2E_BROWSERSTACK_TIMEOUT_SECONDS` | `1800` | BrowserStack build timeout. |
5858
| `E2E_BROWSERSTACK_POLL_SECONDS` | `30` | BrowserStack status polling interval. |
5959
| `E2E_IOS_EXPORT_METHOD` | `development` | Export method for the React Native iOS IPA. |
60+
| `E2E_ANDROID_COMMAND_TIMEOUT_SECONDS` | `1800` | Per-command timeout for React Native Android artifact commands. |
6061
| `E2E_PACKAGE_COMMAND_TIMEOUT_SECONDS` | `300` | Per-command timeout for package-suite matrix and suite commands. |
6162
| `E2E_RUBY_INSTALL_TIMEOUT_SECONDS` | `1800` | Timeout for installing the exact repository Ruby version from `.ruby-version`. |
6263

6364
Secrets still need to be configured in Bitrise.io.
6465

66+
| Secret | Purpose |
67+
|---|---|
68+
| `STOREFRONT_DOMAIN` | Required by `scripts/setup_storefront_env` for sample app builds. |
69+
| `STOREFRONT_ACCESS_TOKEN` | Required by `scripts/setup_storefront_env` for sample app builds. |
70+
6571
## Future secrets
6672

6773
Do not add BrowserStack credentials until the BrowserStack integration phase.
@@ -83,6 +89,8 @@ React Native iOS IPA generation is added in a later phase and will require Bitri
8389

8490
## Caching
8591

92+
React Native Android E2E builds use the released native Maven artifact versions declared by the React Native sample and module configuration. Do not set local native SDK override flags for these builds.
93+
8694
The pipeline uses Bitrise cache steps for key-based pnpm/CocoaPods/Gradle cache paths.
8795

8896
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.

e2e/bitrise.yml

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ app:
1414
- E2E_BROWSERSTACK_TIMEOUT_SECONDS: "1800"
1515
- E2E_BROWSERSTACK_POLL_SECONDS: "30"
1616
- E2E_IOS_EXPORT_METHOD: development
17+
- E2E_ANDROID_COMMAND_TIMEOUT_SECONDS: "1800"
1718
- E2E_PACKAGE_COMMAND_TIMEOUT_SECONDS: "300"
1819
- E2E_RUBY_INSTALL_TIMEOUT_SECONDS: "1800"
1920

@@ -94,13 +95,27 @@ workflows:
9495
- key: |-
9596
rn-android-{{ checksum "platforms/react-native/pnpm-lock.yaml" }}-{{ checksum "platforms/react-native/sample/android/**/*.gradle*" }}
9697
- script@1:
97-
title: Create React Native Android artifact placeholder
98+
title: Build React Native Android APK artifact
9899
inputs:
99100
- content: |-
100101
set -euo pipefail
101-
mkdir -p "$BITRISE_DEPLOY_DIR/e2e"
102-
echo "Phase 2 placeholder for React Native Android APK" > "$BITRISE_DEPLOY_DIR/e2e/react-native-android.apk"
103-
envman add --key E2E_REACT_NATIVE_ANDROID_APP_PATH --value "$BITRISE_DEPLOY_DIR/e2e/react-native-android.apk"
102+
source e2e/scripts/bitrise_ci_helpers
103+
e2e_log "Enabling Corepack"
104+
corepack enable
105+
e2e_log "Configuring storefront environment"
106+
./scripts/setup_storefront_env --skip-optional-prompts
107+
e2e_log "Installing React Native dependencies"
108+
cd platforms/react-native
109+
e2e_run_with_timeout "${E2E_ANDROID_COMMAND_TIMEOUT_SECONDS:-1800}" pnpm install --frozen-lockfile
110+
e2e_log "Building React Native module"
111+
e2e_run_with_timeout "${E2E_ANDROID_COMMAND_TIMEOUT_SECONDS:-1800}" pnpm module build
112+
e2e_log "Building Android debug APK"
113+
cd sample/android
114+
e2e_run_with_timeout "${E2E_ANDROID_COMMAND_TIMEOUT_SECONDS:-1800}" ./gradlew assembleDebug --no-daemon --console=plain -PreactNativeArchitectures=arm64-v8a
115+
android_apk="$PWD/app/build/outputs/apk/debug/app-debug.apk"
116+
test -f "$android_apk"
117+
e2e_log "Publishing Android APK path"
118+
envman add --key E2E_REACT_NATIVE_ANDROID_APP_PATH --value "$android_apk"
104119
- deploy-to-bitrise-io@2:
105120
inputs:
106121
- pipeline_intermediate_files: |-

e2e/test/bitrise_pipeline_test.rb

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,35 @@ def test_dev_up_installs_bitrise_cli
113113
assert_includes packages, "bitrise"
114114
end
115115

116+
def test_react_native_android_workflow_builds_real_apk_artifact
117+
script = workflow_script("e2e-build-react-native-android")
118+
119+
assert_equal "1800", app_env_values.fetch("E2E_ANDROID_COMMAND_TIMEOUT_SECONDS")
120+
assert_includes script, 'e2e_log "Configuring storefront environment"'
121+
assert_includes script, 'e2e_log "Installing React Native dependencies"'
122+
assert_includes script, 'e2e_log "Building React Native module"'
123+
assert_includes script, 'e2e_log "Building Android debug APK"'
124+
assert_includes script, 'e2e_log "Publishing Android APK path"'
125+
assert_includes script, "corepack enable"
126+
assert_includes script, "cd platforms/react-native"
127+
assert_command_order script, "cd platforms/react-native", "pnpm install --frozen-lockfile"
128+
assert_includes script, "pnpm install --frozen-lockfile"
129+
assert_includes script, "./scripts/setup_storefront_env --skip-optional-prompts"
130+
assert_includes script, 'e2e_run_with_timeout "${E2E_ANDROID_COMMAND_TIMEOUT_SECONDS:-1800}" pnpm install --frozen-lockfile'
131+
assert_includes script, 'e2e_run_with_timeout "${E2E_ANDROID_COMMAND_TIMEOUT_SECONDS:-1800}" pnpm module build'
132+
assert_includes script, 'e2e_run_with_timeout "${E2E_ANDROID_COMMAND_TIMEOUT_SECONDS:-1800}" ./gradlew assembleDebug --no-daemon --console=plain -PreactNativeArchitectures=arm64-v8a'
133+
assert_includes script, "app/build/outputs/apk/debug/app-debug.apk"
134+
refute_includes script, "Phase 2 placeholder for React Native Android APK"
135+
end
136+
137+
def test_react_native_android_workflow_does_not_use_local_native_sdk_overrides
138+
script = workflow_script("e2e-build-react-native-android")
139+
140+
refute_includes script, "USE_LOCAL_SDK"
141+
refute_includes script, "publish_android_snapshot"
142+
refute_includes script, "--local"
143+
end
144+
116145
def test_bitrise_setup_docs_exist
117146
assert File.exist?("e2e/BITRISE.md")
118147
end
@@ -162,4 +191,13 @@ def assert_workflow_has_step(config, workflow, step_name)
162191

163192
assert step_names.any? { |name| name.start_with?(step_name) }, "expected #{workflow} to include #{step_name}"
164193
end
194+
195+
def assert_command_order(script, first_command, second_command)
196+
first_index = script.index(first_command)
197+
second_index = script.index(second_command)
198+
199+
assert first_index, "expected script to include #{first_command}"
200+
assert second_index, "expected script to include #{second_command}"
201+
assert_operator first_index, :<, second_index, "expected #{first_command} to run before #{second_command}"
202+
end
165203
end

0 commit comments

Comments
 (0)