Skip to content

Commit b19f86c

Browse files
Build React Native iOS E2E IPA artifact
Assisted-By: devx/6c1e3ad5-96c8-4972-b087-da7ff7b195c3
1 parent 17f737e commit b19f86c

3 files changed

Lines changed: 204 additions & 9 deletions

File tree

e2e/BITRISE.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,12 @@ 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_IOS_BUNDLE_ID` | `com.shopify.checkoutkit.reactnativedemo` | Bundle identifier used for iOS archive and export signing. |
63+
| `E2E_IOS_DEVELOPMENT_TEAM` | `A7XGC83MZE` | Apple development team used for iOS archive signing. |
64+
| `E2E_IOS_CODE_SIGN_IDENTITY` | `Apple Development` | Code signing identity used for iOS archive and export signing. |
65+
| `E2E_IOS_PROVISIONING_PROFILE_SPECIFIER` | `bitrise-checkout-kit-e2e` | Provisioning profile specifier installed by Bitrise and passed to `xcodebuild`. |
6266
| `E2E_ANDROID_COMMAND_TIMEOUT_SECONDS` | `1800` | Per-command timeout for React Native Android artifact commands. |
67+
| `E2E_IOS_COMMAND_TIMEOUT_SECONDS` | `1800` | Per-command timeout for React Native iOS dependency, CocoaPods, archive, and export commands. |
6368
| `E2E_PACKAGE_COMMAND_TIMEOUT_SECONDS` | `300` | Per-command timeout for package-suite matrix and suite commands. |
6469
| `E2E_RUBY_INSTALL_TIMEOUT_SECONDS` | `1800` | Timeout for installing the exact repository Ruby version from `.ruby-version`. |
6570

@@ -87,7 +92,11 @@ Configure the Bitrise app to run the `e2e` pipeline for pull requests once the s
8792

8893
## Code signing
8994

90-
React Native iOS IPA generation is added in a later phase and will require Bitrise iOS code signing setup for the sample app.
95+
React Native iOS IPA generation uses Bitrise's certificate and profile installer before running `xcodebuild archive` and `xcodebuild -exportArchive`.
96+
97+
The React Native iOS artifact workflow overrides the default Linux stack and runs on `osx-xcode-26.0.x-edge` with `g2.mac.4large`, because it requires Xcode and iOS signing. Its cache keys are prefixed with `rn-ios-macos-` so macOS caches cannot restore Linux-built dependencies.
98+
99+
Upload the required signing certificate and provisioning profile for the React Native sample app to the Bitrise app before running the iOS artifact workflow. The default provisioning profile specifier is `bitrise-checkout-kit-e2e`; update `E2E_IOS_PROVISIONING_PROFILE_SPECIFIER` in `e2e/bitrise.yml` if the Bitrise-installed profile uses a different name.
91100

92101
## Caching
93102

e2e/bitrise.yml

Lines changed: 103 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@ app:
1515
- E2E_BROWSERSTACK_TIMEOUT_SECONDS: "1800"
1616
- E2E_BROWSERSTACK_POLL_SECONDS: "30"
1717
- E2E_IOS_EXPORT_METHOD: development
18+
- E2E_IOS_BUNDLE_ID: com.shopify.checkoutkit.reactnativedemo
19+
- E2E_IOS_DEVELOPMENT_TEAM: A7XGC83MZE
20+
- E2E_IOS_CODE_SIGN_IDENTITY: Apple Development
21+
- E2E_IOS_PROVISIONING_PROFILE_SPECIFIER: bitrise-checkout-kit-e2e
1822
- E2E_ANDROID_COMMAND_TIMEOUT_SECONDS: "1800"
23+
- E2E_IOS_COMMAND_TIMEOUT_SECONDS: "1800"
1924
- E2E_PACKAGE_COMMAND_TIMEOUT_SECONDS: "300"
2025
- E2E_RUBY_INSTALL_TIMEOUT_SECONDS: "1800"
2126

@@ -62,28 +67,121 @@ workflows:
6267
$BITRISE_DEPLOY_DIR/e2e-matrix.json:E2E_MATRIX_JSON
6368
6469
e2e-build-react-native-ios:
70+
meta:
71+
bitrise.io:
72+
stack: osx-xcode-26.0.x-edge
73+
machine_type_id: g2.mac.4large
6574
steps:
6675
- git-clone@8: {}
76+
- certificate-and-profile-installer@1: {}
6777
- restore-cache@1:
6878
inputs:
6979
- key: |-
70-
rn-ios-{{ checksum "platforms/react-native/pnpm-lock.yaml" }}-{{ checksum "platforms/react-native/sample/ios/Podfile.lock" }}
80+
rn-ios-macos-{{ checksum "platforms/react-native/pnpm-lock.yaml" }}-{{ checksum "platforms/react-native/sample/ios/Podfile.lock" }}
7181
- script@1:
72-
title: Create React Native iOS artifact placeholder
82+
title: Build React Native iOS IPA artifact
7383
inputs:
7484
- content: |-
7585
set -euo pipefail
86+
source e2e/scripts/bitrise_ci_helpers
87+
e2e_prepare_ruby
88+
e2e_log "Enabling Corepack"
89+
corepack enable
90+
e2e_log "Checking storefront configuration secrets"
91+
: "${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.}"
92+
: "${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.}"
93+
e2e_log "Configuring storefront environment"
94+
./scripts/setup_storefront_env --skip-optional-prompts
95+
e2e_log "Installing React Native dependencies"
96+
cd platforms/react-native
97+
e2e_run_with_timeout "${E2E_IOS_COMMAND_TIMEOUT_SECONDS:-1800}" pnpm install --frozen-lockfile
98+
cd sample
99+
e2e_log "Installing iOS Ruby dependencies"
100+
e2e_run_with_timeout "${E2E_IOS_COMMAND_TIMEOUT_SECONDS:-1800}" bundle install
101+
cd ios
102+
e2e_log "Installing CocoaPods dependencies"
103+
e2e_run_with_timeout "${E2E_IOS_COMMAND_TIMEOUT_SECONDS:-1800}" bundle exec pod install --deployment --repo-update
76104
mkdir -p "$BITRISE_DEPLOY_DIR/e2e"
77-
echo "Phase 2 placeholder for React Native iOS IPA" > "$BITRISE_DEPLOY_DIR/e2e/react-native-ios.ipa"
78-
envman add --key E2E_REACT_NATIVE_IOS_APP_PATH --value "$BITRISE_DEPLOY_DIR/e2e/react-native-ios.ipa"
105+
archive_path="$BITRISE_DEPLOY_DIR/e2e/CheckoutKitReactNativeDemo.xcarchive"
106+
export_path="$BITRISE_DEPLOY_DIR/e2e/react-native-ios-export"
107+
export_options="$BITRISE_DEPLOY_DIR/e2e/ExportOptions.plist"
108+
export_method="${E2E_IOS_EXPORT_METHOD:-development}"
109+
ios_bundle_id="${E2E_IOS_BUNDLE_ID:-com.shopify.checkoutkit.reactnativedemo}"
110+
ios_development_team="${E2E_IOS_DEVELOPMENT_TEAM:-A7XGC83MZE}"
111+
ios_code_sign_identity="${E2E_IOS_CODE_SIGN_IDENTITY:-Apple Development}"
112+
ios_profile_specifier="${E2E_IOS_PROVISIONING_PROFILE_SPECIFIER:-bitrise-checkout-kit-e2e}"
113+
cat > "$export_options" <<PLIST
114+
<?xml version="1.0" encoding="UTF-8"?>
115+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
116+
<plist version="1.0">
117+
<dict>
118+
<key>method</key>
119+
<string>$export_method</string>
120+
<key>signingStyle</key>
121+
<string>manual</string>
122+
<key>teamID</key>
123+
<string>$ios_development_team</string>
124+
<key>signingCertificate</key>
125+
<string>$ios_code_sign_identity</string>
126+
<key>provisioningProfiles</key>
127+
<dict>
128+
<key>$ios_bundle_id</key>
129+
<string>$ios_profile_specifier</string>
130+
</dict>
131+
<key>stripSwiftSymbols</key>
132+
<true/>
133+
<key>compileBitcode</key>
134+
<false/>
135+
</dict>
136+
</plist>
137+
PLIST
138+
e2e_log "Archiving React Native iOS app"
139+
if ! e2e_run_with_timeout "${E2E_IOS_COMMAND_TIMEOUT_SECONDS:-1800}" xcodebuild archive \
140+
-workspace CheckoutKitReactNativeDemo.xcworkspace \
141+
-scheme CheckoutKitReactNativeDemo \
142+
-configuration Release \
143+
-sdk iphoneos \
144+
-destination generic/platform=iOS \
145+
-archivePath "$archive_path" \
146+
-skipPackagePluginValidation \
147+
"CODE_SIGN_STYLE=Manual" \
148+
"DEVELOPMENT_TEAM=$ios_development_team" \
149+
"CODE_SIGN_IDENTITY=$ios_code_sign_identity" \
150+
"PROVISIONING_PROFILE_SPECIFIER=$ios_profile_specifier"; then
151+
e2e_log "iOS archive failed"
152+
echo "Check Bitrise code signing assets for bundle id ${ios_bundle_id} and team ${ios_development_team}." >&2
153+
echo "Expected provisioning profile specifier: ${ios_profile_specifier}." >&2
154+
echo "Upload an Apple Development certificate and matching development provisioning profile at https://app.bitrise.io/app/f51f9054-053e-40f1-81e9-ae727567ae76/workflow_editor#!/code_signing." >&2
155+
echo "The e2e-build-react-native-ios workflow runs certificate-and-profile-installer before xcodebuild." >&2
156+
exit 1
157+
fi
158+
e2e_log "Exporting React Native iOS IPA"
159+
if ! e2e_run_with_timeout "${E2E_IOS_COMMAND_TIMEOUT_SECONDS:-1800}" xcodebuild -exportArchive \
160+
-archivePath "$archive_path" \
161+
-exportPath "$export_path" \
162+
-exportOptionsPlist "$export_options"; then
163+
e2e_log "iOS IPA export failed"
164+
echo "Check that the installed provisioning profile matches export method ${export_method}." >&2
165+
echo "Export options plist: ${export_options}" >&2
166+
exit 1
167+
fi
168+
ios_ipa="$(find "$export_path" -name "*.ipa" -print -quit)"
169+
if [ -z "$ios_ipa" ] || [ ! -f "$ios_ipa" ]; then
170+
e2e_log "iOS IPA export did not create an IPA"
171+
find "$export_path" -maxdepth 3 -print >&2 || true
172+
exit 1
173+
fi
174+
e2e_log "Publishing iOS IPA path"
175+
envman add --key E2E_REACT_NATIVE_IOS_APP_PATH --value "$ios_ipa"
79176
- deploy-to-bitrise-io@2:
177+
is_always_run: false
80178
inputs:
81179
- pipeline_intermediate_files: |-
82180
$E2E_REACT_NATIVE_IOS_APP_PATH:E2E_REACT_NATIVE_IOS_APP_PATH
83181
- save-cache@1:
84182
inputs:
85183
- key: |-
86-
rn-ios-{{ checksum "platforms/react-native/pnpm-lock.yaml" }}-{{ checksum "platforms/react-native/sample/ios/Podfile.lock" }}
184+
rn-ios-macos-{{ checksum "platforms/react-native/pnpm-lock.yaml" }}-{{ checksum "platforms/react-native/sample/ios/Podfile.lock" }}
87185
- paths: |-
88186
platforms/react-native/node_modules
89187
platforms/react-native/sample/ios/Pods

e2e/test/bitrise_pipeline_test.rb

Lines changed: 91 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@ def test_bitrise_config_defines_non_secret_e2e_defaults
107107
assert_equal "1800", values.fetch("E2E_BROWSERSTACK_TIMEOUT_SECONDS")
108108
assert_equal "30", values.fetch("E2E_BROWSERSTACK_POLL_SECONDS")
109109
assert_equal "development", values.fetch("E2E_IOS_EXPORT_METHOD")
110+
assert_equal "com.shopify.checkoutkit.reactnativedemo", values.fetch("E2E_IOS_BUNDLE_ID")
111+
assert_equal "A7XGC83MZE", values.fetch("E2E_IOS_DEVELOPMENT_TEAM")
112+
assert_equal "Apple Development", values.fetch("E2E_IOS_CODE_SIGN_IDENTITY")
113+
assert_equal "bitrise-checkout-kit-e2e", values.fetch("E2E_IOS_PROVISIONING_PROFILE_SPECIFIER")
110114
assert_equal "300", values.fetch("E2E_PACKAGE_COMMAND_TIMEOUT_SECONDS")
111115
assert_equal "1800", values.fetch("E2E_RUBY_INSTALL_TIMEOUT_SECONDS")
112116
end
@@ -161,6 +165,85 @@ def test_react_native_android_workflow_does_not_use_local_native_sdk_overrides
161165
refute_includes script, "--local"
162166
end
163167

168+
def test_react_native_ios_workflow_uses_macos_xcode_resources
169+
workflow = load_bitrise_config.fetch("workflows").fetch("e2e-build-react-native-ios")
170+
meta = workflow.fetch("meta").fetch("bitrise.io")
171+
172+
assert_equal "osx-xcode-26.0.x-edge", meta.fetch("stack")
173+
assert_equal "g2.mac.4large", meta.fetch("machine_type_id")
174+
end
175+
176+
def test_react_native_ios_workflow_builds_real_ipa_artifact
177+
config = load_bitrise_config
178+
script = workflow_script("e2e-build-react-native-ios")
179+
180+
assert_equal "1800", app_env_values.fetch("E2E_IOS_COMMAND_TIMEOUT_SECONDS")
181+
assert_workflow_has_step(config, "e2e-build-react-native-ios", "certificate-and-profile-installer")
182+
assert_includes script, "source e2e/scripts/bitrise_ci_helpers"
183+
assert_includes script, "e2e_prepare_ruby"
184+
assert_includes script, 'e2e_log "Checking storefront configuration secrets"'
185+
assert_includes script, 'STOREFRONT_DOMAIN is required'
186+
assert_includes script, 'STOREFRONT_ACCESS_TOKEN is required'
187+
assert_includes script, 'workflow_editor#!/secrets'
188+
assert_includes script, 'Expose for pull requests'
189+
assert_includes script, 'e2e_log "Configuring storefront environment"'
190+
assert_includes script, 'e2e_log "Installing React Native dependencies"'
191+
assert_includes script, 'e2e_log "Installing iOS Ruby dependencies"'
192+
assert_includes script, 'e2e_log "Installing CocoaPods dependencies"'
193+
assert_includes script, 'ios_bundle_id="${E2E_IOS_BUNDLE_ID:-com.shopify.checkoutkit.reactnativedemo}"'
194+
assert_includes script, 'ios_development_team="${E2E_IOS_DEVELOPMENT_TEAM:-A7XGC83MZE}"'
195+
assert_includes script, 'ios_code_sign_identity="${E2E_IOS_CODE_SIGN_IDENTITY:-Apple Development}"'
196+
assert_includes script, 'ios_profile_specifier="${E2E_IOS_PROVISIONING_PROFILE_SPECIFIER:-bitrise-checkout-kit-e2e}"'
197+
assert_includes script, '<key>signingStyle</key>'
198+
assert_includes script, '<string>manual</string>'
199+
assert_includes script, '<key>teamID</key>'
200+
assert_includes script, '<string>$ios_development_team</string>'
201+
assert_includes script, '<key>provisioningProfiles</key>'
202+
assert_includes script, '<key>$ios_bundle_id</key>'
203+
assert_includes script, '<string>$ios_profile_specifier</string>'
204+
assert_includes script, 'e2e_log "Archiving React Native iOS app"'
205+
assert_includes script, 'CODE_SIGN_STYLE=Manual'
206+
assert_includes script, 'DEVELOPMENT_TEAM=$ios_development_team'
207+
assert_includes script, 'CODE_SIGN_IDENTITY=$ios_code_sign_identity'
208+
assert_includes script, 'PROVISIONING_PROFILE_SPECIFIER=$ios_profile_specifier'
209+
assert_includes script, 'e2e_log "iOS archive failed"'
210+
assert_includes script, 'com.shopify.checkoutkit.reactnativedemo'
211+
assert_includes script, 'A7XGC83MZE'
212+
assert_includes script, 'workflow_editor#!/code_signing'
213+
assert_includes script, 'certificate-and-profile-installer'
214+
assert_includes script, 'e2e_log "Exporting React Native iOS IPA"'
215+
assert_includes script, 'e2e_log "iOS IPA export failed"'
216+
assert_includes script, 'find "$export_path"'
217+
assert_includes script, 'e2e_log "Publishing iOS IPA path"'
218+
assert_includes script, "corepack enable"
219+
assert_includes script, "cd platforms/react-native"
220+
assert_command_order script, "cd platforms/react-native", "pnpm install --frozen-lockfile"
221+
assert_includes script, "pnpm install --frozen-lockfile"
222+
assert_includes script, "./scripts/setup_storefront_env --skip-optional-prompts"
223+
assert_includes script, 'e2e_run_with_timeout "${E2E_IOS_COMMAND_TIMEOUT_SECONDS:-1800}" pnpm install --frozen-lockfile'
224+
assert_includes script, 'e2e_run_with_timeout "${E2E_IOS_COMMAND_TIMEOUT_SECONDS:-1800}" bundle install'
225+
assert_includes script, 'e2e_run_with_timeout "${E2E_IOS_COMMAND_TIMEOUT_SECONDS:-1800}" bundle exec pod install --deployment --repo-update'
226+
assert_includes script, 'e2e_run_with_timeout "${E2E_IOS_COMMAND_TIMEOUT_SECONDS:-1800}" xcodebuild archive'
227+
assert_includes script, 'e2e_run_with_timeout "${E2E_IOS_COMMAND_TIMEOUT_SECONDS:-1800}" xcodebuild -exportArchive'
228+
assert_includes script, "bundle exec pod install --deployment --repo-update"
229+
assert_includes script, "xcodebuild archive"
230+
assert_includes script, "-sdk iphoneos"
231+
assert_includes script, "generic/platform=iOS"
232+
assert_includes script, "xcodebuild -exportArchive"
233+
assert_includes script, "E2E_REACT_NATIVE_IOS_APP_PATH"
234+
refute_includes script, "Phase 2 placeholder for React Native iOS IPA"
235+
236+
deploy_step = workflow_step(config, "e2e-build-react-native-ios", "deploy-to-bitrise-io")
237+
assert_equal false, deploy_step.fetch("is_always_run")
238+
end
239+
240+
def test_react_native_ios_workflow_does_not_use_local_native_sdk_overrides
241+
script = workflow_script("e2e-build-react-native-ios")
242+
243+
refute_includes script, "USE_LOCAL_SDK"
244+
refute_includes script, "--local"
245+
end
246+
164247
def test_bitrise_setup_docs_exist
165248
assert File.exist?("e2e/BITRISE.md")
166249
end
@@ -204,11 +287,16 @@ def expected_workflows
204287
]
205288
end
206289

207-
def assert_workflow_has_step(config, workflow, step_name)
290+
def workflow_step(config, workflow, step_name)
208291
steps = config.fetch("workflows").fetch(workflow).fetch("steps")
209-
step_names = steps.flat_map(&:keys)
292+
step = steps.find { |candidate| candidate.keys.first.start_with?(step_name) }
210293

211-
assert step_names.any? { |name| name.start_with?(step_name) }, "expected #{workflow} to include #{step_name}"
294+
assert step, "expected #{workflow} to include #{step_name}"
295+
step.values.first
296+
end
297+
298+
def assert_workflow_has_step(config, workflow, step_name)
299+
workflow_step(config, workflow, step_name)
212300
end
213301

214302
def assert_command_order(script, first_command, second_command)

0 commit comments

Comments
 (0)