Skip to content

Commit d7a8e44

Browse files
committed
test: update ios test script
1 parent 54e4ccb commit d7a8e44

File tree

3 files changed

+159
-143
lines changed

3 files changed

+159
-143
lines changed

.github/workflows/ui-tests.yml

Lines changed: 102 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ concurrency:
1111
cancel-in-progress: true
1212

1313
jobs:
14-
build:
15-
name: Build ${{ matrix.targetPlatform }} for AltTester 🛠️
16-
runs-on: ubuntu-latest-8-cores
17-
strategy:
18-
fail-fast: false
19-
matrix:
20-
include:
14+
# build:
15+
# name: Build ${{ matrix.targetPlatform }} for AltTester 🛠️
16+
# runs-on: ubuntu-latest-8-cores
17+
# strategy:
18+
# fail-fast: false
19+
# matrix:
20+
# include:
2121
# - targetPlatform: StandaloneOSX
2222
# buildMethod: MacBuilder.BuildForAltTester
2323
# buildPath: sample/Builds/MacOS
@@ -27,115 +27,112 @@ jobs:
2727
# - targetPlatform: Android
2828
# buildMethod: MobileBuilder.BuildForAltTester
2929
# buildPath: sample/Builds/Android
30-
- targetPlatform: iOS
31-
buildMethod: MobileBuilder.BuildForAltTester
32-
buildPath: sample/Builds/iOS
33-
steps:
34-
- uses: actions/checkout@v3
35-
with:
36-
lfs: true
37-
- uses: actions/cache@v3
38-
with:
39-
path: Library
40-
key: Library-${{ matrix.targetPlatform }}-${{ hashFiles('sample/Assets/**', 'sample/Packages/**', 'sample/ProjectSettings/**') }}
41-
restore-keys: |
42-
Library-${{ matrix.targetPlatform }}
43-
Library-
44-
- name: Build project
45-
uses: game-ci/unity-builder@v4
46-
env:
47-
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
48-
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
49-
UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }}
50-
with:
51-
targetPlatform: ${{ matrix.targetPlatform }}
52-
projectPath: sample
53-
buildMethod: ${{ matrix.buildMethod }}
54-
customParameters: -logFile logFile.log -quit -batchmode
55-
- name: List build directory
56-
run: ls -R ./
57-
- name: Upload artifact
58-
uses: actions/upload-artifact@v4
59-
if: always()
60-
with:
61-
name: Build-${{ matrix.targetPlatform }}
62-
path: ${{ matrix.buildPath }}
63-
test:
64-
name: Run ${{ matrix.targetPlatform }} UI tests 🧪
65-
needs: build
66-
strategy:
67-
matrix:
68-
include:
69-
# - targetPlatform: StandaloneOSX
70-
# runs-on: [self-hosted, macOS]
71-
# test_script: pytest -xs test/test_mac.py::MacTest
72-
# - targetPlatform: StandaloneWindows64
73-
# runs-on: [self-hosted, windows]
74-
# test_script: pytest -xs test/test_windows.py::WindowsTest
75-
# - targetPlatform: Android
76-
# runs-on: [ self-hosted, macOS ]
77-
# test_script: browserstack-sdk pytest -s ./test/test_android.py --browserstack.config "browserstack.android.yml"
78-
- targetPlatform: iOS
79-
runs-on: [ self-hosted, macOS ]
80-
test_script: browserstack-sdk pytest -s ./test/test_android.py --browserstack.config "browserstack.android.yml"
81-
concurrency:
82-
group: test-${{ matrix.targetPlatform }}
83-
runs-on: ${{ matrix.runs-on }}
84-
steps:
85-
- uses: actions/checkout@v3
86-
with:
87-
lfs: true
88-
- uses: actions/download-artifact@v4
89-
with:
90-
name: Build-${{ matrix.targetPlatform }}
91-
path: sample/Tests
92-
- name: Make macOS artifact executable
93-
if: ${{ matrix.targetPlatform == 'StandaloneOSX' }}
94-
run: chmod +x sample/Tests/SampleApp.app/Contents/MacOS/*
95-
- uses: actions/setup-python@v4
96-
with:
97-
python-version: "3.10"
98-
- name: Install dependencies (Windows)
99-
if: ${{ matrix.targetPlatform == 'StandaloneWindows64' }}
100-
run: pip install -r "sample/Tests/requirements-desktop.txt"
101-
- name: Install dependencies (Mac)
102-
if: ${{ matrix.targetPlatform != 'StandaloneWindows64' }}
103-
run: |
104-
if [[ "${{ matrix.targetPlatform }}" == "StandaloneOSX" ]]; then
105-
pip uninstall -y browserstack-sdk || true
106-
pip install -r "sample/Tests/requirements-desktop.txt"
107-
else
108-
pip install -r "sample/Tests/requirements-mobile.txt"
109-
fi
110-
- name: Run UI tests
111-
env:
112-
UNITY_APP_PATH: SampleApp.app
113-
UNITY_APP_NAME: SampleApp
114-
MAILSLURP_API_KEY: ${{ secrets.MAILSLURP_API_KEY }}
115-
BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }}
116-
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
117-
working-directory: sample/Tests
118-
run: ${{ matrix.test_script }}
119-
# test-ios:
120-
# name: Run iOS UI tests 🧪
121-
# runs-on: [ self-hosted, macOS ]
30+
# steps:
31+
# - uses: actions/checkout@v3
32+
# with:
33+
# lfs: true
34+
# - uses: actions/cache@v3
35+
# with:
36+
# path: Library
37+
# key: Library-${{ matrix.targetPlatform }}-${{ hashFiles('sample/Assets/**', 'sample/Packages/**', 'sample/ProjectSettings/**') }}
38+
# restore-keys: |
39+
# Library-${{ matrix.targetPlatform }}
40+
# Library-
41+
# - name: Build project
42+
# uses: game-ci/unity-builder@v4
43+
# env:
44+
# UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
45+
# UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
46+
# UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }}
47+
# with:
48+
# targetPlatform: ${{ matrix.targetPlatform }}
49+
# projectPath: sample
50+
# buildMethod: ${{ matrix.buildMethod }}
51+
# customParameters: -logFile logFile.log -quit -batchmode
52+
# - name: List build directory
53+
# run: ls -R ./
54+
# - name: Upload artifact
55+
# uses: actions/upload-artifact@v4
56+
# if: always()
57+
# with:
58+
# name: Build-${{ matrix.targetPlatform }}
59+
# path: ${{ matrix.buildPath }}
60+
# test:
61+
# name: Run ${{ matrix.targetPlatform }} UI tests 🧪
62+
# needs: build
63+
# strategy:
64+
# matrix:
65+
# include:
66+
# # - targetPlatform: StandaloneOSX
67+
# # runs-on: [self-hosted, macOS]
68+
# # test_script: pytest -xs test/test_mac.py::MacTest
69+
# # - targetPlatform: StandaloneWindows64
70+
# # runs-on: [self-hosted, windows]
71+
# # test_script: pytest -xs test/test_windows.py::WindowsTest
72+
# # - targetPlatform: Android
73+
# # runs-on: [ self-hosted, macOS ]
74+
# # test_script: browserstack-sdk pytest -s ./test/test_android.py --browserstack.config "browserstack.android.yml"
75+
# - targetPlatform: iOS
76+
# runs-on: [ self-hosted, macOS ]
77+
# test_script: browserstack-sdk pytest -s ./test/test_android.py --browserstack.config "browserstack.android.yml"
78+
# concurrency:
79+
# group: test-${{ matrix.targetPlatform }}
80+
# runs-on: ${{ matrix.runs-on }}
12281
# steps:
12382
# - uses: actions/checkout@v3
12483
# with:
12584
# lfs: true
126-
# - name: build iOS app
127-
# working-directory: sample
128-
# run: ./build_ios.sh
85+
# - uses: actions/download-artifact@v4
86+
# with:
87+
# name: Build-${{ matrix.targetPlatform }}
88+
# path: sample/Tests
89+
# - name: Make macOS artifact executable
90+
# if: ${{ matrix.targetPlatform == 'StandaloneOSX' }}
91+
# run: chmod +x sample/Tests/SampleApp.app/Contents/MacOS/*
12992
# - uses: actions/setup-python@v4
13093
# with:
13194
# python-version: "3.10"
132-
# - name: Install dependencies
133-
# run: pip install -r "sample/Tests/requirements.txt"
95+
# - name: Install dependencies (Windows)
96+
# if: ${{ matrix.targetPlatform == 'StandaloneWindows64' }}
97+
# run: pip install -r "sample/Tests/requirements-desktop.txt"
98+
# - name: Install dependencies (Mac)
99+
# if: ${{ matrix.targetPlatform != 'StandaloneWindows64' }}
100+
# run: |
101+
# if [[ "${{ matrix.targetPlatform }}" == "StandaloneOSX" ]]; then
102+
# pip uninstall -y browserstack-sdk || true
103+
# pip install -r "sample/Tests/requirements-desktop.txt"
104+
# else
105+
# pip install -r "sample/Tests/requirements-mobile.txt"
106+
# fi
134107
# - name: Run UI tests
135108
# env:
109+
# UNITY_APP_PATH: SampleApp.app
110+
# UNITY_APP_NAME: SampleApp
136111
# MAILSLURP_API_KEY: ${{ secrets.MAILSLURP_API_KEY }}
137112
# BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }}
138113
# BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
139114
# working-directory: sample/Tests
140-
# run: browserstack-sdk pytest -s ./test/test_ios.py --browserstack.config "browserstack.ios.yml"
115+
# run: ${{ matrix.test_script }}
116+
test-ios:
117+
name: Run iOS UI tests 🧪
118+
runs-on: [ self-hosted, macOS ]
119+
steps:
120+
- uses: actions/checkout@v3
121+
with:
122+
lfs: true
123+
- name: build iOS app
124+
working-directory: sample
125+
run: ./build_ios.sh
126+
- uses: actions/setup-python@v4
127+
with:
128+
python-version: "3.10"
129+
- name: Install dependencies
130+
run: pip install -r "sample/Tests/requirements-mobile.txt"
131+
- name: Run UI tests
132+
env:
133+
MAILSLURP_API_KEY: ${{ secrets.MAILSLURP_API_KEY }}
134+
BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }}
135+
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
136+
working-directory: sample/Tests
137+
run: browserstack-sdk pytest -s ./test/test_ios.py --browserstack.config "browserstack.ios.yml"
141138

sample/Tests/test/test_ios.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
from alttester import AltDriver, By
1414

15+
from test import TestConfig
16+
1517
sys.path.insert(0, str(Path(__file__).resolve().parent.parent / 'src'))
1618
from fetch_otp import EMAIL, fetch_code
1719

@@ -26,7 +28,7 @@ def setUpClass(cls):
2628
options = XCUITestOptions()
2729
options.app = "./Payload.ipa"
2830
options.show_xcode_log = True
29-
options.xcode_org_id = "APPLE_TEAM_ID" # Replace with Apple Team ID
31+
options.xcode_org_id = "54XMLXPF98" # Replace with Apple Team ID
3032
options.auto_accept_alerts = True
3133

3234
cls.appium_driver = webdriver.Remote('https://hub-cloud.browserstack.com/wd/hub/', options=options)
@@ -75,14 +77,14 @@ def test_1_pkce_login(self):
7577
# Found email
7678
target_context = context
7779

78-
email_field.send_keys("[email protected]")
80+
email_field.send_keys(TestConfig.EMAIL)
7981
submit_button = driver.find_element(by=AppiumBy.XPATH, value="//form/div/div/div[2]/button")
8082
submit_button.click()
8183

8284
time.sleep(10) # Wait for OTP
8385

8486
code = fetch_gmail_code()
85-
assert code, "Failed to fetch OTP from Gmail"
87+
assert code, "Failed to fetch OTP from MailSlurp"
8688
print(f"Successfully fetched OTP: {code}")
8789

8890
# Unlike on Android, each digit must be entered into a separate input field on iOS.

sample/build_ios.sh

Lines changed: 52 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
PATH_UNITY="/Applications/Unity/Unity.app/Contents/MacOS/Unity"
44
PATH_TO_UNITY_SDK_SAMPLE_APP="./"
55
BUILD_METHOD="MobileBuilder.BuildForAltTester"
6-
APPLE_TEAM_ID=""
6+
APPLE_TEAM_ID="54XMLXPF98"
77

88
# Define the build paths
99
BUILD_XCODE_PATH="$(pwd)/build/output/iOS/Xcode"
@@ -39,39 +39,56 @@ if [ $? -ne 0 ]; then
3939
exit 1
4040
fi
4141

42-
# Build and archive project
43-
xcodebuild -project "$(pwd)/build/output/iOS/Xcode/Unity-iPhone.xcodeproj" \
42+
xcodebuild clean build \
43+
-project "$(pwd)/build/output/iOS/Xcode/Unity-iPhone.xcodeproj" \
4444
-scheme Unity-iPhone \
45-
-archivePath "$(pwd)/build/output/iOS/Archive/Unity-iPhone.xcarchive" \
46-
-configuration Release \
45+
-destination "generic/platform=iOS" \
4746
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"
47+
PRODUCT_BUNDLE_IDENTIFIER=com.immutable.Immutable-Sample-GameSDK \
48+
-allowProvisioningUpdates \
49+
-derivedDataPath "$(pwd)/build/output/iOS/DerivedData"
50+
51+
mkdir -p "$(pwd)/build/output/iOS/IPA/Payload"
52+
53+
mv "$(pwd)/build/output/iOS/DerivedData/Build/Products/ReleaseForRunning-iphoneos/ImmutableSample.app" "$(pwd)/build/output/iOS/IPA/Payload"
54+
55+
zip -r "$(pwd)/build/output/iOS/IPA/Payload.zip" "$(pwd)/build/output/iOS/IPA/Payload"
56+
57+
mv "$(pwd)/build/output/iOS/IPA/Payload.zip" "$(pwd)/Tests/Payload.ipa"
58+
59+
# # Build and archive project
60+
# xcodebuild -project "$(pwd)/build/output/iOS/Xcode/Unity-iPhone.xcodeproj" \
61+
# -scheme Unity-iPhone \
62+
# -archivePath "$(pwd)/build/output/iOS/Archive/Unity-iPhone.xcarchive" \
63+
# -configuration Release \
64+
# DEVELOPMENT_TEAM="$APPLE_TEAM_ID" \
65+
# CODE_SIGN_STYLE=Automatic \
66+
# archive
67+
68+
# # Create ExportOptions.plist with the correct APPLE_TEAM_ID
69+
# EXPORT_OPTIONS_PATH="$(pwd)/build/output/iOS/Archive/ExportOptions.plist"
70+
71+
# cat <<EOF > "$EXPORT_OPTIONS_PATH"
72+
# <?xml version="1.0" encoding="UTF-8"?>
73+
# <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
74+
# <plist version="1.0">
75+
# <dict>
76+
# <key>method</key>
77+
# <string>development</string> <!-- Use 'ad-hoc' or 'app-store' as needed -->
78+
# <key>teamID</key>
79+
# <string>$APPLE_TEAM_ID</string>
80+
# <key>signingStyle</key>
81+
# <string>automatic</string> <!-- Use automatic signing -->
82+
# <key>compileBitcode</key>
83+
# <false/>
84+
# <key>thinning</key>
85+
# <string>&lt;none&gt;</string>
86+
# </dict>
87+
# </plist>
88+
# EOF
89+
90+
# # Generate .ipa file
91+
# xcodebuild -exportArchive \
92+
# -archivePath "$(pwd)/build/output/iOS/Archive/Unity-iPhone.xcarchive" \
93+
# -exportPath "$(pwd)/build/output/iOS/IPA" \
94+
# -exportOptionsPlist "$EXPORT_OPTIONS_PATH"

0 commit comments

Comments
 (0)