Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MOB-7376] hackweek ios browserstack #702

Draft
wants to merge 69 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
808b35f
temp: hard code api-key
jyu115 Dec 5, 2023
8af68fe
updated project schemes
jyu115 Dec 5, 2023
bce9fe2
XCUITestBase class
jyu115 Dec 5, 2023
f732e80
testElementsVisible
jyu115 Dec 5, 2023
b5d03b0
fastlane setup
jyu115 Dec 5, 2023
dea5050
add first test case
jyu115 Dec 6, 2023
d14fad2
install fastlane
jyu115 Dec 6, 2023
5ee9e10
fix test
jyu115 Dec 6, 2023
2fc691f
proj update
jyu115 Dec 6, 2023
259ea71
fastlane browserstack
jyu115 Dec 6, 2023
19f8033
github actions browserstack
jyu115 Dec 6, 2023
2d39cd4
use secrets
jyu115 Dec 6, 2023
dfaf4d7
update iOS profiles
jyu115 Dec 6, 2023
5f03891
use bundle exec
jyu115 Dec 6, 2023
f529387
add allowProvisioningUpdates
jyu115 Dec 6, 2023
e202982
compileBitcode:false
jyu115 Dec 6, 2023
93e3fd7
add ruby version for bundle
jyu115 Dec 6, 2023
496568f
add Gemfile.lock platforms
jyu115 Dec 6, 2023
e93d29f
remove code signing identity
jyu115 Dec 6, 2023
d911a93
fastlane add provisioning profiles
jyu115 Dec 6, 2023
8ae3b83
project set provisioning profiles
jyu115 Dec 6, 2023
000c65a
typo
jyu115 Dec 6, 2023
86ad865
add signing cert
jyu115 Dec 6, 2023
0b73488
try with signing
jyu115 Dec 6, 2023
8ea7f1e
set xcversion
jyu115 Dec 6, 2023
7133ce3
update Gemfile
jyu115 Dec 6, 2023
a170f8c
use xcodes
jyu115 Dec 7, 2023
c2092aa
fastlane profile update
jyu115 Dec 7, 2023
f20d490
remove xcodes
jyu115 Dec 7, 2023
8347f52
add xcodes
jyu115 Dec 7, 2023
892ba51
xcodes github workflow
jyu115 Dec 7, 2023
b05d5b2
refactor fastlane
jyu115 Dec 7, 2023
1990483
add plist
jyu115 Dec 7, 2023
73821e2
fix typo
jyu115 Dec 7, 2023
5b61dcc
update path
jyu115 Dec 7, 2023
04bb063
add extension profile
jyu115 Dec 7, 2023
f48a908
fix paths
jyu115 Dec 7, 2023
2412acd
fix provisioning profiles
jyu115 Dec 7, 2023
e6e9310
cleanup
jyu115 Dec 7, 2023
5614ea7
add missing quote in workflow
jyu115 Dec 7, 2023
83c6a6b
Update ios-browserstack.yml quotes
jyu115 Dec 7, 2023
8856bda
try curl
jyu115 Dec 8, 2023
87da333
try curl
jyu115 Dec 8, 2023
40fe92a
curl and jq
jyu115 Dec 8, 2023
38bdc74
try again
jyu115 Dec 8, 2023
91a741c
try again
jyu115 Dec 8, 2023
50dca17
fix typo
jyu115 Dec 8, 2023
bed7ba8
try again
jyu115 Dec 8, 2023
27bf5c6
add comma
jyu115 Dec 8, 2023
6e68dac
test
jyu115 Dec 8, 2023
9df8091
debugging
jyu115 Dec 8, 2023
70e1542
debugging again
jyu115 Dec 8, 2023
9a39a03
try build sdk
jyu115 Dec 8, 2023
a795c97
destination iOS
jyu115 Dec 8, 2023
0c9d274
make sure use real device
jyu115 Dec 8, 2023
e6f4342
update to real device path
jyu115 Dec 8, 2023
5af5a32
try clean and set sdk
jyu115 Dec 8, 2023
b5dd01d
add debug and allowProvisioningUpdates
jyu115 Dec 8, 2023
66cb25c
add provisioning profile for ui-test target
jyu115 Dec 8, 2023
85946bb
add devices to workflow
jyu115 Dec 8, 2023
f3ac0a1
fix typo
jyu115 Dec 8, 2023
7589a73
try again
jyu115 Dec 8, 2023
15c942d
update browserstack request
jyu115 Dec 8, 2023
5be3c39
add quotes
jyu115 Dec 8, 2023
43e657a
update devices
jyu115 Dec 8, 2023
7c4a9b7
no iOS 17 device due to open bug
jyu115 Dec 8, 2023
59ee806
try again
jyu115 Dec 8, 2023
dfaa05c
add test wait
jyu115 Dec 8, 2023
e19341b
try with increase timeout
jyu115 Dec 8, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 81 additions & 0 deletions .github/workflows/ios-browserstack.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: Build and test iOS Sample App on Browserstack
on: pull_request

jobs:
run-ios-browserstack:
runs-on: macos-latest

steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: "3.2.2"
bundler-cache: true
- run: brew install xcodesorg/made/xcodes
- name: Install the Apple certificate and provisioning profile
env:
BUILD_CERTIFICATE_BASE64: ${{ secrets.BUILD_CERTIFICATE_BASE64 }}
P12_PASSWORD: ${{ secrets.P12_PASSWORD }}
BUILD_PROVISION_PROFILE_BASE64: ${{ secrets.BUILD_PROVISION_PROFILE_BASE64 }}
BUILD_PROVISION_EXTENSION_PROFILE_BASE64: ${{ secrets.BUILD_PROVISION_EXTENSION_PROFILE_BASE64 }}
BUILD_PROVISION_WILDCARD_PROFILE_BASE64: ${{ secrets.BUILD_PROVISION_WILDCARD_PROFILE_BASE64 }}
KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }}
EXPORT_OPTIONS_PLIST: ${{ secrets.EXPORT_OPTIONS_PLIST }}
run: |
# create variables
CERTIFICATE_PATH=$RUNNER_TEMP/build_certificate.p12
PP_1_PATH=$RUNNER_TEMP/build_pp_1.mobileprovision
PP_2_PATH=$RUNNER_TEMP/build_pp_2.mobileprovision
PP_3_PATH=$RUNNER_TEMP/build_pp_3.mobileprovision
KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db

# import certificate and provisioning profile from secrets
echo -n "$BUILD_CERTIFICATE_BASE64" | base64 --decode -o $CERTIFICATE_PATH
echo -n "$BUILD_PROVISION_PROFILE_BASE64" | base64 --decode -o $PP_1_PATH
echo -n "$BUILD_PROVISION_EXTENSION_PROFILE_BASE64" | base64 --decode -o $PP_2_PATH
echo -n "$BUILD_PROVISION_WILDCARD_PROFILE_BASE64" | base64 --decode -o $PP_3_PATH

# create temporary keychain
security create-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
security set-keychain-settings -lut 21600 $KEYCHAIN_PATH
security unlock-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH

# import certificate to keychain
security import $CERTIFICATE_PATH -P "$P12_PASSWORD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH
security list-keychain -d user -s $KEYCHAIN_PATH

# apply provisioning profile
mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
cp $PP_1_PATH ~/Library/MobileDevice/Provisioning\ Profiles
cp $PP_2_PATH ~/Library/MobileDevice/Provisioning\ Profiles
cp $PP_3_PATH ~/Library/MobileDevice/Provisioning\ Profiles

# create plist
EXPORT_OPTS_PATH=$RUNNER_TEMP/ExportOptions.plist
echo -n "$EXPORT_OPTIONS_PLIST" | base64 --decode -o $EXPORT_OPTS_PATH

- name: fastlane build swift-sample-app
run: bundle exec fastlane build_for_browserstack plist:$RUNNER_TEMP/ExportOptions.plist

- name: upload swift-sample-app .ipa to browserstack
id: upload_ipa
run: |
app_url=$(curl -u "${{ secrets.BROWSERSTACK_USERNAME }}:${{ secrets.BROWSERSTACK_ACCESS_KEY }}" \
-X POST "https://api-cloud.browserstack.com/app-automate/xcuitest/v2/app" \
-F "file=@${{ github.workspace }}/build-swift-sample-app/swift-sample-app.ipa" \
-F "custom_id=swift-sample-app" | jq -r '.app_url'); echo "app_url=$app_url" >> $GITHUB_OUTPUT

- name: upload test suite .zip to browserstack
id: upload_test
run: |
test_suite_url=$(curl -u "${{ secrets.BROWSERSTACK_USERNAME}}:${{ secrets.BROWSERSTACK_ACCESS_KEY }}" \
-X POST "https://api-cloud.browserstack.com/app-automate/xcuitest/v2/test-suite" \
-F "file=@${{ github.workspace }}/build-swift-sample-app/swift-sample-app-ui-test.zip" \
-F "custom_id=swift-sample-app-ui-test" | jq -r '.test_suite_url'); echo "test_suite_url=$test_suite_url" >> $GITHUB_OUTPUT

- name: execute test suite on browserstack
run: |
curl -u "${{ secrets.BROWSERSTACK_USERNAME }}:${{ secrets.BROWSERSTACK_ACCESS_KEY }}" \
-X POST "https://api-cloud.browserstack.com/app-automate/xcuitest/v2/build" \
-d '{"devices": ["iPad Air 4-14", "iPhone XS-13", "iPhone 14 Pro Max-16"], "app": "${{ steps.upload_ipa.outputs.app_url }}", "testSuite": "${{ steps.upload_test.outputs.test_suite_url }}"}' \
-H "Content-Type: application/json"
4 changes: 4 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
source "https://rubygems.org"

gem "fastlane"
gem "xcode-install"
220 changes: 220 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,220 @@
GEM
remote: https://rubygems.org/
specs:
CFPropertyList (3.0.6)
rexml
addressable (2.8.5)
public_suffix (>= 2.0.2, < 6.0)
artifactory (3.0.15)
atomos (0.1.3)
aws-eventstream (1.3.0)
aws-partitions (1.863.0)
aws-sdk-core (3.190.0)
aws-eventstream (~> 1, >= 1.3.0)
aws-partitions (~> 1, >= 1.651.0)
aws-sigv4 (~> 1.8)
jmespath (~> 1, >= 1.6.1)
aws-sdk-kms (1.74.0)
aws-sdk-core (~> 3, >= 3.188.0)
aws-sigv4 (~> 1.1)
aws-sdk-s3 (1.141.0)
aws-sdk-core (~> 3, >= 3.189.0)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.8)
aws-sigv4 (1.8.0)
aws-eventstream (~> 1, >= 1.0.2)
babosa (1.0.4)
claide (1.1.0)
colored (1.2)
colored2 (3.1.2)
commander (4.6.0)
highline (~> 2.0.0)
declarative (0.0.20)
digest-crc (0.6.5)
rake (>= 12.0.0, < 14.0.0)
domain_name (0.6.20231109)
dotenv (2.8.1)
emoji_regex (3.2.3)
excon (0.105.0)
faraday (1.10.3)
faraday-em_http (~> 1.0)
faraday-em_synchrony (~> 1.0)
faraday-excon (~> 1.1)
faraday-httpclient (~> 1.0)
faraday-multipart (~> 1.0)
faraday-net_http (~> 1.0)
faraday-net_http_persistent (~> 1.0)
faraday-patron (~> 1.0)
faraday-rack (~> 1.0)
faraday-retry (~> 1.0)
ruby2_keywords (>= 0.0.4)
faraday-cookie_jar (0.0.7)
faraday (>= 0.8.0)
http-cookie (~> 1.0.0)
faraday-em_http (1.0.0)
faraday-em_synchrony (1.0.0)
faraday-excon (1.1.0)
faraday-httpclient (1.0.1)
faraday-multipart (1.0.4)
multipart-post (~> 2)
faraday-net_http (1.0.1)
faraday-net_http_persistent (1.2.0)
faraday-patron (1.0.0)
faraday-rack (1.0.0)
faraday-retry (1.0.3)
faraday_middleware (1.2.0)
faraday (~> 1.0)
fastimage (2.2.7)
fastlane (2.217.0)
CFPropertyList (>= 2.3, < 4.0.0)
addressable (>= 2.8, < 3.0.0)
artifactory (~> 3.0)
aws-sdk-s3 (~> 1.0)
babosa (>= 1.0.3, < 2.0.0)
bundler (>= 1.12.0, < 3.0.0)
colored
commander (~> 4.6)
dotenv (>= 2.1.1, < 3.0.0)
emoji_regex (>= 0.1, < 4.0)
excon (>= 0.71.0, < 1.0.0)
faraday (~> 1.0)
faraday-cookie_jar (~> 0.0.6)
faraday_middleware (~> 1.0)
fastimage (>= 2.1.0, < 3.0.0)
gh_inspector (>= 1.1.2, < 2.0.0)
google-apis-androidpublisher_v3 (~> 0.3)
google-apis-playcustomapp_v1 (~> 0.1)
google-cloud-storage (~> 1.31)
highline (~> 2.0)
http-cookie (~> 1.0.5)
json (< 3.0.0)
jwt (>= 2.1.0, < 3)
mini_magick (>= 4.9.4, < 5.0.0)
multipart-post (>= 2.0.0, < 3.0.0)
naturally (~> 2.2)
optparse (~> 0.1.1)
plist (>= 3.1.0, < 4.0.0)
rubyzip (>= 2.0.0, < 3.0.0)
security (= 0.1.3)
simctl (~> 1.6.3)
terminal-notifier (>= 2.0.0, < 3.0.0)
terminal-table (~> 3)
tty-screen (>= 0.6.3, < 1.0.0)
tty-spinner (>= 0.8.0, < 1.0.0)
word_wrap (~> 1.0.0)
xcodeproj (>= 1.13.0, < 2.0.0)
xcpretty (~> 0.3.0)
xcpretty-travis-formatter (>= 0.0.3)
gh_inspector (1.1.3)
google-apis-androidpublisher_v3 (0.53.0)
google-apis-core (>= 0.11.0, < 2.a)
google-apis-core (0.11.2)
addressable (~> 2.5, >= 2.5.1)
googleauth (>= 0.16.2, < 2.a)
httpclient (>= 2.8.1, < 3.a)
mini_mime (~> 1.0)
representable (~> 3.0)
retriable (>= 2.0, < 4.a)
rexml
webrick
google-apis-iamcredentials_v1 (0.17.0)
google-apis-core (>= 0.11.0, < 2.a)
google-apis-playcustomapp_v1 (0.13.0)
google-apis-core (>= 0.11.0, < 2.a)
google-apis-storage_v1 (0.29.0)
google-apis-core (>= 0.11.0, < 2.a)
google-cloud-core (1.6.1)
google-cloud-env (>= 1.0, < 3.a)
google-cloud-errors (~> 1.0)
google-cloud-env (2.0.1)
faraday (>= 1.0, < 3.a)
google-cloud-errors (1.3.1)
google-cloud-storage (1.45.0)
addressable (~> 2.8)
digest-crc (~> 0.4)
google-apis-iamcredentials_v1 (~> 0.1)
google-apis-storage_v1 (~> 0.29.0)
google-cloud-core (~> 1.6)
googleauth (>= 0.16.2, < 2.a)
mini_mime (~> 1.0)
googleauth (1.8.1)
faraday (>= 0.17.3, < 3.a)
jwt (>= 1.4, < 3.0)
multi_json (~> 1.11)
os (>= 0.9, < 2.0)
signet (>= 0.16, < 2.a)
highline (2.0.3)
http-cookie (1.0.5)
domain_name (~> 0.5)
httpclient (2.8.3)
jmespath (1.6.2)
json (2.7.1)
jwt (2.7.1)
mini_magick (4.12.0)
mini_mime (1.1.5)
multi_json (1.15.0)
multipart-post (2.3.0)
nanaimo (0.3.0)
naturally (2.2.1)
optparse (0.1.1)
os (1.1.4)
plist (3.7.0)
public_suffix (5.0.4)
rake (13.1.0)
representable (3.2.0)
declarative (< 0.1.0)
trailblazer-option (>= 0.1.1, < 0.2.0)
uber (< 0.2.0)
retriable (3.1.2)
rexml (3.2.6)
rouge (2.0.7)
ruby2_keywords (0.0.5)
rubyzip (2.3.2)
security (0.1.3)
signet (0.18.0)
addressable (~> 2.8)
faraday (>= 0.17.5, < 3.a)
jwt (>= 1.5, < 3.0)
multi_json (~> 1.10)
simctl (1.6.10)
CFPropertyList
naturally
terminal-notifier (2.0.0)
terminal-table (3.0.2)
unicode-display_width (>= 1.1.1, < 3)
trailblazer-option (0.1.2)
tty-cursor (0.7.1)
tty-screen (0.8.1)
tty-spinner (0.9.3)
tty-cursor (~> 0.7)
uber (0.1.0)
unicode-display_width (2.5.0)
webrick (1.8.1)
word_wrap (1.0.0)
xcode-install (2.8.1)
claide (>= 0.9.1)
fastlane (>= 2.1.0, < 3.0.0)
xcodeproj (1.23.0)
CFPropertyList (>= 2.3.3, < 4.0)
atomos (~> 0.1.3)
claide (>= 1.0.2, < 2.0)
colored2 (~> 3.1)
nanaimo (~> 0.3.0)
rexml (~> 3.2.4)
xcpretty (0.3.0)
rouge (~> 2.0.7)
xcpretty-travis-formatter (1.0.1)
xcpretty (~> 0.2, >= 0.0.7)

PLATFORMS
arm64-darwin-21
ruby
x86_64-darwin-20
x86_64-linux

DEPENDENCIES
fastlane
xcode-install

BUNDLED WITH
2.4.22
54 changes: 54 additions & 0 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
default_platform(:ios)

platform :ios do
desc "build swift-sample-app .ipa and ui-test.zip for browserstack"
lane :build_for_browserstack do |options|
xcodes(version: "14.2", select_for_current_build_only: true)
ensure_xcode_version(version: "14.2")
build_swift_sample_app(plist:options[:plist])
build_ui_tests
end

desc "build swift-sample-app .ipa"
lane :build_swift_sample_app do |options|
build_app(
project: "sample-apps/swift-sample-app/swift-sample-app.xcodeproj",
configuration: "Debug",
scheme: "swift-sample-app",
silent: true,
clean: true,
sdk: "iphoneos",
destination: "generic/platform=iOS",
output_directory: "./build-swift-sample-app",
output_name: "swift-sample-app.ipa",
export_method: "development",
export_options: {
provisioningProfiles: {
"iterable.swift-sample-app" => "ios-dev-swift-sample-app",
"iterable.swift-sample-app.swift-sample-app-notification-extension" => "ios-dev-swift-sample-app-notification-extension",
}
}
)
end

desc "build swift-sample-app UI tests"
lane :build_ui_tests do
scan(
project: "sample-apps/swift-sample-app/swift-sample-app.xcodeproj",
configuration: "Debug",
scheme: "swift-sample-app",
sdk: "iphoneos",
destination: "generic/platform=iOS",
skip_build: false,
derived_data_path: "./build-swift-sample-app",
build_for_testing: true,
clean: true,
xcargs: "-allowProvisioningUpdates"
)

zip(
path: "./build-swift-sample-app/Build/Products/Debug-iphoneos/SwiftSampleAppUITest-Runner.app",
output_path: "./build-swift-sample-app/swift-sample-app-ui-test.zip"
)
end
end
Loading
Loading