4040 unity : 2021.3.45f2
4141 changeset : 88f88f591b2e
4242 runner : [self-hosted, macOS, ARM64]
43+ - target : StandaloneWindows64
44+ backend : IL2CPP
45+ unity : 6000.4.0f1
46+ changeset : 8cf496087c8f
47+ runner : [self-hosted, Windows, X64]
48+ - target : StandaloneWindows64
49+ backend : Mono2x
50+ unity : 6000.4.0f1
51+ changeset : 8cf496087c8f
52+ runner : [self-hosted, Windows, X64]
53+ - target : StandaloneOSX
54+ backend : IL2CPP
55+ unity : 6000.4.0f1
56+ changeset : 8cf496087c8f
57+ runner : [self-hosted, macOS, ARM64]
58+ - target : StandaloneOSX
59+ backend : Mono2x
60+ unity : 6000.4.0f1
61+ changeset : 8cf496087c8f
62+ runner : [self-hosted, macOS, ARM64]
4363 runs-on : ${{ matrix.runner }}
4464 timeout-minutes : 60
4565
@@ -243,13 +263,19 @@ jobs:
243263 run : |
244264 set -euo pipefail
245265 mkdir -p artifacts
266+ # Tee Unity's stdout to artifacts/unity.log so the annotation step has a
267+ # file to scan, while still streaming progress to the job log. pipefail
268+ # propagates Unity's exit code through tee. The annotation step reads this
269+ # file in-job; the actions/upload-artifact step below also uploads it so
270+ # compile failures retain a full post-mortem (annotations are matched-line
271+ # only and drop IL2CPP linker output, build config dumps, etc).
246272 "$UNITY_PATH" \
247273 -batchmode -nographics \
248274 -projectPath examples/audience \
249275 -runTests \
250276 -testPlatform ${{ matrix.target }} \
251277 -testResults "$(pwd)/artifacts/test-results.xml" \
252- -logFile -
278+ -logFile - 2>&1 | tee "$(pwd)/artifacts/unity.log"
253279
254280 - name : Run PlayMode tests (Windows)
255281 if : runner.os == 'Windows'
@@ -283,6 +309,51 @@ jobs:
283309 run : |
284310 git config --global --add safe.directory $env:GITHUB_WORKSPACE.Replace('\','/')
285311
312+ - name : Surface Unity compile errors as annotations (macOS)
313+ if : always() && runner.os == 'macOS'
314+ shell : bash
315+ run : |
316+ set -uo pipefail
317+ # Unity writes compile errors as 'error CS####:' or 'Compilation failed: <n>'.
318+ # When a cell fails compile (vs fails a test), the test-results.xml is empty
319+ # and the only signal otherwise is the artifact zip. Promote those lines to
320+ # ::error:: annotations so the PR UI shows the cause inline.
321+ LOG_FILE="artifacts/unity.log"
322+ if [ ! -f "$LOG_FILE" ]; then
323+ echo "::notice::No Unity log file at $LOG_FILE."
324+ exit 0
325+ fi
326+ # `|| true` guards the success path: with `pipefail`, grep exits 1 when no
327+ # matches (the clean-build case), which would otherwise propagate as the
328+ # step's exit code and falsely mark every green cell red.
329+ grep -E '(error CS[0-9]+:|Compilation failed:)' "$LOG_FILE" | sort -u | while IFS= read -r line; do
330+ trimmed="${line#"${line%%[![:space:]]*}"}"
331+ # Sanitize '::' so log lines containing workflow commands (e.g. ::endgroup::)
332+ # cannot terminate the annotation early or inject other commands.
333+ sanitized="${trimmed//::/%3A%3A}"
334+ echo "::error::$sanitized"
335+ done || true
336+
337+ - name : Surface Unity compile errors as annotations (Windows)
338+ if : always() && runner.os == 'Windows'
339+ shell : pwsh
340+ run : |
341+ $logFile = "artifacts\unity.log"
342+ if (-not (Test-Path $logFile)) {
343+ Write-Host "::notice::No Unity log file at $logFile."
344+ exit 0
345+ }
346+ Get-Content $logFile |
347+ Select-String -Pattern '(error CS\d+:|Compilation failed:)' |
348+ ForEach-Object { $_.Line.Trim() } |
349+ Sort-Object -Unique |
350+ ForEach-Object {
351+ # Sanitize '::' so log lines containing workflow commands cannot
352+ # terminate the annotation early or inject other commands.
353+ $sanitized = $_ -replace '::', '%3A%3A'
354+ Write-Host "::error::$sanitized"
355+ }
356+
286357 - name : Publish test report
287358 uses : dorny/test-reporter@v3
288359 if : always()
@@ -298,4 +369,5 @@ jobs:
298369 name : playmode-${{ matrix.backend }}-${{ matrix.target }}-${{ matrix.unity }}
299370 path : |
300371 artifacts/test-results.xml
372+ artifacts/unity.log
301373 examples/audience/Logs/**
0 commit comments