Skip to content

chore: Add mobile tests to nightly trigger #1161

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

Merged
merged 11 commits into from
Sep 13, 2021
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
.vs
.vscode
.idea
.DS_Store
2 changes: 2 additions & 0 deletions .yamato/_run-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ run_all_tests:
dependencies:
# Pull in package and validate jobs through the badges job
- .yamato/_triggers.yml#badges_test_trigger
- .yamato/mobile-build-and-test.yml#2021.2_Run_iOS_Player_With_Tests
- .yamato/mobile-build-and-test.yml#2021.2_Run_Android_Player_With_Tests
{% for platform in test_platforms -%}
{% for project in projects -%}
{% for editor in project.test_editors -%}
Expand Down
93 changes: 93 additions & 0 deletions .yamato/disable-burst-if-requested.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import argparse
import json
import os


args = None
platform_plugin_definition = None


def resolve_target(platform):
resolved_target = platform
if 'StandaloneWindows' in platform:
resolved_target = 'StandaloneWindows'
elif 'StandaloneLinux' in platform:
resolved_target = 'StandaloneLinux64'

return resolved_target


def create_config(settings_path, platform):
config_name = os.path.join(settings_path, 'BurstAotSettings_{}.json'.format(resolve_target(platform)))
monobehaviour = {
'm_Enabled': True,
'm_EditorHideFlags': 0,
'm_Name': "",
'm_EditorClassIdentifier': 'Unity.Burst.Editor:Unity.Burst.Editor:BurstPlatformAotSettings',
'DisableOptimisations': False,
'DisableSafetyChecks': True,
'DisableBurstCompilation': False
}

data = {'MonoBehaviour': monobehaviour}
with open(config_name, 'w') as f:
json.dump(data, f)
return config_name


def get_or_create_AOT_config(project_path, platform):
settings_path = os.path.join(project_path, 'ProjectSettings')
if not os.path.isdir(settings_path):
os.mkdir(settings_path)
config_names = [os.path.join(settings_path, filename) for filename in os.listdir(settings_path) if filename.startswith("BurstAotSettings_{}".format(resolve_target(platform)))]
if not config_names:
return [create_config(settings_path, platform)]
return config_names


def disable_AOT(project_path, platform):
config_names = get_or_create_AOT_config(project_path, platform)
for config_name in config_names:
set_AOT(config_name, True)


def enable_AOT(project_path, platform):
config_names = get_or_create_AOT_config(project_path, platform)
for config_name in config_names:
set_AOT(config_name, False)


def set_AOT(config_file, status):
config = None
with open(config_file, 'r') as f:
config = json.load(f)

assert config is not None, 'AOT settings not found; did the burst-enabled build finish successfully?'

config['MonoBehaviour']['DisableBurstCompilation'] = status
with open(config_file, 'w') as f:
json.dump(config, f)


def main():
enable_burst = os.environ.get('ENABLE_BURST_COMPILATION', 'true').strip().lower()
if enable_burst == 'true':
print('BURST COMPILATION: ENABLED')
elif enable_burst == 'false':
print('BURST COMPILATION: DISABLED')
disable_AOT(args.project_path, args.platform)
else:
sys.exit('BURST COMPILATION: unexpected value: {}'.format(enable_burst))


def parse_args():
global args
parser = argparse.ArgumentParser(description='This tool disables burst AOT compilation')
parser.add_argument('--project-path', help='Specify the location of the unity project.')
parser.add_argument('--platform', help="Platform to be used to run the build.")
args = parser.parse_args()


if __name__ == '__main__':
parse_args()
main()
77 changes: 54 additions & 23 deletions .yamato/mobile-build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,32 @@
name: 2021.2 Build Android player
agent:
type: Unity::VM
image: package-ci/win10:stable
flavor: b1.large
image: desktop/android-execution-r19:v0.1.1-860408
flavor: b1.xlarge
commands:
- pip install unity-downloader-cli --index-url https://artifactory.prd.it.unity3d.com/artifactory/api/pypi/pypi/simple
- curl -s https://artifactory.prd.it.unity3d.com/artifactory/unity-tools-local/utr-standalone/utr.bat --output utr.bat
- |
mkdir C:\TMP
cd C:\TMP
unity-downloader-cli -u 2021.2 -c editor -c Android -w --fast
- python .yamato/disable-burst-if-requested.py --project-path testproject --platform Android
- unity-downloader-cli -u 2021.2 -c editor -c Android -w --fast
- |
set UTR_VERSION=0.12.0
utr.bat --suite=playmode --platform=Android --editor-location=C:\TMP\.Editor --testproject=testproject --player-save-path=build/players --artifacts_path=build/logs --scripting-backend=il2cpp --build-only --testfilter=Unity.Netcode.RuntimeTests --extra-editor-arg=-nographics --timeout=1800 --extra-editor-arg=-batchmode --reruncount=2
utr.bat --artifacts_path=artifacts --timeout=1800 --testproject=testproject --editor-location=.Editor --suite=playmode --platform=android --build-only --player-save-path=build/players --extra-editor-arg=-batchmode --extra-editor-arg=-nographics --testfilter=Unity.Netcode.RuntimeTests
artifacts:
players:
paths:
- "build/players/**"
logs:
paths:
- "build/logs/**"
paths:
- '*.log'
- '*.xml'
- artifacts/**/*
- testproject/Logs/**
- testproject/Library/*.log
- testproject/*.log
- testproject/Builds/*.log
- build/test-results/**
- artifacts/**
- build/players/**
variables:
CI: true
ENABLE_BURST_COMPILATION: False

2021.2_Build_iOS_player:
name: 2021.2 Build iOS player
Expand All @@ -34,14 +41,20 @@
- curl -s https://artifactory.prd.it.unity3d.com/artifactory/unity-tools-local/utr-standalone/utr --output utr
- chmod +x ./utr
- export UTR_VERSION=0.12.0
- ./utr --suite=playmode --platform=iOS --editor-location=.Editor --testproject=testproject --player-save-path=build/players --artifacts_path=build/logs --build-only --testfilter=Unity.Netcode.RuntimeTests
- ./utr --artifacts_path=artifacts --timeout=1800 --testproject=testproject --editor-location=.Editor --suite=playmode --platform=iOS --build-only --player-save-path=build/players --extra-editor-arg=-batchmode --extra-editor-arg=-nographics --testfilter=Unity.Netcode.RuntimeTests
artifacts:
players:
paths:
- "build/players/**"
logs:
paths:
- "build/logs/**"
paths:
- '*.log'
- '*.xml'
- artifacts/**/*
- testproject/Logs/**
- testproject/Library/*.log
- testproject/*.log
- testproject/Builds/*.log
- build/test-results/**
- artifacts/**
- build/players/**


2021.2_Run_iOS_Player_With_Tests:
Expand All @@ -61,11 +74,20 @@
- chmod +x ./utr
# Run the test build on the device
- export UTR_VERSION=0.12.0
- ./utr --suite=playmode --platform=iOS --player-load-path=build/players --artifacts_path=build/test-results --testfilter=Unity.Netcode.RuntimeTests
- ./utr -artifacts_path=artifacts --testproject=testproject --editor-location=.Editor --reruncount=2 --suite=playmode --platform=iOS --player-load-path=build/players --testfilter=Unity.Netcode.RuntimeTests
artifacts:
logs:
paths:
- "build/test-results/**"
paths:
- '*.log'
- '*.xml'
- artifacts/**/*
- testproject/Logs/**
- testproject/Library/*.log
- testproject/*.log
- testproject/Builds/*.log
- build/test-results/**
- artifacts/**
- build/players/**

2021.2_Run_Android_Player_With_Tests:
name: 2021.2 Run Android player with tests
Expand All @@ -85,9 +107,18 @@
start %ANDROID_SDK_ROOT%\platform-tools\adb.exe connect %BOKKEN_DEVICE_IP%
start %ANDROID_SDK_ROOT%\platform-tools\adb.exe devices
set UTR_VERSION=0.12.0
./utr --suite=playmode --platform=android --player-load-path=build/players --artifacts_path=build/test-results --testfilter=Unity.Netcode.RuntimeTests
./utr --artifacts_path=artifacts --testproject=testproject --editor-location=.Editor --reruncount=2 --suite=playmode --platform=android --player-connection-ip=%BOKKEN_HOST_IP% --player-load-path=build/players --testfilter=Unity.Netcode.RuntimeTests
# Set uploadable artifact paths
artifacts:
logs:
paths:
- "build/test-results/**"
- '*.log'
- '*.xml'
- artifacts/**/*
- testproject/Logs/**
- testproject/Library/*.log
- testproject/*.log
- testproject/Builds/*.log
- build/test-results/**
- artifacts/**
- build/players/**