Skip to content

Commit c9e0b25

Browse files
chore: Yamato jobs to trigger format & UPM project pack (#489)
* formatting yamato job and dotnet format project * trigger job added to pack and test projects * reordered project versions so 2020.3 is tested first * removing legacy blocker on ubuntu * mobile build & run tests added & triggered by PRs * adding reference to project metafile * dependency file name fix * reordering name * android commands syntax fixed * job name definition descriptor * name for build file * adding matching build jobs for running jobs * reference to project metafile * using project path as name * updated build params * burst compilation removed on android, ios utr url param * disable burst .py file * shifting order of operations * test: using ngo params * python script enabling/disabling burst fixed, cleanup * specifying test filter * adding testfilter to builds and runs * android image change * utr command param update for playerconnection * utr version? * project name addition * adding editor path * testing building with utr 0.12.0 as well * formatting test * joined mobile build and run to single yml file * format * test editors 2021 & trunk * just 2021 * adding testfilter for only bossroom tests * removing testfilter on packing * fix to hanging tests * code source added * formatting files from RNSM PR
1 parent 0022336 commit c9e0b25

File tree

9 files changed

+306
-11
lines changed

9 files changed

+306
-11
lines changed

.yamato/_triggers.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{% metadata_file .yamato/project.metafile %}
2+
---
3+
4+
# Run all relevant tasks when a pull request targeting specified
5+
# branches is created or updated.
6+
pull_request_trigger:
7+
name: Pull Request Trigger (main, develop, & release branches)
8+
dependencies:
9+
- .yamato/project-standards.yml#standards_{{ projects.first.name }}
10+
{% for project in projects -%}
11+
{% for platform in test_platforms -%}
12+
# desktop platforms
13+
- .yamato/project-tests.yml#test_{{ project.name }}_{{ project.test_editors.first }}_{{ platform.name }}
14+
{% 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 }}
19+
{% endfor -%}
20+
triggers:
21+
cancel_old_ci: true
22+
pull_requests:
23+
- targets:
24+
only:
25+
- "main"
26+
- "develop"
27+
- "/release\/.*/"

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

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

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

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

.yamato/project-pack.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{% metadata_file .yamato/project.metafile %}
2+
---
3+
{% for project in projects -%}
4+
pack_{{ project.name }}:
5+
name: Pack {{ project.name }}
6+
agent:
7+
type: Unity::VM
8+
image: package-ci/ubuntu:stable
9+
flavor: b1.small
10+
commands:
11+
- npm install upm-ci-utils@stable -g --registry https://artifactory.prd.cds.internal.unity3d.com/artifactory/api/npm/upm-npm
12+
- upm-ci project pack --project-path {{ project.path }}
13+
artifacts:
14+
packages:
15+
paths:
16+
- "upm-ci~/packages/**/*"
17+
{% endfor -%}

.yamato/project-tests.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{% metadata_file .yamato/project.metafile %}
2+
---
3+
4+
# For every platform and editor version, run its project tests without
5+
# running package tests too since they are handled on their respective
6+
# jobs
7+
{% for project in projects -%}
8+
{% for editor in project.test_editors -%}
9+
{% for platform in test_platforms -%}
10+
test_{{ project.name }}_{{ editor }}_{{ platform.name }}:
11+
name : {{ project.name }} project tests - {{ editor }} on {{ platform.name }}
12+
agent:
13+
type: {{ platform.type }}
14+
image: {{ platform.image }}
15+
flavor: {{ platform.flavor}}
16+
commands:
17+
- npm install upm-ci-utils@stable -g --registry https://artifactory.prd.cds.internal.unity3d.com/artifactory/api/npm/upm-npm
18+
- pip install unity-downloader-cli --index-url https://artifactory.prd.it.unity3d.com/artifactory/api/pypi/pypi/simple
19+
- unity-downloader-cli -u {{ editor }} -c editor -w --fast
20+
- upm-ci project test -u {{ editor }} --project-path {{ project.path }} --type project-tests --extra-utr-arg=--testfilter=Unity.Multiplayer.Samples.BossRoom.Tests.Runtime
21+
artifacts:
22+
logs:
23+
paths:
24+
- "upm-ci~/test-results/**/*"
25+
dependencies:
26+
- .yamato/project-pack.yml#pack_{{ project.name }}
27+
{% endfor -%}
28+
{% endfor -%}
29+
{% endfor -%}

.yamato/project.metafile

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,4 @@ projects:
3333
- name: com.unity.multiplayer.samples.coop
3434
path: Packages/com.unity.multiplayer.samples.coop
3535
test_editors:
36-
- 2021.1
37-
- 2021.2
38-
- 2020.3
39-
- trunk
36+
- 2021.3

Assets/Tests/Runtime/HostAndDisconnectTest.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@ IEnumerator WaitUntilMainMenuSceneIsLoaded()
4141
// MainMenu is loaded as soon as Startup scene is launched, validate it is loaded
4242
yield return new TestUtilities.WaitForSceneLoad(k_MainMenuSceneName);
4343

44-
yield return new WaitForEndOfFrame();
44+
yield return null;
4545
}
4646

4747
IEnumerator WaitUntilCharacterIsSelectedAndReady(int playerIndex)
4848
{
4949
yield return new TestUtilities.WaitForSceneLoad(k_CharSelectSceneName);
5050

51-
yield return new WaitForEndOfFrame();
51+
yield return null;
5252

5353
// select a Character
5454
var seatObjectName = $"PlayerSeat ({playerIndex})";
@@ -61,7 +61,7 @@ IEnumerator WaitUntilCharacterIsSelectedAndReady(int playerIndex)
6161
uiCharSelectPlayerSeat.OnClicked();
6262

6363
// selecting a class will enable the "Ready" button, next frame it is selectable
64-
yield return new WaitForEndOfFrame();
64+
yield return null;
6565

6666
// hit ready
6767
ClientCharSelectState.Instance.OnPlayerClickedReady();
@@ -128,13 +128,13 @@ public IEnumerator IP_HostAndDisconnect_Valid([ValueSource(nameof(s_PlayerIndice
128128
// select "DIRECT IP" button
129129
clientMainMenuState.OnDirectIPClicked();
130130

131-
yield return new WaitForEndOfFrame();
131+
yield return null;
132132

133133
// select the "HOST" button
134134
ipHostingUI.OnCreateClick();
135135

136136
// confirming hosting will initialize the hosting process; next frame the results will be ready
137-
yield return new WaitForEndOfFrame();
137+
yield return null;
138138

139139
// verify hosting is successful
140140
Assert.That(m_NetworkManager.IsListening && m_NetworkManager.IsHost);

Packages/com.unity.multiplayer.samples.coop/Utilities/DontDestroyOnLoad.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ void Awake()
1010
DontDestroyOnLoad(gameObject);
1111
}
1212
}
13-
}
13+
}

Packages/com.unity.multiplayer.samples.coop/Utilities/Net/RNSM/AutoHide.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ IEnumerator HideAfterSeconds()
2020
gameObject.SetActive(false);
2121
}
2222
}
23-
}
23+
}

0 commit comments

Comments
 (0)