unity-devkit 0.3.2__tar.gz → 0.3.3.dev246__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {unity_devkit-0.3.2 → unity_devkit-0.3.3.dev246}/PKG-INFO +1 -1
- {unity_devkit-0.3.2 → unity_devkit-0.3.3.dev246}/pyproject.toml +1 -1
- {unity_devkit-0.3.2 → unity_devkit-0.3.3.dev246}/src/unity_devkit/player_build.py +43 -0
- {unity_devkit-0.3.2 → unity_devkit-0.3.3.dev246}/tests/test_run_unity_batchmode.py +62 -0
- {unity_devkit-0.3.2 → unity_devkit-0.3.3.dev246}/.gitignore +0 -0
- {unity_devkit-0.3.2 → unity_devkit-0.3.3.dev246}/src/unity_devkit/__init__.py +0 -0
- {unity_devkit-0.3.2 → unity_devkit-0.3.3.dev246}/src/unity_devkit/build_unity.py +0 -0
- {unity_devkit-0.3.2 → unity_devkit-0.3.3.dev246}/src/unity_devkit/compile_check_unity.py +0 -0
- {unity_devkit-0.3.2 → unity_devkit-0.3.3.dev246}/src/unity_devkit/identity.py +0 -0
- {unity_devkit-0.3.2 → unity_devkit-0.3.3.dev246}/src/unity_devkit/install.py +0 -0
- {unity_devkit-0.3.2 → unity_devkit-0.3.3.dev246}/src/unity_devkit/license.py +0 -0
- {unity_devkit-0.3.2 → unity_devkit-0.3.3.dev246}/src/unity_devkit/license_restore.py +0 -0
- {unity_devkit-0.3.2 → unity_devkit-0.3.3.dev246}/src/unity_devkit/lock_unity.py +0 -0
- {unity_devkit-0.3.2 → unity_devkit-0.3.3.dev246}/src/unity_devkit/matrix.py +0 -0
- {unity_devkit-0.3.2 → unity_devkit-0.3.3.dev246}/src/unity_devkit/projects.py +0 -0
- {unity_devkit-0.3.2 → unity_devkit-0.3.3.dev246}/src/unity_devkit/py.typed +0 -0
- {unity_devkit-0.3.2 → unity_devkit-0.3.3.dev246}/src/unity_devkit/test_unity.py +0 -0
- {unity_devkit-0.3.2 → unity_devkit-0.3.3.dev246}/src/unity_devkit/upm_cache.py +0 -0
- {unity_devkit-0.3.2 → unity_devkit-0.3.3.dev246}/tests/test_build_player.py +0 -0
- {unity_devkit-0.3.2 → unity_devkit-0.3.3.dev246}/tests/test_identity.py +0 -0
- {unity_devkit-0.3.2 → unity_devkit-0.3.3.dev246}/tests/test_matrix.py +0 -0
- {unity_devkit-0.3.2 → unity_devkit-0.3.3.dev246}/tests/test_prepare.py +0 -0
- {unity_devkit-0.3.2 → unity_devkit-0.3.3.dev246}/tests/test_projects.py +0 -0
- {unity_devkit-0.3.2 → unity_devkit-0.3.3.dev246}/tests/test_upm_cache.py +0 -0
|
@@ -43,6 +43,11 @@ DOTNET_SDK_VERSION = "8.0.421"
|
|
|
43
43
|
# are discovered.
|
|
44
44
|
QUIET_FAILURE_SIGNATURES = ("An error occurred while resolving packages:",)
|
|
45
45
|
|
|
46
|
+
COMPILE_ERROR_PATTERN = re.compile(
|
|
47
|
+
r"^(?P<file>.+?)\((?P<line>\d+),(?P<column>\d+)\): error (?P<code>CS\d+): (?P<message>.+)$"
|
|
48
|
+
)
|
|
49
|
+
ANNOTATION_LIMIT = 10
|
|
50
|
+
|
|
46
51
|
|
|
47
52
|
def run_unity_batchmode(
|
|
48
53
|
project_path: Path,
|
|
@@ -100,14 +105,52 @@ def run_unity_batchmode(
|
|
|
100
105
|
break
|
|
101
106
|
|
|
102
107
|
if failure_block is not None:
|
|
108
|
+
report_compile_errors(lines)
|
|
103
109
|
raise SystemExit(f"Unity reported a silent failure (exit code {returncode}):\n{failure_block}")
|
|
104
110
|
if returncode != 0 and strict_exit:
|
|
111
|
+
report_compile_errors(lines)
|
|
105
112
|
raise SystemExit(f"Unity exited {returncode}; full editor log at {log_path}")
|
|
106
113
|
if returncode != 0:
|
|
107
114
|
print(f" WARNING: Unity exited {returncode}; no package-manager failure found — full editor log at {log_path}")
|
|
108
115
|
return log_path
|
|
109
116
|
|
|
110
117
|
|
|
118
|
+
def report_compile_errors(lines: list[str]) -> None:
|
|
119
|
+
counts: dict[tuple[str, int, str, str], int] = {}
|
|
120
|
+
for line in lines:
|
|
121
|
+
if line.startswith("[Script Updater]"):
|
|
122
|
+
continue
|
|
123
|
+
match = COMPILE_ERROR_PATTERN.match(line)
|
|
124
|
+
if match is None:
|
|
125
|
+
continue
|
|
126
|
+
key = (match["file"], int(match["line"]), match["code"], match["message"].strip())
|
|
127
|
+
counts[key] = counts.get(key, 0) + 1
|
|
128
|
+
if not counts:
|
|
129
|
+
return
|
|
130
|
+
|
|
131
|
+
print(f"Unity compile errors ({len(counts)} distinct):", file=sys.stderr)
|
|
132
|
+
for (file, line_number, code, message), count in counts.items():
|
|
133
|
+
print(f" {code} x{count} {file}:{line_number} {message}", file=sys.stderr)
|
|
134
|
+
|
|
135
|
+
if os.environ.get("GITHUB_ACTIONS") != "true":
|
|
136
|
+
return
|
|
137
|
+
for (file, line_number, code, message), count in list(counts.items())[:ANNOTATION_LIMIT]:
|
|
138
|
+
title = escape_annotation_property(f"{code} x{count}")
|
|
139
|
+
body = escape_annotation_data(f"{code}: {message}")
|
|
140
|
+
print(f"::error file={escape_annotation_property(file)},line={line_number},title={title}::{body}")
|
|
141
|
+
beyond_limit = len(counts) - ANNOTATION_LIMIT
|
|
142
|
+
if beyond_limit > 0:
|
|
143
|
+
print(f"::error::{escape_annotation_data(f'...and {beyond_limit} more distinct compile errors')}")
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
def escape_annotation_data(value: str) -> str:
|
|
147
|
+
return value.replace("%", "%25").replace("\r", "%0D").replace("\n", "%0A")
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
def escape_annotation_property(value: str) -> str:
|
|
151
|
+
return escape_annotation_data(value).replace(":", "%3A").replace(",", "%2C")
|
|
152
|
+
|
|
153
|
+
|
|
111
154
|
def read_editor_version(project_path: Path) -> str:
|
|
112
155
|
version_file = project_path / "ProjectSettings" / "ProjectVersion.txt"
|
|
113
156
|
version = editor_version(project_path)
|
|
@@ -72,3 +72,65 @@ def test_package_manager_signature_still_fails(tmp_path: Path, monkeypatch: pyte
|
|
|
72
72
|
|
|
73
73
|
with pytest.raises(SystemExit, match="silent failure"):
|
|
74
74
|
player_build.run_unity_batchmode(tmp_path)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def test_compile_error_dedups_into_one_annotation(
|
|
78
|
+
tmp_path: Path, monkeypatch: pytest.MonkeyPatch, capfd: pytest.CaptureFixture[str]
|
|
79
|
+
) -> None:
|
|
80
|
+
line = "Assets/Foo.cs(12,34): error CS0246: type not found"
|
|
81
|
+
patch_editor(monkeypatch, write_fake_editor(tmp_path, f"{line}\n{line}", 0))
|
|
82
|
+
monkeypatch.setenv("GITHUB_ACTIONS", "true")
|
|
83
|
+
monkeypatch.delenv("GITHUB_STEP_SUMMARY", raising=False)
|
|
84
|
+
|
|
85
|
+
with pytest.raises(SystemExit, match="silent failure"):
|
|
86
|
+
player_build.run_unity_batchmode(tmp_path, extra_failure_signatures=("error CS",))
|
|
87
|
+
|
|
88
|
+
captured = capfd.readouterr()
|
|
89
|
+
assert captured.out.count("::error file=Assets/Foo.cs,line=12") == 1
|
|
90
|
+
assert "title=CS0246 x2" in captured.out
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def test_compile_error_reports_distinct_list_locally(
|
|
94
|
+
tmp_path: Path, monkeypatch: pytest.MonkeyPatch, capfd: pytest.CaptureFixture[str]
|
|
95
|
+
) -> None:
|
|
96
|
+
patch_editor(monkeypatch, write_fake_editor(tmp_path, "Assets/Foo.cs(12,34): error CS0246: type not found", 0))
|
|
97
|
+
monkeypatch.delenv("GITHUB_ACTIONS", raising=False)
|
|
98
|
+
|
|
99
|
+
with pytest.raises(SystemExit, match="silent failure"):
|
|
100
|
+
player_build.run_unity_batchmode(tmp_path, extra_failure_signatures=("error CS",))
|
|
101
|
+
|
|
102
|
+
captured = capfd.readouterr()
|
|
103
|
+
assert "CS0246" in captured.err
|
|
104
|
+
assert "::error" not in captured.out
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def test_script_updater_noise_not_annotated(
|
|
108
|
+
tmp_path: Path, monkeypatch: pytest.MonkeyPatch, capfd: pytest.CaptureFixture[str]
|
|
109
|
+
) -> None:
|
|
110
|
+
noise = (
|
|
111
|
+
"[Script Updater] Library/PackageCache/com.cysharp.r3/Runtime/UnityXR.cs(9,89): error CS0246: type not found"
|
|
112
|
+
)
|
|
113
|
+
patch_editor(monkeypatch, write_fake_editor(tmp_path, noise, 0))
|
|
114
|
+
monkeypatch.setenv("GITHUB_ACTIONS", "true")
|
|
115
|
+
monkeypatch.delenv("GITHUB_STEP_SUMMARY", raising=False)
|
|
116
|
+
|
|
117
|
+
player_build.run_unity_batchmode(tmp_path, extra_failure_signatures=("error CS",))
|
|
118
|
+
|
|
119
|
+
captured = capfd.readouterr()
|
|
120
|
+
assert "::error" not in captured.out
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
def test_annotations_capped_at_ten(
|
|
124
|
+
tmp_path: Path, monkeypatch: pytest.MonkeyPatch, capfd: pytest.CaptureFixture[str]
|
|
125
|
+
) -> None:
|
|
126
|
+
log = "\n".join(f"Assets/F{i}.cs({i},1): error CS0246: gone" for i in range(1, 15))
|
|
127
|
+
patch_editor(monkeypatch, write_fake_editor(tmp_path, log, 0))
|
|
128
|
+
monkeypatch.setenv("GITHUB_ACTIONS", "true")
|
|
129
|
+
monkeypatch.delenv("GITHUB_STEP_SUMMARY", raising=False)
|
|
130
|
+
|
|
131
|
+
with pytest.raises(SystemExit, match="silent failure"):
|
|
132
|
+
player_build.run_unity_batchmode(tmp_path, extra_failure_signatures=("error CS",))
|
|
133
|
+
|
|
134
|
+
captured = capfd.readouterr()
|
|
135
|
+
assert captured.out.count("::error file=") == 10
|
|
136
|
+
assert "...and 4 more distinct compile errors" in captured.out
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|