Skip to content

Commit dcf9a26

Browse files
test
Adding a project verification test that can be triggered by typing "apiupdater" as a comment. The project added verifies that the entire public API within the unity.netcode.editor namespace is auto-upgraded without compilation errors.
1 parent 78a9979 commit dcf9a26

41 files changed

Lines changed: 2491 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.yamato/_run-all.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,3 +444,17 @@ run_all_project_tests_cmb_service_default:
444444
{% endfor -%}
445445
{% endfor -%}
446446
{% endfor -%}
447+
448+
449+
# Runs the NGO 2.x -> 3.x editor script upgrade validation (see api-updater-test.yml)
450+
# Manual only today. Add this to develop_nightly or develop_weekly_trunk in _triggers.yml to schedule it.
451+
run_all_api_updater_tests:
452+
name: Run All API Updater Tests
453+
dependencies:
454+
{% for platform in test_platforms.desktop -%}
455+
{% if platform.name == "win" -%}
456+
{% for editor in validation_editors.default -%}
457+
- .yamato/api-updater-test.yml#api_updater_test_{{ platform.name }}_{{ editor }}
458+
{% endfor -%}
459+
{% endif -%}
460+
{% endfor -%}

.yamato/_triggers.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,22 @@ unified_pr_checks:
134134
cancel_old_ci: true
135135

136136

137+
# NGO 2.x -> 3.x editor script upgrade validation, on demand.
138+
# This job allows the API updater test to be kicked off by commenting "/ci apiupdater".
139+
# It is deliberately not part of the PR gate: what it protects only changes when a public editor type
140+
# is added, moved or removed, so paying a full editor import on every PR is not worth it.
141+
# To put it on a schedule, add .yamato/_run-all.yml#run_all_api_updater_tests to develop_nightly or
142+
# develop_weekly_trunk below.
143+
api_updater_pr_checks:
144+
name: API Updater checks [on demand]
145+
dependencies:
146+
- .yamato/_run-all.yml#run_all_api_updater_tests
147+
triggers:
148+
expression: |-
149+
pull_request.comment eq "apiupdater"
150+
cancel_old_ci: true
151+
152+
137153
# Run all tests on nightly basis.
138154
# Same subset as pull_request_trigger with addition of mobile/desktop/console tests and webgl builds
139155
# Those tests are all running on trunk and the default editor (since it's daily and running all of them would add a lot of overhead)

.yamato/api-updater-test.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
{% metadata_file .yamato/project.metafile %} # All configuration that is used to create different configurations (used in for loops) is taken from this file.
2+
---
3+
4+
# DESCRIPTION--------------------------------------------------------------------------
5+
# This job validates the NGO 2.x -> 3.x upgrade path for editor scripts.
6+
# NGO 3.0 renamed the editor assembly and its namespaces (Unity.Netcode.Editor ->
7+
# Unity.Netcode.GameObjects.Editor), and every relocated public type carries a [MovedFrom] so that
8+
# Unity's API updater rewrites a 2.x project's editor scripts automatically on upgrade.
9+
# apiupdaterproject holds editor code written against the 2.x API; the job imports it with
10+
# -accept-apiupdate and asserts that every 2.x type reference was rewritten and none survived.
11+
# See apiupdaterproject/README.md.
12+
13+
# WHY THIS JOB IS MANUAL ONLY-----------------------------------------------------------
14+
# It is deliberately not wired into pr_minimal_required_checks or pr_code_changes_checks. The thing
15+
# it protects only changes when a public editor type is added, moved or removed, so paying a full
16+
# editor import on every PR is not worth it. Kick it off with "/ci apiupdater" in a PR comment
17+
# (see api_updater_pr_checks in _triggers.yml), or from the Yamato UI.
18+
# If it should also run on a schedule, add .yamato/_run-all.yml#run_all_api_updater_tests to
19+
# develop_nightly or develop_weekly_trunk in _triggers.yml.
20+
21+
# CONFIGURATION STRUCTURE--------------------------------------------------------------
22+
# Windows only, and not looped over test_platforms: run-upgrade-test.ps1 is PowerShell and uses
23+
# robocopy to purge Library (paths there exceed MAX_PATH, which Remove-Item cannot delete).
24+
# A single editor is enough - the job is asserting on the editor's API updater, not on NGO
25+
# behaviour across editor versions. Widen to validation_editors.all if that stops being true.
26+
27+
# TECHNICAL CONSIDERATIONS---------------------------------------------------------------
28+
# apiupdaterproject/Packages/manifest.json references the package by relative path
29+
# (file:../../com.unity.netcode.gameobjects), so the job tests the package as it sits in the repo
30+
# and needs no package-pack dependency.
31+
# The script restores the 2.x sources when it finishes, so the checkout is left unmodified and the
32+
# job is safe to re-run on the same agent.
33+
# -Clean purges Library first: the assertion is meaningless against a warm Library that already
34+
# holds rewritten sources from a previous run.
35+
36+
# QUALITY CONSIDERATIONS--------------------------------------------------------------------
37+
# The expected type list in run-upgrade-test.ps1 is inline and hand-written. That is fine because
38+
# its input is frozen: it enumerates the 2.x public editor API, and develop-2.0.0 is released.
39+
# TODO: the list does not extend itself. A later relocation within 3.x, or a back port into 2.x,
40+
# has to be added by hand or this job silently stops covering it. Deriving the list from the
41+
# [MovedFrom] attributes in the package source would close that.
42+
43+
#------------------------------------------------------------------------------------
44+
45+
{% for platform in test_platforms.desktop -%}
46+
{% if platform.name == "win" -%}
47+
{% for editor in validation_editors.default -%}
48+
api_updater_test_{{ platform.name }}_{{ editor }}:
49+
name : API Updater Test - NGO 2.x editor scripts upgrade [{{ platform.name }}, {{ editor }}]
50+
agent:
51+
type: {{ platform.type }}
52+
image: {{ platform.image }}
53+
flavor: {{ platform.flavor }}
54+
commands:
55+
- unity-downloader-cli --fast --wait -u {{ editor }} -c Editor # Installing basic editor for the import
56+
- powershell -NoProfile -ExecutionPolicy Bypass -File apiupdaterproject/run-upgrade-test.ps1 -UnityExe .Editor/Editor/Unity.exe -Clean
57+
artifacts:
58+
logs:
59+
paths:
60+
- "apiupdaterproject/upgrade-test.log"
61+
dependencies:
62+
- .yamato/_run-all.yml#run_quick_checks # initial checks to perform fast validation of common errors
63+
{% endfor -%}
64+
{% endif -%}
65+
{% endfor -%}

apiupdaterproject/.gitignore

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# This .gitignore file should be placed at the root of your Unity project directory
2+
#
3+
# Get latest from https://github.com/github/gitignore/blob/master/Unity.gitignore
4+
#
5+
/[Ll]ibrary/
6+
/[Tt]emp/
7+
/[Oo]bj/
8+
/[Bb]uild/
9+
/[Bb]uilds/
10+
/[Ll]ogs/
11+
/[Uu]ser[Ss]ettings/
12+
13+
# MemoryCaptures can get excessive in size.
14+
# They also could contain extremely sensitive data
15+
/[Mm]emoryCaptures/
16+
17+
# Asset meta data should only be ignored when the corresponding asset is also ignored
18+
!/[Aa]ssets/**/*.meta
19+
20+
# Uncomment this line if you wish to ignore the asset store tools plugin
21+
# /[Aa]ssets/AssetStoreTools*
22+
23+
# Autogenerated Jetbrains Rider plugin
24+
/[Aa]ssets/Plugins/Editor/JetBrains*
25+
26+
# Visual Studio cache directory
27+
.vs/
28+
29+
# Gradle cache directory
30+
.gradle/
31+
32+
# Autogenerated VS/MD/Consulo solution and project files
33+
ExportedObj/
34+
.consulo/
35+
*.csproj
36+
*.unityproj
37+
*.sln
38+
*.suo
39+
*.tmp
40+
*.user
41+
*.userprefs
42+
*.pidb
43+
*.booproj
44+
*.svd
45+
*.pdb
46+
*.mdb
47+
*.opendb
48+
*.VC.db
49+
50+
# Unity3D generated meta files
51+
*.pidb.meta
52+
*.pdb.meta
53+
*.mdb.meta
54+
55+
# Unity3D generated file on crash reports
56+
sysinfo.txt
57+
58+
# Builds
59+
*.apk
60+
*.aab
61+
*.unitypackage
62+
63+
# Crashlytics generated file
64+
crashlytics-build.properties
65+
66+
# Packed Addressables
67+
/[Aa]ssets/[Aa]ddressable[Aa]ssets[Dd]ata/*/*.bin*
68+
69+
# Temporary auto-generated Android Assets
70+
/[Aa]ssets/[Ss]treamingAssets/aa.meta
71+
/[Aa]ssets/[Ss]treamingAssets/aa/*
72+
/[Aa]ssets/[Ss]treamingAssets/BuildInfo.json
73+
/[Aa]ssets/[Ss]treamingAssets/BuildInfo.json.meta
74+
75+
InitTestScene*
76+
77+
# API updater test run log
78+
upgrade-test.log
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
%YAML 1.1
2+
%TAG !u! tag:unity3d.com,2011:
3+
--- !u!114 &11400000
4+
MonoBehaviour:
5+
m_ObjectHideFlags: 0
6+
m_CorrespondingSourceObject: {fileID: 0}
7+
m_PrefabInstance: {fileID: 0}
8+
m_PrefabAsset: {fileID: 0}
9+
m_GameObject: {fileID: 0}
10+
m_Enabled: 1
11+
m_EditorHideFlags: 0
12+
m_Script: {fileID: 11500000, guid: e651dbb3fbac04af2b8f5abf007ddc23, type: 3}
13+
m_Name: DefaultNetworkPrefabs
14+
m_EditorClassIdentifier: Unity.Netcode.Runtime::Unity.Netcode.NetworkPrefabsList
15+
IsDefault: 1
16+
List: []

apiupdaterproject/Assets/DefaultNetworkPrefabs.asset.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apiupdaterproject/Assets/Editor.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// NGO 2.x-era editor code. Every type reference below must be rewritten by Unity's API updater to
2+
// its `Unity.Netcode.GameObjects.Editor` equivalent. Do not "fix" this file - it is the input to
3+
// the upgrade test. See ../../README.md.
4+
#pragma warning disable 169 // field is never used
5+
6+
using ApiUpdaterProject;
7+
using Unity.Netcode.Editor;
8+
using Unity.Netcode.Editor.Configuration;
9+
10+
namespace ApiUpdaterProject.Editor
11+
{
12+
internal class DeprecatedApiUsage
13+
{
14+
// Unity.Netcode.Editor -> Unity.Netcode.GameObjects.Editor
15+
private NetworkPrefabsEditor m_NetworkPrefabsEditor;
16+
private HiddenScriptEditor m_HiddenScriptEditor;
17+
private UnityTransportEditor m_UnityTransportEditor;
18+
private NetworkAnimatorEditor m_NetworkAnimatorEditor;
19+
private NetworkRigidbodyEditor m_NetworkRigidbodyEditor;
20+
private NetworkRigidbody2DEditor m_NetworkRigidbody2DEditor;
21+
private NetcodeEditorBase<UpgradeProbeBehaviour> m_NetcodeEditorBase;
22+
private NetworkBehaviourEditor m_NetworkBehaviourEditor;
23+
private NetworkManagerEditor m_NetworkManagerEditor;
24+
private NetworkManagerHelper m_NetworkManagerHelper;
25+
private NetworkObjectEditor m_NetworkObjectEditor;
26+
private NetworkRigidbodyBaseEditor m_NetworkRigidbodyBaseEditor;
27+
private NetworkTransformEditor m_NetworkTransformEditor;
28+
29+
// Unity.Netcode.Editor.Configuration -> Unity.Netcode.GameObjects.Editor.Configuration
30+
private NetcodeForGameObjectsProjectSettings m_ProjectSettings;
31+
private NetworkPrefabProcessor m_NetworkPrefabProcessor;
32+
}
33+
}

apiupdaterproject/Assets/Editor/DeprecatedApiUsage.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// The same 2.x API reached through the reference forms the updater has to handle separately from a
2+
// plain `using` + simple name: fully qualified names, a namespace alias, a type alias, a base type
3+
// and a typeof. Do not "fix" this file - it is the input to the upgrade test.
4+
#pragma warning disable 169 // field is never used
5+
6+
using System;
7+
using Cfg = Unity.Netcode.Editor.Configuration;
8+
using ManagerEditor = Unity.Netcode.Editor.NetworkManagerEditor;
9+
10+
namespace ApiUpdaterProject.Editor
11+
{
12+
internal class DeprecatedApiUsageQualified
13+
{
14+
private Unity.Netcode.Editor.NetworkObjectEditor m_FullyQualified;
15+
private Unity.Netcode.Editor.NetcodeEditorBase<ApiUpdaterProject.UpgradeProbeBehaviour> m_FullyQualifiedGeneric;
16+
private Cfg.NetworkPrefabProcessor m_ThroughNamespaceAlias;
17+
private ManagerEditor m_ThroughTypeAlias;
18+
19+
private Type TransformEditorType => typeof(Unity.Netcode.Editor.NetworkTransformEditor);
20+
}
21+
22+
internal class DerivesFromDeprecatedBase : Unity.Netcode.Editor.HiddenScriptEditor
23+
{
24+
}
25+
}

0 commit comments

Comments
 (0)