Skip to content

Commit d97d336

Browse files
committed
chore: resolve conflicts
2 parents 0c40b77 + 3a9ea09 commit d97d336

File tree

4 files changed

+104
-9
lines changed

4 files changed

+104
-9
lines changed

.github/workflows/ui-tests.yml

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ jobs:
4747
with:
4848
targetPlatform: ${{ matrix.targetPlatform }}
4949
projectPath: sample
50+
buildMethod: ${{ matrix.buildMethod }}
51+
customParameters: -logFile logFile.log -quit -batchmode
5052
- name: List build directory
5153
run: ls -R ./
5254
- name: Upload artifact
@@ -70,9 +72,6 @@ jobs:
7072
- targetPlatform: Android
7173
runs-on: [ self-hosted, macOS ]
7274
test_script: browserstack-sdk pytest -s ./test/test_android.py --browserstack.config "browserstack.android.yml"
73-
- targetPlatform: iOS
74-
runs-on: [ self-hosted, macOS ]
75-
test_script: browserstack-sdk pytest -s ./test/test_ios.py --browserstack.config "browserstack.ios.yml"
7675
concurrency:
7776
group: test-${{ matrix.targetPlatform }}
7877
runs-on: ${{ matrix.runs-on }}
@@ -110,9 +109,28 @@ jobs:
110109
MAILSLURP_API_KEY: ${{ secrets.MAILSLURP_API_KEY }}
111110
BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }}
112111
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
113-
run: |
114-
pwd
115-
ls -la
116-
cd sample/Tests
117-
./${{ matrix.test_script }}
112+
working-directory: sample/Tests
113+
run: ${{ matrix.test_script }}
114+
test-ios:
115+
name: Run iOS UI tests 🧪
116+
runs-on: [ self-hosted, macOS ]
117+
steps:
118+
- uses: actions/checkout@v3
119+
with:
120+
lfs: true
121+
- name: build iOS app
122+
working-directory: sample
123+
run: ./build_ios.sh
124+
- uses: actions/setup-python@v4
125+
with:
126+
python-version: "3.10"
127+
- name: Install dependencies
128+
run: pip install -r "sample/Tests/requirements.txt"
129+
- name: Run UI tests
130+
env:
131+
MAILSLURP_API_KEY: ${{ secrets.MAILSLURP_API_KEY }}
132+
BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }}
133+
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
134+
working-directory: sample/Tests
135+
run: browserstack-sdk pytest -s ./test/test_ios.py --browserstack.config "browserstack.ios.yml"
118136

sample/Tests/Payload.ipa

-34.5 MB
Binary file not shown.

sample/Tests/browserstack.ios.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ source: pytest-browserstack:sample-sdk:v1.0
2626
# Set `app` to define the app that is to be used for testing.
2727
# It can either take the id of any uploaded app or the path of the app directly.
2828
#app: ./WikipediaSample.apk
29-
app: ./Payload.ipa #For running local tests
29+
app: ../build/output/iOS/IPA/Payload.ipa #For running local tests
3030

3131
# =======================================
3232
# Platforms (Browsers / Devices to test)

sample/build_ios.sh

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#!/bin/bash
2+
3+
PATH_UNITY="/Applications/Unity/Unity.app/Contents/MacOS/Unity"
4+
PATH_TO_UNITY_SDK_SAMPLE_APP="./"
5+
BUILD_METHOD="MobileBuilder.BuildForAltTester"
6+
APPLE_TEAM_ID=""
7+
8+
# Define the build paths
9+
BUILD_XCODE_PATH="$(pwd)/build/output/iOS/Xcode"
10+
BUILD_ARCHIVE_PATH="$(pwd)/build/output/iOS/Archive"
11+
BUILD_IPA_PATH="$(pwd)/build/output/iOS/IPA"
12+
13+
# Function to clear a directory
14+
clear_directory() {
15+
local dir_path=$1
16+
if [ -d "$dir_path" ]; then
17+
echo "Clearing contents of $dir_path."
18+
rm -rf "$dir_path"/*
19+
else
20+
echo "Directory not found at $dir_path"
21+
fi
22+
}
23+
24+
# Clear all specified directories
25+
clear_directory "$BUILD_XCODE_PATH"
26+
clear_directory "$BUILD_ARCHIVE_PATH"
27+
clear_directory "$BUILD_IPA_PATH"
28+
29+
# Unity build command
30+
UNITY_COMMAND="$PATH_UNITY -projectPath \"$PATH_TO_UNITY_SDK_SAMPLE_APP\" -executeMethod $BUILD_METHOD -logFile logFile.log -quit -batchmode --buildPath \"$BUILD_XCODE_PATH\" --platform iOS"
31+
echo "Running command: $UNITY_COMMAND"
32+
33+
# Execute the Unity build command
34+
eval "$UNITY_COMMAND"
35+
36+
# Check if the Unity build command was successful
37+
if [ $? -ne 0 ]; then
38+
echo "Unity build failed. Exiting script."
39+
exit 1
40+
fi
41+
42+
# Build and archive project
43+
xcodebuild -project "$(pwd)/build/output/iOS/Xcode/Unity-iPhone.xcodeproj" \
44+
-scheme Unity-iPhone \
45+
-archivePath "$(pwd)/build/output/iOS/Archive/Unity-iPhone.xcarchive" \
46+
-configuration Release \
47+
DEVELOPMENT_TEAM="$APPLE_TEAM_ID" \
48+
CODE_SIGN_STYLE=Automatic \
49+
archive
50+
51+
# Create ExportOptions.plist with the correct APPLE_TEAM_ID
52+
EXPORT_OPTIONS_PATH="$(pwd)/build/output/iOS/Archive/ExportOptions.plist"
53+
54+
cat <<EOF > "$EXPORT_OPTIONS_PATH"
55+
<?xml version="1.0" encoding="UTF-8"?>
56+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
57+
<plist version="1.0">
58+
<dict>
59+
<key>method</key>
60+
<string>development</string> <!-- Use 'ad-hoc' or 'app-store' as needed -->
61+
<key>teamID</key>
62+
<string>$APPLE_TEAM_ID</string>
63+
<key>signingStyle</key>
64+
<string>automatic</string> <!-- Use automatic signing -->
65+
<key>compileBitcode</key>
66+
<false/>
67+
<key>thinning</key>
68+
<string>&lt;none&gt;</string>
69+
</dict>
70+
</plist>
71+
EOF
72+
73+
# Generate .ipa file
74+
xcodebuild -exportArchive \
75+
-archivePath "$(pwd)/build/output/iOS/Archive/Unity-iPhone.xcarchive" \
76+
-exportPath "$(pwd)/build/output/iOS/IPA" \
77+
-exportOptionsPlist "$EXPORT_OPTIONS_PATH"

0 commit comments

Comments
 (0)