Skip to content

Commit 43ab6fd

Browse files
Merge branch 'feature/yamato-trigger-format-project-pack-mobile' into feature/yamato-trigger-format-project-pack
2 parents a354c0a + 6f4b998 commit 43ab6fd

File tree

3 files changed

+225
-0
lines changed

3 files changed

+225
-0
lines changed

.yamato/_triggers.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,13 @@ pull_request_trigger:
99
- .yamato/project-standards.yml#standards_{{ projects.first.name }}
1010
{% for project in projects -%}
1111
{% for platform in test_platforms -%}
12+
# desktop platforms
1213
- .yamato/project-tests.yml#test_{{ project.name }}_{{ project.test_editors.first }}_{{ platform.name }}
1314
{% endfor -%}
15+
# iOS
16+
- .yamato/mobile-build-and-run.yml#mobile_test_ios_{{ project.name }}_{{ project.test_editors.first }}
17+
# Android
18+
- .yamato/mobile-build-and-run.yml#mobile_test_android_{{ project.name }}_{{ project.test_editors.first }}
1419
{% endfor -%}
1520
triggers:
1621
cancel_old_ci: true

.yamato/disable-burst-if-requested.py

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
import argparse
2+
import json
3+
import os
4+
5+
6+
args = None
7+
platform_plugin_definition = None
8+
9+
10+
def resolve_target(platform):
11+
resolved_target = platform
12+
if 'StandaloneWindows' in platform:
13+
resolved_target = 'StandaloneWindows'
14+
elif 'StandaloneLinux' in platform:
15+
resolved_target = 'StandaloneLinux64'
16+
17+
return resolved_target
18+
19+
20+
def create_config(settings_path, platform):
21+
config_name = os.path.join(settings_path, 'BurstAotSettings_{}.json'.format(resolve_target(platform)))
22+
monobehaviour = {
23+
'm_Enabled': True,
24+
'm_EditorHideFlags': 0,
25+
'm_Name': "",
26+
'm_EditorClassIdentifier': 'Unity.Burst.Editor:Unity.Burst.Editor:BurstPlatformAotSettings',
27+
'EnableOptimisations': True,
28+
'EnableSafetyChecks': False,
29+
'EnableBurstCompilation': True
30+
}
31+
32+
data = {'MonoBehaviour': monobehaviour}
33+
with open(config_name, 'w') as f:
34+
json.dump(data, f)
35+
return config_name
36+
37+
38+
def get_or_create_AOT_config(project_path, platform):
39+
settings_path = os.path.join(project_path, 'ProjectSettings')
40+
if not os.path.isdir(settings_path):
41+
os.mkdir(settings_path)
42+
config_names = [os.path.join(settings_path, filename) for filename in os.listdir(settings_path) if filename.startswith("BurstAotSettings_{}".format(resolve_target(platform)))]
43+
if not config_names:
44+
return [create_config(settings_path, platform)]
45+
return config_names
46+
47+
48+
def disable_AOT(project_path, platform):
49+
config_names = get_or_create_AOT_config(project_path, platform)
50+
for config_name in config_names:
51+
set_AOT(config_name, False)
52+
53+
54+
def enable_AOT(project_path, platform):
55+
config_names = get_or_create_AOT_config(project_path, platform)
56+
for config_name in config_names:
57+
set_AOT(config_name, True)
58+
59+
60+
def set_AOT(config_file, status):
61+
config = None
62+
with open(config_file, 'r') as f:
63+
config = json.load(f)
64+
65+
assert config is not None, 'AOT settings not found; did the burst-enabled build finish successfully?'
66+
67+
config['MonoBehaviour']['EnableBurstCompilation'] = status
68+
with open(config_file, 'w') as f:
69+
json.dump(config, f)
70+
71+
72+
def main():
73+
enable_burst = os.environ.get('ENABLE_BURST_COMPILATION', 'true').strip().lower()
74+
if enable_burst == 'true':
75+
print('BURST COMPILATION: ENABLED')
76+
elif enable_burst == 'false':
77+
print('BURST COMPILATION: DISABLED')
78+
disable_AOT(args.project_path, args.platform)
79+
else:
80+
sys.exit('BURST COMPILATION: unexpected value: {}'.format(enable_burst))
81+
82+
83+
def parse_args():
84+
global args
85+
parser = argparse.ArgumentParser(description='This tool disables burst AOT compilation')
86+
parser.add_argument('--project-path', help='Specify the location of the unity project.')
87+
parser.add_argument('--platform', help="Platform to be used to run the build.")
88+
args = parser.parse_args()
89+
90+
91+
if __name__ == '__main__':
92+
parse_args()
93+
main()

.yamato/mobile-build-and-run.yml

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
{% metadata_file .yamato/project.metafile %}
2+
---
3+
4+
{% for project in projects -%}
5+
{% for editor in project.test_editors -%}
6+
Build_Player_With_Tests_iOS_{{ project.name }}_{{ editor }}:
7+
name: build {{ project.name }} - {{ editor }} on iOS
8+
agent:
9+
type: Unity::VM::osx
10+
image: mobile/macos-10.15-testing:stable
11+
flavor: b1.large
12+
13+
commands:
14+
- pip install unity-downloader-cli --index-url https://artifactory.prd.it.unity3d.com/artifactory/api/pypi/pypi/simple --upgrade
15+
- unity-downloader-cli -c Editor -c iOS -u {{ editor }} --fast --wait
16+
- curl -s https://artifactory.prd.it.unity3d.com/artifactory/unity-tools-local/utr-standalone/utr --output utr
17+
- chmod +x ./utr
18+
- ./utr --suite=playmode --platform=iOS --editor-location=.Editor --testproject={{ project.path }} --player-save-path=build/players --artifacts_path=build/logs --build-only --testfilter=Unity.Multiplayer.Samples.BossRoom.Tests.Runtime
19+
20+
artifacts:
21+
players:
22+
paths:
23+
- "build/players/**"
24+
logs:
25+
paths:
26+
- "build/logs/**"
27+
{% endfor -%}
28+
{% endfor -%}
29+
30+
{% for project in projects -%}
31+
{% for editor in project.test_editors -%}
32+
Build_Player_With_Tests_Android_{{ project.name }}_{{ editor }}:
33+
name: build {{ project.name }} - {{ editor }} on Android
34+
agent:
35+
type: Unity::VM
36+
# Any generic image can be used, no need to have Android tools in the image for building
37+
# All Android tools will be downloaded by unity-downloader-cli
38+
image: desktop/android-execution-r19:v0.1.1-860408
39+
flavor: b1.xlarge
40+
41+
commands:
42+
# Download unity-downloader-cli
43+
- pip install unity-downloader-cli --index-url https://artifactory.prd.it.unity3d.com/artifactory/api/pypi/pypi/simple --upgrade
44+
- curl -s https://artifactory.prd.it.unity3d.com/artifactory/unity-tools/utr-standalone/utr.bat --output utr.bat
45+
- python .yamato/disable-burst-if-requested.py --project-path {{ project.path }} --platform Android
46+
- unity-downloader-cli -c Editor -c Android -u {{ editor }} --fast --wait
47+
# Build player(s)
48+
- set UTR_VERSION=0.12.0
49+
- ./utr.bat --suite=playmode --platform=Android --editor-location=.Editor --testproject={{ project.path }} --player-save-path=build/players --artifacts_path=build/logs --scripting-backend=mono --build-only --testfilter=Unity.Multiplayer.Samples.BossRoom.Tests.Runtime
50+
artifacts:
51+
players:
52+
paths:
53+
- "build/players/**"
54+
logs:
55+
paths:
56+
- "build/logs/**"
57+
variables:
58+
CI: true
59+
ENABLE_BURST_COMPILATION: False
60+
{% endfor -%}
61+
{% endfor -%}
62+
63+
# For every editor version, run iOS project tests without
64+
# running package tests too since they are handled on their respective jobs
65+
{% for project in projects -%}
66+
{% for editor in project.test_editors -%}
67+
mobile_test_ios_{{ project.name }}_{{ editor }}:
68+
name: {{ project.name }} mobile project tests - {{ editor }} on iOS
69+
agent:
70+
type: Unity::mobile::iPhone
71+
image: mobile/macos-10.15-testing:latest
72+
flavor: b1.medium
73+
74+
# Skip repository cloning
75+
skip_checkout: true
76+
77+
# Set a dependency on the build job
78+
dependencies:
79+
- .yamato/mobile-build-and-run.yml#Build_Player_With_Tests_iOS_{{ project.name }}_{{ editor }}
80+
81+
commands:
82+
# Download standalone UnityTestRunner
83+
- curl -s https://artifactory.prd.it.unity3d.com/artifactory/unity-tools-local/utr-standalone/utr --output utr
84+
# Give UTR execution permissions
85+
- chmod +x ./utr
86+
# Run the test build on the device
87+
- ./utr --suite=playmode --platform=iOS --player-load-path=build/players --artifacts_path=build/test-results --testfilter=Unity.Multiplayer.Samples.BossRoom.Tests.Runtime
88+
89+
artifacts:
90+
logs:
91+
paths:
92+
- "build/test-results/**"
93+
{% endfor -%}
94+
{% endfor -%}
95+
96+
# For every editor version, run Android project tests without
97+
# running package tests too since they are handled on their respective jobs
98+
{% for project in projects -%}
99+
{% for editor in project.test_editors -%}
100+
mobile_test_android_{{ project.name }}_{{ editor }}:
101+
name: {{ project.name }} mobile project tests - {{ editor }} on Android
102+
agent:
103+
type: Unity::mobile::shield
104+
image: mobile/android-execution-r19:stable
105+
flavor: b1.medium
106+
107+
# Skip repository cloning
108+
skip_checkout: true
109+
# Set a dependency on the build job
110+
dependencies:
111+
- .yamato/mobile-build-and-run.yml#Build_Player_With_Tests_Android_{{ project.name }}_{{ editor }}
112+
commands:
113+
# Download standalone UnityTestRunner
114+
- curl -s https://artifactory.prd.it.unity3d.com/artifactory/unity-tools/utr-standalone/utr.bat --output utr.bat
115+
- |
116+
set ANDROID_DEVICE_CONNECTION=%BOKKEN_DEVICE_IP%
117+
start %ANDROID_SDK_ROOT%\platform-tools\adb.exe connect %BOKKEN_DEVICE_IP%
118+
start %ANDROID_SDK_ROOT%\platform-tools\adb.exe devices
119+
set UTR_VERSION=0.12.0
120+
./utr --artifacts_path=build/test-results --testproject={{ project.path }} --editor-location=.Editor --reruncount=2 --suite=playmode --platform=android --player-connection-ip=%BOKKEN_HOST_IP% --player-load-path=build/players --testfilter=Unity.Multiplayer.Samples.BossRoom.Tests.Runtime
121+
# Set uploadable artifact paths
122+
artifacts:
123+
logs:
124+
paths:
125+
- "build/test-results/**"
126+
{% endfor -%}
127+
{% endfor -%}

0 commit comments

Comments
 (0)