Skip to content

UI Tests 🧪

UI Tests 🧪 #854

Workflow file for this run

---
name: UI Tests 🧪
on:
workflow_dispatch:
inputs:
targetPlatform:
description: "Select the platform to build and test"
required: true
default: "All"
type: choice
options:
- All
- StandaloneOSX # Builds Unity 2021 macOS only
- StandaloneOSX-Unity6 # Builds Unity 6 macOS only
- StandaloneWindows64
- Android
- iOS
push:
branches: [main]
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
name: Build ${{ matrix.targetPlatform }} for AltTester 🛠️
runs-on: ubuntu-latest-8-cores
strategy:
fail-fast: false
matrix:
include:
# Unity 2021 macOS build
- targetPlatform: StandaloneOSX
buildMethod: MacBuilder.BuildForAltTester
buildPath: sample/Builds/MacOS
projectPath: sample
unityVersion: 2021.3.26f1
# Unity 6 macOS build (also triggered when StandaloneOSX is selected)
- targetPlatform: StandaloneOSX-Unity6
buildMethod: MacBuilderUnity6.BuildForAltTester
buildPath: sample-unity6/Builds/MacOS
projectPath: sample-unity6
unityVersion: 6000.0.58f1
- targetPlatform: StandaloneWindows64
buildMethod: WindowsBuilder.BuildForAltTester
buildPath: sample/Builds/Windows64
projectPath: sample
unityVersion: 2021.3.26f1
- targetPlatform: Android
buildMethod: MobileBuilder.BuildForAltTester
buildPath: sample/Builds/Android
projectPath: sample
unityVersion: 2021.3.26f1
steps:
- uses: actions/checkout@v3
if: github.event_name != 'workflow_dispatch' || github.event.inputs.targetPlatform == 'All' || github.event.inputs.targetPlatform == matrix.targetPlatform
with:
lfs: true
- name: Setup symlinks for Unity 6 project
if: contains(matrix.targetPlatform, 'Unity6') && (github.event_name != 'workflow_dispatch' || github.event.inputs.targetPlatform == 'All' || github.event.inputs.targetPlatform == matrix.targetPlatform)
run: |
echo "Setting up symlinks for sample-unity6..."
cd sample-unity6/Assets
rm -rf Scenes Scripts Editor
rm -f Scenes.meta Scripts.meta Editor.meta
ln -s ../../sample/Assets/Scenes Scenes
ln -s ../../sample/Assets/Scripts Scripts
ln -s ../../sample/Assets/Editor Editor
ln -s ../../sample/Assets/Scenes.meta Scenes.meta
ln -s ../../sample/Assets/Scripts.meta Scripts.meta
ln -s ../../sample/Assets/Editor.meta Editor.meta
echo "✅ Symlinks created successfully!"
ls -la Scenes Scripts Editor
- uses: actions/cache@v3
if: github.event_name != 'workflow_dispatch' || github.event.inputs.targetPlatform == 'All' || github.event.inputs.targetPlatform == matrix.targetPlatform
with:
path: Library
key: Library-${{ matrix.targetPlatform }}-${{ hashFiles(format('{0}/Assets/**', matrix.projectPath), format('{0}/Packages/**', matrix.projectPath), format('{0}/ProjectSettings/**', matrix.projectPath)) }}
restore-keys: |
Library-${{ matrix.targetPlatform }}
Library-
- name: Build project
if: github.event_name != 'workflow_dispatch' || github.event.inputs.targetPlatform == 'All' || github.event.inputs.targetPlatform == matrix.targetPlatform
uses: game-ci/unity-builder@v4
env:
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }}
with:
targetPlatform: ${{ contains(matrix.targetPlatform, 'Unity6') && 'StandaloneOSX' || matrix.targetPlatform }}
projectPath: ${{ matrix.projectPath }}
unityVersion: ${{ matrix.unityVersion }}
buildMethod: ${{ matrix.buildMethod }}
customParameters: -logFile logFile.log -quit -batchmode
artifactsPath: ${{ matrix.buildPath }}
- name: Ensure build path exists
if: github.event_name != 'workflow_dispatch' || github.event.inputs.targetPlatform == 'All' || github.event.inputs.targetPlatform == matrix.targetPlatform
run: mkdir -p ${{ matrix.buildPath }}
- name: Upload artifact
if: github.event_name != 'workflow_dispatch' || github.event.inputs.targetPlatform == 'All' || github.event.inputs.targetPlatform == matrix.targetPlatform
uses: actions/upload-artifact@v4
with:
name: Build-${{ matrix.targetPlatform }}
path: ${{ matrix.buildPath }}
test:
name: Run ${{ matrix.targetPlatform }} UI tests 🧪
needs: build
strategy:
matrix:
include:
- targetPlatform: StandaloneOSX
runs-on: [self-hosted, macOS]
test_script: pytest -xs test/test_mac.py::MacTest
projectPath: sample
unityAppName: SampleApp
- targetPlatform: StandaloneOSX-Unity6
runs-on: [self-hosted, macOS]
test_script: pytest -xs test/test_mac.py::MacTest
projectPath: sample-unity6
unityAppName: Sample Unity 6 macOS
- targetPlatform: StandaloneWindows64
runs-on: [self-hosted, windows]
test_script: python -m pytest -xs test/test_windows.py::WindowsTest
projectPath: sample
unityAppName: SampleApp
# - targetPlatform: Android
# runs-on: [ self-hosted, macOS ]
# test_script: browserstack-sdk pytest -s ./test/test_android.py --browserstack.config "browserstack.android.yml"
concurrency:
group: ui-tests-email-inbox
cancel-in-progress: false # Let tests complete rather than canceling
runs-on: ${{ matrix.runs-on }}
steps:
- uses: actions/checkout@v3
if: github.event_name != 'workflow_dispatch' || github.event.inputs.targetPlatform == 'All' || github.event.inputs.targetPlatform == matrix.targetPlatform
with:
lfs: true
- name: Create temporary keychain
if: contains(matrix.targetPlatform, 'StandaloneOSX') && (github.event_name != 'workflow_dispatch' || github.event.inputs.targetPlatform == 'All' || github.event.inputs.targetPlatform == matrix.targetPlatform)
run: |
security list-keychains
security delete-keychain temporary || true
security list-keychains
security create-keychain -p "" temporary
security default-keychain -s temporary
security unlock-keychain -p "" temporary
security set-keychain-settings -lut 600 temporary
- uses: actions/download-artifact@v4
if: github.event_name != 'workflow_dispatch' || github.event.inputs.targetPlatform == 'All' || github.event.inputs.targetPlatform == matrix.targetPlatform
with:
name: Build-${{ matrix.targetPlatform }}
path: ${{ matrix.projectPath }}/Tests
- name: Make macOS artifact executable
if: contains(matrix.targetPlatform, 'StandaloneOSX') && (github.event_name != 'workflow_dispatch' || github.event.inputs.targetPlatform == 'All' || github.event.inputs.targetPlatform == matrix.targetPlatform)
run: chmod +x ${{ matrix.projectPath }}/Tests/${{ matrix.unityAppName }}.app/Contents/MacOS/*
- uses: actions/setup-python@v4
if: github.event_name != 'workflow_dispatch' || github.event.inputs.targetPlatform == 'All' || github.event.inputs.targetPlatform == matrix.targetPlatform
with:
python-version: "3.13"
- name: Install dependencies (Windows)
if: matrix.targetPlatform == 'StandaloneWindows64' && (github.event_name != 'workflow_dispatch' || github.event.inputs.targetPlatform == 'All' || github.event.inputs.targetPlatform == 'StandaloneWindows64')
run: pip install -r "${{ matrix.projectPath }}/Tests/requirements-desktop.txt"
- name: Install dependencies (Mac)
if: contains(matrix.targetPlatform, 'StandaloneOSX') && (github.event_name != 'workflow_dispatch' || github.event.inputs.targetPlatform == 'All' || github.event.inputs.targetPlatform == matrix.targetPlatform)
run: pip install -r "${{ matrix.projectPath }}/Tests/requirements-desktop.txt"
- name: Run UI tests
if: github.event_name != 'workflow_dispatch' || github.event.inputs.targetPlatform == 'All' || github.event.inputs.targetPlatform == matrix.targetPlatform
env:
UNITY_APP_PATH: ${{ matrix.unityAppName }}.app
UNITY_APP_NAME: ${{ matrix.unityAppName }}
MAILSLURP_API_KEY: ${{ secrets.MAILSLURP_API_KEY }}
BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }}
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
working-directory: ${{ matrix.projectPath }}/Tests
run: ${{ matrix.test_script }}
- name: Remove temporary keychain
if: contains(matrix.targetPlatform, 'StandaloneOSX') && (github.event_name != 'workflow_dispatch' || github.event.inputs.targetPlatform == 'All' || github.event.inputs.targetPlatform == matrix.targetPlatform)
run: |
security list-keychains
security delete-keychain temporary
security default-keychain -s ~/Library/Keychains/login.keychain-db
security list-keychains -d user -s ~/Library/Keychains/login.keychain-db
security list-keychains
build-ios: #test-ios:
name: Run iOS build #UI tests 🧪
needs:
- build
- test
runs-on: [ self-hosted, macOS ]
if: github.event_name != 'workflow_dispatch' || github.event.inputs.targetPlatform == 'All' || github.event.inputs.targetPlatform == 'iOS'
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.13"
# - name: Install dependencies
# run: pip install -r "sample/Tests/requirements-mobile.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/test/ios
# run: browserstack-sdk pytest -xs ./test_ios.py --browserstack.config "browserstack.ios.yml"