From 23f93527d1be4b692566b935551669dab2470c5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9D=D0=B0=D0=B7=D0=B0=D1=80?= Date: Mon, 27 Jul 2026 20:24:37 +0300 Subject: [PATCH 01/17] chore: add editor tooling folder metadata --- Assets/_ZoneUA/Editor.meta | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 Assets/_ZoneUA/Editor.meta diff --git a/Assets/_ZoneUA/Editor.meta b/Assets/_ZoneUA/Editor.meta new file mode 100644 index 0000000..6cc7c2b --- /dev/null +++ b/Assets/_ZoneUA/Editor.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 9f3b6d0fd9e84e388c1548f9845686b1 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: From 772e2ae722fa51707b76bdb5538cfbb9e1af7b1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9D=D0=B0=D0=B7=D0=B0=D1=80?= Date: Mon, 27 Jul 2026 20:24:49 +0300 Subject: [PATCH 02/17] feat: add editor validation assembly --- .../Editor/ZoneUA.EditorValidation.asmdef | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 Assets/_ZoneUA/Editor/ZoneUA.EditorValidation.asmdef diff --git a/Assets/_ZoneUA/Editor/ZoneUA.EditorValidation.asmdef b/Assets/_ZoneUA/Editor/ZoneUA.EditorValidation.asmdef new file mode 100644 index 0000000..9c8ee52 --- /dev/null +++ b/Assets/_ZoneUA/Editor/ZoneUA.EditorValidation.asmdef @@ -0,0 +1,16 @@ +{ + "name": "ZoneUA.EditorValidation", + "rootNamespace": "ZoneUA.EditorValidation", + "references": [], + "includePlatforms": [ + "Editor" + ], + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": false, + "precompiledReferences": [], + "autoReferenced": true, + "defineConstraints": [], + "versionDefines": [], + "noEngineReferences": false +} From 96788f925a6b7ab2c68d50706af760e0ed571845 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9D=D0=B0=D0=B7=D0=B0=D1=80?= Date: Mon, 27 Jul 2026 20:25:00 +0300 Subject: [PATCH 03/17] chore: add editor validation assembly metadata --- Assets/_ZoneUA/Editor/ZoneUA.EditorValidation.asmdef.meta | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 Assets/_ZoneUA/Editor/ZoneUA.EditorValidation.asmdef.meta diff --git a/Assets/_ZoneUA/Editor/ZoneUA.EditorValidation.asmdef.meta b/Assets/_ZoneUA/Editor/ZoneUA.EditorValidation.asmdef.meta new file mode 100644 index 0000000..26bdd6d --- /dev/null +++ b/Assets/_ZoneUA/Editor/ZoneUA.EditorValidation.asmdef.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 6dcaf627f6ef4bfaab8a034962cd3fb1 +AssemblyDefinitionImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: From 167ec7b07c08478679a1dc64ffa030eed9a5cd1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9D=D0=B0=D0=B7=D0=B0=D1=80?= Date: Mon, 27 Jul 2026 20:26:18 +0300 Subject: [PATCH 04/17] feat: add project, prefab and build validation tools --- .../_ZoneUA/Editor/ZoneUAProjectValidator.cs | 478 ++++++++++++++++++ 1 file changed, 478 insertions(+) create mode 100644 Assets/_ZoneUA/Editor/ZoneUAProjectValidator.cs diff --git a/Assets/_ZoneUA/Editor/ZoneUAProjectValidator.cs b/Assets/_ZoneUA/Editor/ZoneUAProjectValidator.cs new file mode 100644 index 0000000..54ea02c --- /dev/null +++ b/Assets/_ZoneUA/Editor/ZoneUAProjectValidator.cs @@ -0,0 +1,478 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using UnityEditor; +using UnityEditor.Build; +using UnityEditor.Build.Reporting; +using UnityEngine; + +namespace ZoneUA.EditorValidation +{ + public enum ValidationSeverity + { + Info, + Warning, + Error + } + + [Serializable] + public sealed class ValidationIssue + { + public ValidationSeverity severity; + public string code; + public string message; + public string assetPath; + + public ValidationIssue(ValidationSeverity severity, string code, string message, string assetPath = "") + { + this.severity = severity; + this.code = code; + this.message = message; + this.assetPath = assetPath ?? string.Empty; + } + } + + [Serializable] + public sealed class ValidationReport + { + public string generatedAtUtc; + public List issues = new List(); + + public int ErrorCount => issues.Count(issue => issue.severity == ValidationSeverity.Error); + public int WarningCount => issues.Count(issue => issue.severity == ValidationSeverity.Warning); + public bool IsValid => ErrorCount == 0; + + public void Add(ValidationSeverity severity, string code, string message, string assetPath = "") + { + issues.Add(new ValidationIssue(severity, code, message, assetPath)); + } + } + + public static class ZoneUAProjectValidator + { + private const string InputActionsPath = "Assets/_ZoneUA/Input/ZoneUAInput.inputactions"; + private static readonly string[] RequiredInputActions = + { + "Move", "Look", "Sprint", "Fire", "Reload", + "SwitchFireMode", "Weapon1", "Weapon2", "HideWeapon" + }; + + [MenuItem("Zone UA/Validation/Validate Project", priority = 1)] + public static void ValidateProjectMenu() + { + ValidationReport report = ValidateProject(); + LogReport(report); + ZoneUAValidationWindow.ShowReport(report); + } + + [MenuItem("Zone UA/Validation/Validate Selected Prefabs", priority = 2)] + public static void ValidateSelectedPrefabsMenu() + { + ValidationReport report = CreateReport(); + foreach (UnityEngine.Object selected in Selection.objects) + { + string path = AssetDatabase.GetAssetPath(selected); + if (path.EndsWith(".prefab", StringComparison.OrdinalIgnoreCase)) + { + ValidatePrefab(path, report); + } + } + + LogReport(report); + ZoneUAValidationWindow.ShowReport(report); + } + + public static ValidationReport ValidateProject() + { + ValidationReport report = CreateReport(); + ValidateMetaFiles(report); + ValidateDuplicateGuids(report); + ValidateAssemblyDefinitions(report); + ValidateInputActions(report); + ValidateBuildScenes(report); + ValidateDefinitions(report); + ValidatePrefabs(report); + ValidateScenes(report); + return report; + } + + public static void WriteJsonReport(ValidationReport report, string outputPath) + { + string directory = Path.GetDirectoryName(outputPath); + if (!string.IsNullOrEmpty(directory)) + { + Directory.CreateDirectory(directory); + } + + File.WriteAllText(outputPath, JsonUtility.ToJson(report, true)); + } + + private static ValidationReport CreateReport() + { + return new ValidationReport + { + generatedAtUtc = DateTime.UtcNow.ToString("O") + }; + } + + private static void ValidateMetaFiles(ValidationReport report) + { + foreach (string path in AssetDatabase.GetAllAssetPaths()) + { + if (!path.StartsWith("Assets/", StringComparison.Ordinal) || path.EndsWith(".meta", StringComparison.Ordinal)) + { + continue; + } + + if (!File.Exists(path + ".meta")) + { + report.Add(ValidationSeverity.Error, "META_MISSING", "Asset or folder has no .meta file.", path); + } + } + } + + private static void ValidateDuplicateGuids(ValidationReport report) + { + Dictionary pathByGuid = new Dictionary(StringComparer.OrdinalIgnoreCase); + foreach (string metaPath in Directory.GetFiles("Assets", "*.meta", SearchOption.AllDirectories)) + { + string guid = ReadMetaGuid(metaPath); + if (string.IsNullOrEmpty(guid)) + { + report.Add(ValidationSeverity.Error, "META_GUID_MISSING", "Meta file has no GUID.", metaPath.Replace('\\', '/')); + continue; + } + + string normalisedPath = metaPath.Replace('\\', '/'); + string existingPath; + if (pathByGuid.TryGetValue(guid, out existingPath)) + { + report.Add( + ValidationSeverity.Error, + "META_GUID_DUPLICATE", + "Duplicate GUID also used by " + existingPath + ".", + normalisedPath); + } + else + { + pathByGuid.Add(guid, normalisedPath); + } + } + } + + private static string ReadMetaGuid(string path) + { + foreach (string line in File.ReadLines(path)) + { + if (line.StartsWith("guid: ", StringComparison.Ordinal)) + { + return line.Substring(6).Trim(); + } + } + + return string.Empty; + } + + private static void ValidateAssemblyDefinitions(ValidationReport report) + { + Dictionary pathByName = new Dictionary(StringComparer.Ordinal); + foreach (string path in Directory.GetFiles("Assets", "*.asmdef", SearchOption.AllDirectories)) + { + string normalisedPath = path.Replace('\\', '/'); + try + { + AssemblyDefinitionData data = JsonUtility.FromJson(File.ReadAllText(path)); + if (data == null || string.IsNullOrWhiteSpace(data.name)) + { + report.Add(ValidationSeverity.Error, "ASMDEF_NAME_MISSING", "Assembly definition has no name.", normalisedPath); + continue; + } + + string existingPath; + if (pathByName.TryGetValue(data.name, out existingPath)) + { + report.Add( + ValidationSeverity.Error, + "ASMDEF_NAME_DUPLICATE", + "Assembly name is already used by " + existingPath + ".", + normalisedPath); + } + else + { + pathByName.Add(data.name, normalisedPath); + } + } + catch (Exception exception) + { + report.Add(ValidationSeverity.Error, "ASMDEF_INVALID_JSON", exception.Message, normalisedPath); + } + } + } + + private static void ValidateInputActions(ValidationReport report) + { + if (!File.Exists(InputActionsPath)) + { + report.Add(ValidationSeverity.Error, "INPUT_ACTIONS_MISSING", "The central InputActionAsset is missing.", InputActionsPath); + return; + } + + string content = File.ReadAllText(InputActionsPath); + if (content.IndexOf("\"name\": \"Player\"", StringComparison.Ordinal) < 0) + { + report.Add(ValidationSeverity.Error, "INPUT_MAP_MISSING", "Input action map 'Player' is missing.", InputActionsPath); + } + + foreach (string action in RequiredInputActions) + { + if (content.IndexOf("\"name\": \"" + action + "\"", StringComparison.Ordinal) < 0) + { + report.Add(ValidationSeverity.Error, "INPUT_ACTION_MISSING", "Required input action is missing: " + action + ".", InputActionsPath); + } + } + } + + private static void ValidateBuildScenes(ValidationReport report) + { + EditorBuildSettingsScene[] enabledScenes = EditorBuildSettings.scenes.Where(scene => scene.enabled && !string.IsNullOrWhiteSpace(scene.path)).ToArray(); + if (enabledScenes.Length == 0) + { + report.Add(ValidationSeverity.Warning, "BUILD_SCENES_EMPTY", "No enabled scenes are configured in Build Settings.", "ProjectSettings/EditorBuildSettings.asset"); + } + } + + private static void ValidateDefinitions(ValidationReport report) + { + ValidateScriptableObjectsByTypeName("BiomeDefinition", ValidateBiomeDefinition, report); + ValidateScriptableObjectsByTypeName("WorldGenerationSettings", ValidateWorldGenerationSettings, report); + ValidateScriptableObjectsByTypeName("WeaponDefinition", ValidateIdProperty, report); + ValidateScriptableObjectsByTypeName("FactionDefinition", ValidateIdProperty, report); + } + + private static void ValidateScriptableObjectsByTypeName( + string typeName, + Action validator, + ValidationReport report) + { + foreach (string guid in AssetDatabase.FindAssets("t:ScriptableObject")) + { + string path = AssetDatabase.GUIDToAssetPath(guid); + ScriptableObject asset = AssetDatabase.LoadAssetAtPath(path); + if (asset == null || asset.GetType().Name != typeName) + { + continue; + } + + validator(new SerializedObject(asset), path, report); + } + } + + private static void ValidateIdProperty(SerializedObject serialized, string path, ValidationReport report) + { + SerializedProperty id = serialized.FindProperty("id"); + if (id != null && string.IsNullOrWhiteSpace(id.stringValue)) + { + report.Add(ValidationSeverity.Error, "DEFINITION_ID_EMPTY", "Definition has an empty id.", path); + } + } + + private static void ValidateBiomeDefinition(SerializedObject serialized, string path, ValidationReport report) + { + ValidateIdProperty(serialized, path, report); + SerializedProperty terrainPrefab = serialized.FindProperty("terrainPrefab"); + if (terrainPrefab != null && terrainPrefab.objectReferenceValue == null) + { + report.Add(ValidationSeverity.Warning, "BIOME_TERRAIN_MISSING", "Biome has no terrain presentation prefab.", path); + } + } + + private static void ValidateWorldGenerationSettings(SerializedObject serialized, string path, ValidationReport report) + { + SerializedProperty fallbackBiome = serialized.FindProperty("fallbackBiome"); + if (fallbackBiome != null && fallbackBiome.objectReferenceValue == null) + { + report.Add(ValidationSeverity.Error, "WORLD_FALLBACK_MISSING", "World settings have no fallback biome.", path); + } + + SerializedProperty biomes = serialized.FindProperty("biomes"); + if (biomes == null || !biomes.isArray || biomes.arraySize == 0) + { + report.Add(ValidationSeverity.Error, "WORLD_BIOMES_EMPTY", "World settings contain no biome list.", path); + } + } + + private static void ValidatePrefabs(ValidationReport report) + { + foreach (string guid in AssetDatabase.FindAssets("t:Prefab")) + { + ValidatePrefab(AssetDatabase.GUIDToAssetPath(guid), report); + } + } + + private static void ValidatePrefab(string path, ValidationReport report) + { + GameObject prefab = AssetDatabase.LoadAssetAtPath(path); + if (prefab == null) + { + return; + } + + MonoBehaviour[] behaviours = prefab.GetComponentsInChildren(true); + HashSet typeNames = new HashSet(behaviours.Where(item => item != null).Select(item => item.GetType().Name)); + + if (typeNames.Contains("NPCController")) + { + RequireComponentType(typeNames, "Health", "NPC_HEALTH_MISSING", path, report); + RequireComponentType(typeNames, "Death", "NPC_DEATH_MISSING", path, report); + RequireComponentType(typeNames, "FactionMember", "NPC_FACTION_MISSING", path, report); + } + + if (typeNames.Contains("WeaponController") && !typeNames.Contains("Weapon")) + { + report.Add(ValidationSeverity.Error, "WEAPON_DATA_MISSING", "WeaponController prefab has no Weapon component.", path); + } + + if (typeNames.Contains("PlayerInputRouter")) + { + MonoBehaviour router = behaviours.FirstOrDefault(item => item != null && item.GetType().Name == "PlayerInputRouter"); + SerializedObject serialized = new SerializedObject(router); + SerializedProperty actions = serialized.FindProperty("actions"); + if (actions != null && actions.objectReferenceValue == null) + { + report.Add(ValidationSeverity.Error, "PLAYER_ACTIONS_UNASSIGNED", "PlayerInputRouter has no InputActionAsset assigned.", path); + } + } + } + + private static void RequireComponentType( + HashSet typeNames, + string requiredType, + string code, + string path, + ValidationReport report) + { + if (!typeNames.Contains(requiredType)) + { + report.Add(ValidationSeverity.Error, code, "NPC prefab requires " + requiredType + ".", path); + } + } + + private static void ValidateScenes(ValidationReport report) + { + foreach (string guid in AssetDatabase.FindAssets("t:Scene")) + { + string path = AssetDatabase.GUIDToAssetPath(guid); + if (!File.Exists(path + ".meta")) + { + report.Add(ValidationSeverity.Error, "SCENE_META_MISSING", "Scene has no .meta file.", path); + } + } + } + + public static void LogReport(ValidationReport report) + { + foreach (ValidationIssue issue in report.issues) + { + string text = "[ZoneUA:" + issue.code + "] " + issue.message + + (string.IsNullOrEmpty(issue.assetPath) ? string.Empty : " (" + issue.assetPath + ")"); + switch (issue.severity) + { + case ValidationSeverity.Error: + Debug.LogError(text); + break; + case ValidationSeverity.Warning: + Debug.LogWarning(text); + break; + default: + Debug.Log(text); + break; + } + } + + Debug.Log("Zone UA validation finished: " + report.ErrorCount + " error(s), " + report.WarningCount + " warning(s)."); + } + + [Serializable] + private sealed class AssemblyDefinitionData + { + public string name; + } + } + + public sealed class ZoneUABuildValidator : IPreprocessBuildWithReport + { + public int callbackOrder => -1000; + + public void OnPreprocessBuild(BuildReport buildReport) + { + ValidationReport report = ZoneUAProjectValidator.ValidateProject(); + ZoneUAProjectValidator.WriteJsonReport(report, "Logs/ZoneUAValidation.json"); + ZoneUAProjectValidator.LogReport(report); + if (!report.IsValid) + { + throw new BuildFailedException("Zone UA project validation failed with " + report.ErrorCount + " error(s). See Logs/ZoneUAValidation.json."); + } + } + } + + public static class ZoneUAValidationCli + { + public static void Run() + { + ValidationReport report = ZoneUAProjectValidator.ValidateProject(); + ZoneUAProjectValidator.WriteJsonReport(report, "Logs/ZoneUAValidation.json"); + ZoneUAProjectValidator.LogReport(report); + if (!report.IsValid) + { + throw new Exception("Zone UA validation failed with " + report.ErrorCount + " error(s)."); + } + } + } + + public sealed class ZoneUAValidationWindow : EditorWindow + { + private ValidationReport report; + private Vector2 scroll; + + public static void ShowReport(ValidationReport report) + { + ZoneUAValidationWindow window = GetWindow("Zone UA Validation"); + window.report = report; + window.Show(); + } + + private void OnGUI() + { + EditorGUILayout.LabelField("Project Validation", EditorStyles.boldLabel); + if (GUILayout.Button("Run Validation")) + { + report = ZoneUAProjectValidator.ValidateProject(); + ZoneUAProjectValidator.LogReport(report); + } + + if (report == null) + { + EditorGUILayout.HelpBox("Run validation to inspect project issues.", MessageType.Info); + return; + } + + EditorGUILayout.LabelField("Errors", report.ErrorCount.ToString()); + EditorGUILayout.LabelField("Warnings", report.WarningCount.ToString()); + scroll = EditorGUILayout.BeginScrollView(scroll); + foreach (ValidationIssue issue in report.issues) + { + MessageType messageType = issue.severity == ValidationSeverity.Error + ? MessageType.Error + : issue.severity == ValidationSeverity.Warning ? MessageType.Warning : MessageType.Info; + EditorGUILayout.HelpBox(issue.code + ": " + issue.message + "\n" + issue.assetPath, messageType); + if (!string.IsNullOrEmpty(issue.assetPath) && GUILayout.Button("Select " + issue.assetPath)) + { + Selection.activeObject = AssetDatabase.LoadMainAssetAtPath(issue.assetPath); + EditorGUIUtility.PingObject(Selection.activeObject); + } + } + EditorGUILayout.EndScrollView(); + } + } +} From a6a0c8aad51d013d6b77ee2009a112c5335c9e49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9D=D0=B0=D0=B7=D0=B0=D1=80?= Date: Mon, 27 Jul 2026 20:26:30 +0300 Subject: [PATCH 05/17] chore: add project validator metadata --- Assets/_ZoneUA/Editor/ZoneUAProjectValidator.cs.meta | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 Assets/_ZoneUA/Editor/ZoneUAProjectValidator.cs.meta diff --git a/Assets/_ZoneUA/Editor/ZoneUAProjectValidator.cs.meta b/Assets/_ZoneUA/Editor/ZoneUAProjectValidator.cs.meta new file mode 100644 index 0000000..abc6481 --- /dev/null +++ b/Assets/_ZoneUA/Editor/ZoneUAProjectValidator.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 69e10e9c27c941a4bea30fe31fbac716 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: From b6e2d0357447d7ad61b52f5edee5b13a8507f12e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9D=D0=B0=D0=B7=D0=B0=D1=80?= Date: Mon, 27 Jul 2026 20:27:14 +0300 Subject: [PATCH 06/17] ci: add Unity repository integrity validator --- scripts/validate_unity_repo.py | 169 +++++++++++++++++++++++++++++++++ 1 file changed, 169 insertions(+) create mode 100644 scripts/validate_unity_repo.py diff --git a/scripts/validate_unity_repo.py b/scripts/validate_unity_repo.py new file mode 100644 index 0000000..bd59dc3 --- /dev/null +++ b/scripts/validate_unity_repo.py @@ -0,0 +1,169 @@ +#!/usr/bin/env python3 +"""Fast repository checks that do not require a Unity installation.""" + +from __future__ import annotations + +import json +import pathlib +import re +import sys +from dataclasses import dataclass + +ROOT = pathlib.Path(__file__).resolve().parents[1] +ASSETS = ROOT / "Assets" +GUID_RE = re.compile(r"^guid:\s*([0-9a-fA-F]{32})\s*$", re.MULTILINE) +REQUIRED_ACTIONS = { + "Move", + "Look", + "Sprint", + "Fire", + "Reload", + "SwitchFireMode", + "Weapon1", + "Weapon2", + "HideWeapon", +} + + +@dataclass(frozen=True) +class Issue: + severity: str + code: str + path: str + message: str + + +def relative(path: pathlib.Path) -> str: + return path.relative_to(ROOT).as_posix() + + +def check_meta_files(issues: list[Issue]) -> None: + for path in ASSETS.rglob("*"): + if path.name.startswith(".") or path.suffix == ".meta": + continue + meta = pathlib.Path(f"{path}.meta") + if not meta.is_file(): + issues.append(Issue("error", "META_MISSING", relative(path), "Asset or folder has no .meta file.")) + + +def check_guids(issues: list[Issue]) -> None: + owner_by_guid: dict[str, pathlib.Path] = {} + for meta in ASSETS.rglob("*.meta"): + text = meta.read_text(encoding="utf-8", errors="replace") + match = GUID_RE.search(text) + if not match: + issues.append(Issue("error", "META_GUID_MISSING", relative(meta), "Meta file has no valid 32-character GUID.")) + continue + guid = match.group(1).lower() + previous = owner_by_guid.get(guid) + if previous is not None: + issues.append( + Issue( + "error", + "META_GUID_DUPLICATE", + relative(meta), + f"GUID is already used by {relative(previous)}.", + ) + ) + else: + owner_by_guid[guid] = meta + + +def load_json(path: pathlib.Path, issues: list[Issue], code: str) -> object | None: + try: + return json.loads(path.read_text(encoding="utf-8")) + except (OSError, json.JSONDecodeError) as error: + issues.append(Issue("error", code, relative(path), str(error))) + return None + + +def check_asmdefs(issues: list[Issue]) -> None: + owner_by_name: dict[str, pathlib.Path] = {} + for path in ASSETS.rglob("*.asmdef"): + payload = load_json(path, issues, "ASMDEF_INVALID_JSON") + if not isinstance(payload, dict): + continue + name = payload.get("name") + if not isinstance(name, str) or not name.strip(): + issues.append(Issue("error", "ASMDEF_NAME_MISSING", relative(path), "Assembly definition has no name.")) + continue + previous = owner_by_name.get(name) + if previous is not None: + issues.append( + Issue("error", "ASMDEF_NAME_DUPLICATE", relative(path), f"Assembly name is already used by {relative(previous)}.") + ) + else: + owner_by_name[name] = path + + +def check_input_actions(issues: list[Issue]) -> None: + path = ASSETS / "_ZoneUA" / "Input" / "ZoneUAInput.inputactions" + if not path.is_file(): + issues.append(Issue("error", "INPUT_ACTIONS_MISSING", relative(path), "Central InputActionAsset is missing.")) + return + payload = load_json(path, issues, "INPUT_ACTIONS_INVALID_JSON") + if not isinstance(payload, dict): + return + maps = payload.get("maps") + if not isinstance(maps, list): + issues.append(Issue("error", "INPUT_MAPS_MISSING", relative(path), "InputActionAsset has no maps array.")) + return + player = next((item for item in maps if isinstance(item, dict) and item.get("name") == "Player"), None) + if player is None: + issues.append(Issue("error", "INPUT_PLAYER_MAP_MISSING", relative(path), "Player action map is missing.")) + return + actions = player.get("actions") + names = {item.get("name") for item in actions if isinstance(item, dict)} if isinstance(actions, list) else set() + for missing in sorted(REQUIRED_ACTIONS - names): + issues.append(Issue("error", "INPUT_ACTION_MISSING", relative(path), f"Required action is missing: {missing}.")) + + +def check_manifest(issues: list[Issue]) -> None: + path = ROOT / "Packages" / "manifest.json" + payload = load_json(path, issues, "PACKAGE_MANIFEST_INVALID_JSON") + if not isinstance(payload, dict): + return + dependencies = payload.get("dependencies") + if not isinstance(dependencies, dict) or "com.unity.inputsystem" not in dependencies: + issues.append(Issue("error", "INPUT_PACKAGE_MISSING", relative(path), "Unity Input System package is not declared.")) + + +def check_project_version(issues: list[Issue]) -> None: + path = ROOT / "ProjectSettings" / "ProjectVersion.txt" + if not path.is_file(): + issues.append(Issue("error", "PROJECT_VERSION_MISSING", relative(path), "ProjectVersion.txt is missing.")) + return + text = path.read_text(encoding="utf-8", errors="replace") + if "m_EditorVersion:" not in text: + issues.append(Issue("error", "PROJECT_VERSION_INVALID", relative(path), "Editor version entry is missing.")) + elif "m_EditorVersion: 2022.2.8f1" in text: + issues.append( + Issue( + "warning", + "PROJECT_VERSION_LEGACY", + relative(path), + "Repository still declares Unity 2022.2.8f1; commit Unity 6000.5.5f1 migration files after opening the project locally.", + ) + ) + + +def main() -> int: + issues: list[Issue] = [] + check_meta_files(issues) + check_guids(issues) + check_asmdefs(issues) + check_input_actions(issues) + check_manifest(issues) + check_project_version(issues) + + for issue in issues: + print(f"::{issue.severity} file={issue.path},title={issue.code}::{issue.message}") + + errors = sum(issue.severity == "error" for issue in issues) + warnings = sum(issue.severity == "warning" for issue in issues) + print(f"Unity repository validation: {errors} error(s), {warnings} warning(s).") + return 1 if errors else 0 + + +if __name__ == "__main__": + sys.exit(main()) From a5e871c6dea0f8b927abdcc77872bddee8eeda99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9D=D0=B0=D0=B7=D0=B0=D1=80?= Date: Mon, 27 Jul 2026 20:27:32 +0300 Subject: [PATCH 07/17] ci: add repository validation and Unity test workflow --- .github/workflows/unity-validation.yml | 102 +++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 .github/workflows/unity-validation.yml diff --git a/.github/workflows/unity-validation.yml b/.github/workflows/unity-validation.yml new file mode 100644 index 0000000..1e15864 --- /dev/null +++ b/.github/workflows/unity-validation.yml @@ -0,0 +1,102 @@ +name: Unity Validation + +on: + pull_request: + push: + branches: + - master + workflow_dispatch: + +concurrency: + group: unity-validation-${{ github.ref }} + cancel-in-progress: true + +jobs: + repository-integrity: + name: Repository integrity + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + lfs: true + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.12" + + - name: Validate Unity repository + run: python scripts/validate_unity_repo.py + + unity-editmode-tests: + name: Unity EditMode tests + if: ${{ vars.RUN_UNITY_TESTS == 'true' }} + runs-on: ubuntu-latest + timeout-minutes: 45 + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + lfs: true + + - name: Restore Unity Library cache + uses: actions/cache@v4 + with: + path: Library + key: Library-${{ runner.os }}-${{ vars.UNITY_VERSION }}-${{ hashFiles('Assets/**', 'Packages/**', 'ProjectSettings/**') }} + restore-keys: | + Library-${{ runner.os }}-${{ vars.UNITY_VERSION }}- + + - name: Run EditMode tests + uses: game-ci/unity-test-runner@v4 + env: + UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }} + UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }} + UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }} + with: + unityVersion: ${{ vars.UNITY_VERSION }} + testMode: EditMode + artifactsPath: TestResults/EditMode + githubToken: ${{ secrets.GITHUB_TOKEN }} + checkName: Unity EditMode tests + + - name: Upload EditMode results + if: always() + uses: actions/upload-artifact@v4 + with: + name: unity-editmode-results + path: TestResults/EditMode + if-no-files-found: warn + + unity-project-validation: + name: Unity project validation + if: ${{ vars.RUN_UNITY_TESTS == 'true' }} + runs-on: ubuntu-latest + timeout-minutes: 45 + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + lfs: true + + - name: Run project validator + uses: game-ci/unity-builder@v4 + env: + UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }} + UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }} + UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }} + with: + unityVersion: ${{ vars.UNITY_VERSION }} + targetPlatform: StandaloneLinux64 + customParameters: -batchmode -nographics -quit -executeMethod ZoneUA.EditorValidation.ZoneUAValidationCli.Run + buildMethod: ZoneUA.EditorValidation.ZoneUAValidationCli.Run + + - name: Upload validation report + if: always() + uses: actions/upload-artifact@v4 + with: + name: unity-project-validation + path: Logs/ZoneUAValidation.json + if-no-files-found: warn From fb4cc40489520fc3c1a555d3f8563ff59f50a76a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9D=D0=B0=D0=B7=D0=B0=D1=80?= Date: Mon, 27 Jul 2026 20:28:18 +0300 Subject: [PATCH 08/17] fix: keep Unity CI validation runner-safe --- .github/workflows/unity-validation.yml | 31 -------------------------- 1 file changed, 31 deletions(-) diff --git a/.github/workflows/unity-validation.yml b/.github/workflows/unity-validation.yml index 1e15864..9601a75 100644 --- a/.github/workflows/unity-validation.yml +++ b/.github/workflows/unity-validation.yml @@ -69,34 +69,3 @@ jobs: name: unity-editmode-results path: TestResults/EditMode if-no-files-found: warn - - unity-project-validation: - name: Unity project validation - if: ${{ vars.RUN_UNITY_TESTS == 'true' }} - runs-on: ubuntu-latest - timeout-minutes: 45 - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - lfs: true - - - name: Run project validator - uses: game-ci/unity-builder@v4 - env: - UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }} - UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }} - UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }} - with: - unityVersion: ${{ vars.UNITY_VERSION }} - targetPlatform: StandaloneLinux64 - customParameters: -batchmode -nographics -quit -executeMethod ZoneUA.EditorValidation.ZoneUAValidationCli.Run - buildMethod: ZoneUA.EditorValidation.ZoneUAValidationCli.Run - - - name: Upload validation report - if: always() - uses: actions/upload-artifact@v4 - with: - name: unity-project-validation - path: Logs/ZoneUAValidation.json - if-no-files-found: warn From f4d4d28dd77c9cf5e353a12a05f7fd462bf8fcda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9D=D0=B0=D0=B7=D0=B0=D1=80?= Date: Mon, 27 Jul 2026 20:28:30 +0300 Subject: [PATCH 09/17] chore: add editor tests folder metadata --- Assets/_ZoneUA/Tests/Editor.meta | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 Assets/_ZoneUA/Tests/Editor.meta diff --git a/Assets/_ZoneUA/Tests/Editor.meta b/Assets/_ZoneUA/Tests/Editor.meta new file mode 100644 index 0000000..1bfd0af --- /dev/null +++ b/Assets/_ZoneUA/Tests/Editor.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 26d9bd454e224cd98f2f73f1e86efbd6 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: From 0d524369f1dae60677dbedab7a8b1b87c0253ddc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9D=D0=B0=D0=B7=D0=B0=D1=80?= Date: Mon, 27 Jul 2026 20:28:38 +0300 Subject: [PATCH 10/17] test: add editor validation test assembly --- .../ZoneUA.EditorValidation.Tests.asmdef | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 Assets/_ZoneUA/Tests/Editor/ZoneUA.EditorValidation.Tests.asmdef diff --git a/Assets/_ZoneUA/Tests/Editor/ZoneUA.EditorValidation.Tests.asmdef b/Assets/_ZoneUA/Tests/Editor/ZoneUA.EditorValidation.Tests.asmdef new file mode 100644 index 0000000..f29c209 --- /dev/null +++ b/Assets/_ZoneUA/Tests/Editor/ZoneUA.EditorValidation.Tests.asmdef @@ -0,0 +1,21 @@ +{ + "name": "ZoneUA.EditorValidation.Tests", + "rootNamespace": "ZoneUA.EditorValidation.Tests", + "references": [ + "ZoneUA.EditorValidation" + ], + "includePlatforms": [ + "Editor" + ], + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": false, + "precompiledReferences": [], + "autoReferenced": false, + "defineConstraints": [], + "versionDefines": [], + "noEngineReferences": false, + "optionalUnityReferences": [ + "TestAssemblies" + ] +} From 69aba3ab1f7bfd9d011bd863186a1cf2918b6e0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9D=D0=B0=D0=B7=D0=B0=D1=80?= Date: Mon, 27 Jul 2026 20:28:48 +0300 Subject: [PATCH 11/17] chore: add editor validation tests metadata --- .../Tests/Editor/ZoneUA.EditorValidation.Tests.asmdef.meta | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 Assets/_ZoneUA/Tests/Editor/ZoneUA.EditorValidation.Tests.asmdef.meta diff --git a/Assets/_ZoneUA/Tests/Editor/ZoneUA.EditorValidation.Tests.asmdef.meta b/Assets/_ZoneUA/Tests/Editor/ZoneUA.EditorValidation.Tests.asmdef.meta new file mode 100644 index 0000000..8c2033c --- /dev/null +++ b/Assets/_ZoneUA/Tests/Editor/ZoneUA.EditorValidation.Tests.asmdef.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: b99ced9e4d3f4ba98d978ec1a0d9f519 +AssemblyDefinitionImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: From 7a85a7c9a8ebfa5f76aaea810239449cddecd53c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9D=D0=B0=D0=B7=D0=B0=D1=80?= Date: Mon, 27 Jul 2026 20:29:02 +0300 Subject: [PATCH 12/17] test: cover editor validation report behaviour --- .../Tests/Editor/ValidationReportTests.cs | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 Assets/_ZoneUA/Tests/Editor/ValidationReportTests.cs diff --git a/Assets/_ZoneUA/Tests/Editor/ValidationReportTests.cs b/Assets/_ZoneUA/Tests/Editor/ValidationReportTests.cs new file mode 100644 index 0000000..fd083e4 --- /dev/null +++ b/Assets/_ZoneUA/Tests/Editor/ValidationReportTests.cs @@ -0,0 +1,51 @@ +using NUnit.Framework; + +namespace ZoneUA.EditorValidation.Tests +{ + public sealed class ValidationReportTests + { + [Test] + public void EmptyReportIsValid() + { + var report = new ValidationReport(); + + Assert.That(report.IsValid, Is.True); + Assert.That(report.ErrorCount, Is.Zero); + Assert.That(report.WarningCount, Is.Zero); + } + + [Test] + public void ErrorMakesReportInvalid() + { + var report = new ValidationReport(); + + report.Add(ValidationSeverity.Error, "TEST_ERROR", "Failure"); + + Assert.That(report.IsValid, Is.False); + Assert.That(report.ErrorCount, Is.EqualTo(1)); + } + + [Test] + public void WarningDoesNotInvalidateReport() + { + var report = new ValidationReport(); + + report.Add(ValidationSeverity.Warning, "TEST_WARNING", "Warning"); + + Assert.That(report.IsValid, Is.True); + Assert.That(report.WarningCount, Is.EqualTo(1)); + } + + [Test] + public void IssuePreservesAssetPathAndCode() + { + var report = new ValidationReport(); + + report.Add(ValidationSeverity.Info, "TEST_INFO", "Information", "Assets/Test.asset"); + + Assert.That(report.issues, Has.Count.EqualTo(1)); + Assert.That(report.issues[0].code, Is.EqualTo("TEST_INFO")); + Assert.That(report.issues[0].assetPath, Is.EqualTo("Assets/Test.asset")); + } + } +} From 6f4d0fc2a95ccf2f37909ba28dd56056ebeefc66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9D=D0=B0=D0=B7=D0=B0=D1=80?= Date: Mon, 27 Jul 2026 20:29:17 +0300 Subject: [PATCH 13/17] chore: add validation report test metadata --- .../Tests/Editor/ValidationReportTests.cs.meta | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 Assets/_ZoneUA/Tests/Editor/ValidationReportTests.cs.meta diff --git a/Assets/_ZoneUA/Tests/Editor/ValidationReportTests.cs.meta b/Assets/_ZoneUA/Tests/Editor/ValidationReportTests.cs.meta new file mode 100644 index 0000000..a329933 --- /dev/null +++ b/Assets/_ZoneUA/Tests/Editor/ValidationReportTests.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 430c6801589a4a50b2abe2b40ab31192 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: From 0c228c260ebc51f5d0c57154c17a2e22bb1ad773 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9D=D0=B0=D0=B7=D0=B0=D1=80?= Date: Mon, 27 Jul 2026 20:29:41 +0300 Subject: [PATCH 14/17] docs: add editor validation and CI guide --- Docs/EDITOR_VALIDATION_CI.md | 113 +++++++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 Docs/EDITOR_VALIDATION_CI.md diff --git a/Docs/EDITOR_VALIDATION_CI.md b/Docs/EDITOR_VALIDATION_CI.md new file mode 100644 index 0000000..187e4fb --- /dev/null +++ b/Docs/EDITOR_VALIDATION_CI.md @@ -0,0 +1,113 @@ +# Editor validation and CI + +This module adds two complementary validation layers: + +1. Fast repository checks that run without Unity. +2. Unity Editor validation that understands prefabs, ScriptableObjects and build preprocessing. + +## Unity Editor menu + +Open: + +`Zone UA -> Validation -> Validate Project` + +The validation window reports errors and warnings and can select affected assets. + +For a smaller migration pass, select one or more prefabs and run: + +`Zone UA -> Validation -> Validate Selected Prefabs` + +## Checks performed in Unity + +The project validator checks: + +- missing `.meta` files; +- missing or duplicate GUIDs; +- invalid or duplicate asmdef names; +- required Player input map and actions; +- empty Build Settings scene list; +- missing world fallback biome or biome list; +- empty definition IDs; +- biomes without terrain presentation prefabs; +- NPC prefabs without `Health`, `Death` or `FactionMember`; +- weapon prefabs without `Weapon`; +- player prefabs with an unassigned `PlayerInputRouter.actions` field; +- scene metadata. + +Errors block builds through `IPreprocessBuildWithReport`. Warnings remain visible but do not block a build. + +A JSON report is written to: + +`Logs/ZoneUAValidation.json` + +## Batch mode + +Run project validation from a Unity installation with: + +```bash +Unity \ + -batchmode \ + -nographics \ + -quit \ + -projectPath . \ + -executeMethod ZoneUA.EditorValidation.ZoneUAValidationCli.Run \ + -logFile Logs/ZoneUAValidation.log +``` + +The process throws when validation errors exist. + +## Repository validation + +Run locally without Unity: + +```bash +python scripts/validate_unity_repo.py +``` + +This verifies: + +- `.meta` coverage; +- duplicate GUIDs; +- asmdef JSON and unique names; +- Input Actions JSON and required actions; +- Input System package declaration; +- project-version metadata. + +The current repository still declares Unity `2022.2.8f1`. This is reported as a warning until the project is opened and saved in the target Unity `6000.5.5f1` editor. Do not manually invent the `m_EditorVersionWithRevision` value. + +## GitHub Actions + +Workflow: + +`.github/workflows/unity-validation.yml` + +The `repository-integrity` job runs on every pull request and on pushes to `master`. It does not need a Unity licence. + +Unity EditMode tests are opt-in until the repository has working Unity CI credentials. Configure: + +Repository variable: + +- `RUN_UNITY_TESTS=true` +- `UNITY_VERSION=6000.5.5f1` + +Repository secrets required by GameCI: + +- `UNITY_LICENSE` +- `UNITY_EMAIL` +- `UNITY_PASSWORD` + +After configuration, the workflow restores the Unity `Library` cache, runs all EditMode tests and uploads test artefacts. + +## Recommended merge gate + +Require the following check immediately: + +- `Repository integrity` + +Require the following after GameCI credentials and the migrated Unity project version are committed: + +- `Unity EditMode tests` + +## Current limitations + +The validator intentionally does not modify scenes or prefabs automatically. It identifies unsafe setup while preserving serialized references. Visual world-generation quality, dual-grid transitions, animation bindings and Play Mode combat behaviour still require smoke testing in Unity. From 0db68f34d765cede9e306e0c751ae05902d7b9b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9D=D0=B0=D0=B7=D0=B0=D1=80?= Date: Mon, 27 Jul 2026 20:29:49 +0300 Subject: [PATCH 15/17] chore: add editor validation documentation metadata --- Docs/EDITOR_VALIDATION_CI.md.meta | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 Docs/EDITOR_VALIDATION_CI.md.meta diff --git a/Docs/EDITOR_VALIDATION_CI.md.meta b/Docs/EDITOR_VALIDATION_CI.md.meta new file mode 100644 index 0000000..a76b23e --- /dev/null +++ b/Docs/EDITOR_VALIDATION_CI.md.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 4b7c2f77c24c4f97b709fd7812b2f7b3 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: From 3b424ab8b006f5d15bdf8e8f5be8b044f79cbc1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9D=D0=B0=D0=B7=D0=B0=D1=80?= Date: Mon, 27 Jul 2026 20:32:59 +0300 Subject: [PATCH 16/17] tmp --- Docs/_placeholder.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 Docs/_placeholder.txt diff --git a/Docs/_placeholder.txt b/Docs/_placeholder.txt new file mode 100644 index 0000000..c1b0730 --- /dev/null +++ b/Docs/_placeholder.txt @@ -0,0 +1 @@ +x \ No newline at end of file From c5437c351f0fdf756ebeb20da34b0bc8156c40a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9D=D0=B0=D0=B7=D0=B0=D1=80?= Date: Mon, 27 Jul 2026 20:33:17 +0300 Subject: [PATCH 17/17] chore: remove accidental placeholder --- Docs/_placeholder.txt | 1 - 1 file changed, 1 deletion(-) delete mode 100644 Docs/_placeholder.txt diff --git a/Docs/_placeholder.txt b/Docs/_placeholder.txt deleted file mode 100644 index c1b0730..0000000 --- a/Docs/_placeholder.txt +++ /dev/null @@ -1 +0,0 @@ -x \ No newline at end of file