Skip to content

Commit e5a9bbe

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

3 files changed

Lines changed: 83 additions & 6 deletions

File tree

e2e/BITRISE.md

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

6566
Secrets still need to be configured in Bitrise.io.
6667

68+
| Secret | Purpose |
69+
|---|---|
70+
| `STOREFRONT_DOMAIN` | Required by `scripts/setup_storefront_env` for sample app builds. |
71+
| `STOREFRONT_ACCESS_TOKEN` | Required by `scripts/setup_storefront_env` for sample app builds. |
72+
6773
## Future secrets
6874

6975
Do not add BrowserStack credentials until the BrowserStack integration phase.
@@ -85,6 +91,10 @@ React Native iOS IPA generation is added in a later phase and will require Bitri
8591

8692
## Caching
8793

94+
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.
95+
96+
React Native Android E2E builds run on `linux-docker-android-22.04` with `g2.linux.large`. Their cache keys are prefixed with `rn-android-linux-` so Linux caches cannot restore macOS-built dependencies.
97+
8898
The pipeline uses Bitrise cache steps for key-based pnpm/CocoaPods/Gradle cache paths.
8999

90100
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: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ app:
1515
- E2E_BROWSERSTACK_TIMEOUT_SECONDS: "1800"
1616
- E2E_BROWSERSTACK_POLL_SECONDS: "30"
1717
- E2E_IOS_EXPORT_METHOD: development
18+
- E2E_ANDROID_COMMAND_TIMEOUT_SECONDS: "1800"
1819
- E2E_PACKAGE_COMMAND_TIMEOUT_SECONDS: "300"
1920
- E2E_RUBY_INSTALL_TIMEOUT_SECONDS: "1800"
2021

@@ -88,28 +89,46 @@ workflows:
8889
platforms/react-native/sample/ios/Pods
8990
9091
e2e-build-react-native-android:
92+
meta:
93+
bitrise.io:
94+
stack: linux-docker-android-22.04
95+
machine_type_id: g2.linux.large
9196
steps:
9297
- git-clone@8: {}
9398
- restore-cache@1:
9499
inputs:
95100
- key: |-
96-
rn-android-{{ checksum "platforms/react-native/pnpm-lock.yaml" }}-{{ checksum "platforms/react-native/sample/android/**/*.gradle*" }}
101+
rn-android-linux-{{ checksum "platforms/react-native/pnpm-lock.yaml" }}-{{ checksum "platforms/react-native/sample/android/**/*.gradle*" }}
97102
- script@1:
98-
title: Create React Native Android artifact placeholder
103+
title: Build React Native Android APK artifact
99104
inputs:
100105
- content: |-
101106
set -euo pipefail
102-
mkdir -p "$BITRISE_DEPLOY_DIR/e2e"
103-
echo "Phase 2 placeholder for React Native Android APK" > "$BITRISE_DEPLOY_DIR/e2e/react-native-android.apk"
104-
envman add --key E2E_REACT_NATIVE_ANDROID_APP_PATH --value "$BITRISE_DEPLOY_DIR/e2e/react-native-android.apk"
107+
source e2e/scripts/bitrise_ci_helpers
108+
e2e_log "Enabling Corepack"
109+
corepack enable
110+
e2e_log "Configuring storefront environment"
111+
./scripts/setup_storefront_env --skip-optional-prompts
112+
e2e_log "Installing React Native dependencies"
113+
cd platforms/react-native
114+
e2e_run_with_timeout "${E2E_ANDROID_COMMAND_TIMEOUT_SECONDS:-1800}" pnpm install --frozen-lockfile
115+
e2e_log "Building React Native module"
116+
e2e_run_with_timeout "${E2E_ANDROID_COMMAND_TIMEOUT_SECONDS:-1800}" pnpm module build
117+
e2e_log "Building Android debug APK"
118+
cd sample/android
119+
e2e_run_with_timeout "${E2E_ANDROID_COMMAND_TIMEOUT_SECONDS:-1800}" ./gradlew assembleDebug --no-daemon --console=plain -PreactNativeArchitectures=arm64-v8a
120+
android_apk="$PWD/app/build/outputs/apk/debug/app-debug.apk"
121+
test -f "$android_apk"
122+
e2e_log "Publishing Android APK path"
123+
envman add --key E2E_REACT_NATIVE_ANDROID_APP_PATH --value "$android_apk"
105124
- deploy-to-bitrise-io@2:
106125
inputs:
107126
- pipeline_intermediate_files: |-
108127
$E2E_REACT_NATIVE_ANDROID_APP_PATH:E2E_REACT_NATIVE_ANDROID_APP_PATH
109128
- save-cache@1:
110129
inputs:
111130
- key: |-
112-
rn-android-{{ checksum "platforms/react-native/pnpm-lock.yaml" }}-{{ checksum "platforms/react-native/sample/android/**/*.gradle*" }}
131+
rn-android-linux-{{ checksum "platforms/react-native/pnpm-lock.yaml" }}-{{ checksum "platforms/react-native/sample/android/**/*.gradle*" }}
113132
- paths: |-
114133
platforms/react-native/node_modules
115134
~/.gradle/caches

e2e/test/bitrise_pipeline_test.rb

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,45 @@ def test_dev_up_installs_bitrise_cli
117117
assert_includes packages, "bitrise"
118118
end
119119

120+
def test_react_native_android_workflow_uses_linux_resources
121+
workflow = load_bitrise_config.fetch("workflows").fetch("e2e-build-react-native-android")
122+
meta = workflow.fetch("meta").fetch("bitrise.io")
123+
cache_keys = workflow.fetch("steps").flat_map { |step| step.values.first.fetch("inputs", []) }.filter_map { |input| input["key"] }
124+
125+
assert_equal "linux-docker-android-22.04", meta.fetch("stack")
126+
assert_equal "g2.linux.large", meta.fetch("machine_type_id")
127+
assert cache_keys.all? { |key| key.start_with?("rn-android-linux-") }
128+
end
129+
130+
def test_react_native_android_workflow_builds_real_apk_artifact
131+
script = workflow_script("e2e-build-react-native-android")
132+
133+
assert_equal "1800", app_env_values.fetch("E2E_ANDROID_COMMAND_TIMEOUT_SECONDS")
134+
assert_includes script, 'e2e_log "Configuring storefront environment"'
135+
assert_includes script, 'e2e_log "Installing React Native dependencies"'
136+
assert_includes script, 'e2e_log "Building React Native module"'
137+
assert_includes script, 'e2e_log "Building Android debug APK"'
138+
assert_includes script, 'e2e_log "Publishing Android APK path"'
139+
assert_includes script, "corepack enable"
140+
assert_includes script, "cd platforms/react-native"
141+
assert_command_order script, "cd platforms/react-native", "pnpm install --frozen-lockfile"
142+
assert_includes script, "pnpm install --frozen-lockfile"
143+
assert_includes script, "./scripts/setup_storefront_env --skip-optional-prompts"
144+
assert_includes script, 'e2e_run_with_timeout "${E2E_ANDROID_COMMAND_TIMEOUT_SECONDS:-1800}" pnpm install --frozen-lockfile'
145+
assert_includes script, 'e2e_run_with_timeout "${E2E_ANDROID_COMMAND_TIMEOUT_SECONDS:-1800}" pnpm module build'
146+
assert_includes script, 'e2e_run_with_timeout "${E2E_ANDROID_COMMAND_TIMEOUT_SECONDS:-1800}" ./gradlew assembleDebug --no-daemon --console=plain -PreactNativeArchitectures=arm64-v8a'
147+
assert_includes script, "app/build/outputs/apk/debug/app-debug.apk"
148+
refute_includes script, "Phase 2 placeholder for React Native Android APK"
149+
end
150+
151+
def test_react_native_android_workflow_does_not_use_local_native_sdk_overrides
152+
script = workflow_script("e2e-build-react-native-android")
153+
154+
refute_includes script, "USE_LOCAL_SDK"
155+
refute_includes script, "publish_android_snapshot"
156+
refute_includes script, "--local"
157+
end
158+
120159
def test_bitrise_setup_docs_exist
121160
assert File.exist?("e2e/BITRISE.md")
122161
end
@@ -166,4 +205,13 @@ def assert_workflow_has_step(config, workflow, step_name)
166205

167206
assert step_names.any? { |name| name.start_with?(step_name) }, "expected #{workflow} to include #{step_name}"
168207
end
208+
209+
def assert_command_order(script, first_command, second_command)
210+
first_index = script.index(first_command)
211+
second_index = script.index(second_command)
212+
213+
assert first_index, "expected script to include #{first_command}"
214+
assert second_index, "expected script to include #{second_command}"
215+
assert_operator first_index, :<, second_index, "expected #{first_command} to run before #{second_command}"
216+
end
169217
end

0 commit comments

Comments
 (0)