Skip to content

fix: Improve compile and pause-point skill guidance for AI agents #1396

fix: Improve compile and pause-point skill guidance for AI agents

fix: Improve compile and pause-point skill guidance for AI agents #1396

name: Unity Compile Check
# This job is a required status check, so it must report exactly one
# "Compile Check (Linux)" result on every PR. Path filters at the workflow
# level cannot express that: a `paths`/`paths-ignore` pair both fire on a PR
# that mixes C# and non-C# files, producing duplicate required checks. Instead
# the workflow always runs and a change-detection step decides whether to do
# the real Unity work or report success immediately.
on:
pull_request:
branches: [ main, v3-beta ]
workflow_dispatch:
permissions:
checks: write
contents: read
jobs:
compile-check:
name: Compile Check (Linux)
runs-on: ubuntu-latest
# Dependabot PRs cannot access repository secrets (UNITY_LICENSE etc.)
env:
HAS_UNITY_LICENSE: ${{ secrets.UNITY_LICENSE != '' }}
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
with:
# Full history is required so the change-detection step can diff the
# PR head against its base.
fetch-depth: 0
lfs: true
- name: Detect C# changes
id: changes
run: |
BASE_SHA="${{ github.event.pull_request.base.sha }}"
HEAD_SHA="${{ github.event.pull_request.head.sha }}"
# workflow_dispatch has no PR context, so run the full check.
if [ -z "$BASE_SHA" ] || [ -z "$HEAD_SHA" ]; then
echo "csharp=true" >> "$GITHUB_OUTPUT"
exit 0
fi
CHANGED=$(git diff --name-only "$BASE_SHA" "$HEAD_SHA")
echo "=== Changed files ==="
echo "$CHANGED"
if echo "$CHANGED" | grep -qE '^(Packages/src/Editor/.*\.cs|Packages/src/Runtime/.*\.cs|Assets/.*\.cs|tests/.*\.cs|tests/.*\.csproj|Packages/.*\.asmdef|Assets/.*\.asmdef|Packages/manifest\.json|Packages/packages-lock\.json|\.github/workflows/unity-compile-check-and-test-runner\.yml)$'; then
echo "csharp=true" >> "$GITHUB_OUTPUT"
else
echo "csharp=false" >> "$GITHUB_OUTPUT"
fi
- name: Skip notice
if: steps.changes.outputs.csharp != 'true'
run: echo "No C# changes detected; compile check is satisfied without running Unity."
- name: Setup .NET
if: steps.changes.outputs.csharp == 'true'
uses: actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7
with:
dotnet-version: 10.0.x
- name: Run concurrency unit tests
if: steps.changes.outputs.csharp == 'true'
run: |
dotnet test tests/DynamicCodeExecutionScheduler.UnitTests/DynamicCodeExecutionScheduler.UnitTests.csproj --configuration Release
dotnet test tests/SharedRoslynCompilerWorker.UnitTests/SharedRoslynCompilerWorker.UnitTests.csproj --configuration Release
dotnet test tests/OutputFileRetention.UnitTests/OutputFileRetention.UnitTests.csproj --configuration Release
- name: Cache Library folder
if: env.HAS_UNITY_LICENSE == 'true'
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae
with:
path: Library
key: Library-2022.3.62f1-${{ hashFiles('Packages/src/**/*.cs', 'Assets/**/*.cs', 'Packages/manifest.json', 'Packages/packages-lock.json') }}
restore-keys: |
Library-2022.3.62f1-
- name: Compile Unity project
if: steps.changes.outputs.csharp == 'true' && env.HAS_UNITY_LICENSE == 'true'
id: compile
uses: game-ci/unity-builder@1d4ee0697f193f54668e98961d79907911f4b4f2
timeout-minutes: 30
env:
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
with:
unityVersion: 2022.3.62f1
targetPlatform: StandaloneLinux64
buildMethod: ''
allowDirtyBuild: true
continue-on-error: true
- name: Check for compile errors and warnings
if: steps.changes.outputs.csharp == 'true' && env.HAS_UNITY_LICENSE == 'true'
run: |
LOG_FILE=$(find . -name "*.log" -path "*/build/*" -o -name "Editor.log" 2>/dev/null | head -1)
if [ -z "$LOG_FILE" ]; then
echo "No Unity log file found, checking artifacts..."
LOG_FILE="artifacts/unity-build.log"
fi
echo "=== Checking Unity compilation output ==="
ERROR_COUNT=0
WARNING_COUNT=0
if [ -f "$LOG_FILE" ]; then
echo "Analyzing log file: $LOG_FILE"
# Count errors (CS errors from compiler)
ERROR_COUNT=$(grep -c "error CS[0-9]*:" "$LOG_FILE" 2>/dev/null || echo "0")
# Count warnings (CS warnings from compiler, excluding specific noise)
WARNING_COUNT=$(grep -c "warning CS[0-9]*:" "$LOG_FILE" 2>/dev/null || echo "0")
echo ""
echo "=== Compilation Results ==="
echo "Errors: $ERROR_COUNT"
echo "Warnings: $WARNING_COUNT"
echo ""
if [ "$ERROR_COUNT" -gt 0 ]; then
echo "::error::Found $ERROR_COUNT compile error(s)"
echo ""
echo "=== Errors ==="
grep "error CS[0-9]*:" "$LOG_FILE" | head -20
exit 1
fi
if [ "$WARNING_COUNT" -gt 0 ]; then
echo "::warning::Found $WARNING_COUNT compile warning(s)"
echo ""
echo "=== Warnings ==="
grep "warning CS[0-9]*:" "$LOG_FILE" | head -20
exit 1
fi
echo "✅ No compile errors or warnings found!"
else
echo "::warning::Could not find Unity log file for analysis"
# Fall back to checking if build step failed
if [ "${{ steps.compile.outcome }}" == "failure" ]; then
echo "::error::Unity compilation failed"
exit 1
fi
fi