Skip to content

Commit

Permalink
chore: resolve conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-yangy committed Nov 15, 2024
2 parents 0c40b77 + 3a9ea09 commit d97d336
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 9 deletions.
34 changes: 26 additions & 8 deletions .github/workflows/ui-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ jobs:
with:
targetPlatform: ${{ matrix.targetPlatform }}
projectPath: sample
buildMethod: ${{ matrix.buildMethod }}
customParameters: -logFile logFile.log -quit -batchmode
- name: List build directory
run: ls -R ./
- name: Upload artifact
Expand All @@ -70,9 +72,6 @@ jobs:
- targetPlatform: Android
runs-on: [ self-hosted, macOS ]
test_script: browserstack-sdk pytest -s ./test/test_android.py --browserstack.config "browserstack.android.yml"
- targetPlatform: iOS
runs-on: [ self-hosted, macOS ]
test_script: browserstack-sdk pytest -s ./test/test_ios.py --browserstack.config "browserstack.ios.yml"
concurrency:
group: test-${{ matrix.targetPlatform }}
runs-on: ${{ matrix.runs-on }}
Expand Down Expand Up @@ -110,9 +109,28 @@ jobs:
MAILSLURP_API_KEY: ${{ secrets.MAILSLURP_API_KEY }}
BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }}
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
run: |
pwd
ls -la
cd sample/Tests
./${{ matrix.test_script }}
working-directory: sample/Tests
run: ${{ matrix.test_script }}
test-ios:
name: Run iOS UI tests 🧪
runs-on: [ self-hosted, macOS ]
steps:
- uses: actions/checkout@v3
with:
lfs: true
- name: build iOS app
working-directory: sample
run: ./build_ios.sh
- uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install dependencies
run: pip install -r "sample/Tests/requirements.txt"
- name: Run UI tests
env:
MAILSLURP_API_KEY: ${{ secrets.MAILSLURP_API_KEY }}
BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }}
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
working-directory: sample/Tests
run: browserstack-sdk pytest -s ./test/test_ios.py --browserstack.config "browserstack.ios.yml"

Binary file removed sample/Tests/Payload.ipa
Binary file not shown.
2 changes: 1 addition & 1 deletion sample/Tests/browserstack.ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ source: pytest-browserstack:sample-sdk:v1.0
# Set `app` to define the app that is to be used for testing.
# It can either take the id of any uploaded app or the path of the app directly.
#app: ./WikipediaSample.apk
app: ./Payload.ipa #For running local tests
app: ../build/output/iOS/IPA/Payload.ipa #For running local tests

# =======================================
# Platforms (Browsers / Devices to test)
Expand Down
77 changes: 77 additions & 0 deletions sample/build_ios.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#!/bin/bash

PATH_UNITY="/Applications/Unity/Unity.app/Contents/MacOS/Unity"
PATH_TO_UNITY_SDK_SAMPLE_APP="./"
BUILD_METHOD="MobileBuilder.BuildForAltTester"
APPLE_TEAM_ID=""

# Define the build paths
BUILD_XCODE_PATH="$(pwd)/build/output/iOS/Xcode"
BUILD_ARCHIVE_PATH="$(pwd)/build/output/iOS/Archive"
BUILD_IPA_PATH="$(pwd)/build/output/iOS/IPA"

# Function to clear a directory
clear_directory() {
local dir_path=$1
if [ -d "$dir_path" ]; then
echo "Clearing contents of $dir_path."
rm -rf "$dir_path"/*
else
echo "Directory not found at $dir_path"
fi
}

# Clear all specified directories
clear_directory "$BUILD_XCODE_PATH"
clear_directory "$BUILD_ARCHIVE_PATH"
clear_directory "$BUILD_IPA_PATH"

# Unity build command
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"
echo "Running command: $UNITY_COMMAND"

# Execute the Unity build command
eval "$UNITY_COMMAND"

# Check if the Unity build command was successful
if [ $? -ne 0 ]; then
echo "Unity build failed. Exiting script."
exit 1
fi

# Build and archive project
xcodebuild -project "$(pwd)/build/output/iOS/Xcode/Unity-iPhone.xcodeproj" \
-scheme Unity-iPhone \
-archivePath "$(pwd)/build/output/iOS/Archive/Unity-iPhone.xcarchive" \
-configuration Release \
DEVELOPMENT_TEAM="$APPLE_TEAM_ID" \
CODE_SIGN_STYLE=Automatic \
archive

# Create ExportOptions.plist with the correct APPLE_TEAM_ID
EXPORT_OPTIONS_PATH="$(pwd)/build/output/iOS/Archive/ExportOptions.plist"

cat <<EOF > "$EXPORT_OPTIONS_PATH"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>method</key>
<string>development</string> <!-- Use 'ad-hoc' or 'app-store' as needed -->
<key>teamID</key>
<string>$APPLE_TEAM_ID</string>
<key>signingStyle</key>
<string>automatic</string> <!-- Use automatic signing -->
<key>compileBitcode</key>
<false/>
<key>thinning</key>
<string>&lt;none&gt;</string>
</dict>
</plist>
EOF

# Generate .ipa file
xcodebuild -exportArchive \
-archivePath "$(pwd)/build/output/iOS/Archive/Unity-iPhone.xcarchive" \
-exportPath "$(pwd)/build/output/iOS/IPA" \
-exportOptionsPlist "$EXPORT_OPTIONS_PATH"

0 comments on commit d97d336

Please sign in to comment.