diff --git a/.github/instructions/verification.md b/.github/instructions/verification.md index 3d603ca8..8e77c394 100644 --- a/.github/instructions/verification.md +++ b/.github/instructions/verification.md @@ -11,7 +11,7 @@ When you push commits to a work branch the **`Compile Check`** workflow (`.github/workflows/compile-check.yml`) runs automatically and verifies: 1. All SDK C# code compiles without errors (including Samples). -2. All editor-mode tests in `Tests/` pass. +2. The configured Unity **editmode** tests pass (see the workflow for exact coverage). ### Workflow to follow after each batch of commits @@ -45,6 +45,8 @@ Fix the reported errors and push again. 1. Unity is installed locally (any Unity **2019.2+** version works; best to match the project's minimum version in `package.json`). 2. You have a `unity-dev-settings.json` at the repo root (gitignored). +3. Python 3 is installed and available on your `PATH` as `python3` (used by the + local verification scripts to parse `unity-dev-settings.json`). ### One-time setup diff --git a/.github/scripts/verify-compilation.ps1 b/.github/scripts/verify-compilation.ps1 index 2f4527d4..663e4644 100644 --- a/.github/scripts/verify-compilation.ps1 +++ b/.github/scripts/verify-compilation.ps1 @@ -194,33 +194,42 @@ Write-Step "-----------------------------------" Write-Step "" # Determine outcome from log content: -# - Any "error CS####" line => compilation failed -# - "Tundra build success" found => compilation succeeded (Unity may still exit non-zero +# - Any "error CS####" line => compilation failed +# - "Tundra build failed" marker => compilation failed +# - No compiler errors and Unity exit code 0 => compilation succeeded (even if no Tundra marker) +# - "Tundra build success" found => compilation succeeded (Unity may still exit non-zero # due to unrelated project setup issues unrelated to the SDK) -# - Neither found => fall back to Unity exit code if ($compileErrors.Count -gt 0) { Write-Fail "COMPILATION FAILED ($($compileErrors.Count) compiler error(s))" Write-Step "Full log: $LogFile" exit 1 } +elseif ($tundraFailure) { + # Explicit Tundra failure should be treated as a hard failure regardless of exit code + if ($logLines) { + $logLines | Select-String -Pattern "error CS\d+|Scripts have compiler errors|error:" | Select-String -NotMatch "Licensing::" | + ForEach-Object { Write-Host $_.Line } + } + Write-Fail "COMPILATION FAILED (Tundra build failed)" + Write-Step "Full log: $LogFile" + exit 1 +} +elseif ($unityExitCode -eq 0) { + # Treat a clean Unity exit with no compiler errors as success, even if we did not see a Tundra marker + Write-Ok "COMPILATION SUCCEEDED" +} elseif ($tundraSuccess) { Write-Ok "COMPILATION SUCCEEDED" - if ($unityExitCode -ne 0) { - Write-Warn "Note: Unity exited with code $unityExitCode after compilation (likely unrelated project setup - not an SDK issue)." - } + Write-Warn "Note: Unity exited with code $unityExitCode after compilation (likely unrelated project setup - not an SDK issue)." } -elseif ($tundraFailure -or $unityExitCode -ne 0) { - # Print any error/warning lines we can find to help diagnose the issue +else { + # Non-zero Unity exit code with no clear Tundra success/failure marker; surface diagnostics and fail if ($logLines) { $logLines | Select-String -Pattern "error CS\d+|Scripts have compiler errors|error:" | Select-String -NotMatch "Licensing::" | ForEach-Object { Write-Host $_.Line } } - $reason = if ($tundraFailure) { "Tundra build failed" } else { "exit code: $unityExitCode" } + $reason = "exit code: $unityExitCode" Write-Fail "COMPILATION FAILED ($reason)" Write-Step "Full log: $LogFile" exit 1 } -else { - Write-Warn "UNKNOWN: could not determine compilation result from log. Check: $LogFile" - exit 1 -} diff --git a/.github/scripts/verify-compilation.sh b/.github/scripts/verify-compilation.sh index ed013dee..ace83874 100644 --- a/.github/scripts/verify-compilation.sh +++ b/.github/scripts/verify-compilation.sh @@ -35,8 +35,8 @@ if [[ -z "$UNITY_EXE" ]]; then echo -e "${RED}ERROR:${NC} 'unity_executable' is empty in unity-dev-settings.json." exit 1 fi -if [[ ! -f "$UNITY_EXE" && ! -x "$UNITY_EXE" ]]; then - echo -e "${RED}ERROR:${NC} Unity executable not found: $UNITY_EXE" +if [[ ! -f "$UNITY_EXE" || ! -x "$UNITY_EXE" ]]; then + echo -e "${RED}ERROR:${NC} Unity executable not found or not executable: $UNITY_EXE" exit 1 fi @@ -141,18 +141,22 @@ if [[ -n "$COMPILE_ERRORS" ]]; then ERROR_COUNT=$(echo "$COMPILE_ERRORS" | wc -l | tr -d ' ') echo -e "${RED}COMPILATION FAILED${NC} (${ERROR_COUNT} compiler error(s))" exit 1 +elif [[ "$TUNDRA_FAILURE" -gt 0 ]]; then + # Explicit Tundra failure is a hard fail regardless of exit code + echo "$LOG_CONTENT" | grep -E "error CS[0-9]+|Scripts have compiler errors|error:" | grep -v "Licensing::" || true + echo -e "${RED}COMPILATION FAILED${NC} (Tundra build failed)" + exit 1 elif [[ "$TUNDRA_SUCCESS" -gt 0 ]]; then echo -e "${GREEN}COMPILATION SUCCEEDED${NC}" if [[ $UNITY_EXIT_CODE -ne 0 ]]; then echo -e "${YELLOW}Note: Unity exited with code $UNITY_EXIT_CODE after compilation (likely unrelated project setup - not an SDK issue).${NC}" fi -elif [[ "$TUNDRA_FAILURE" -gt 0 || $UNITY_EXIT_CODE -ne 0 ]]; then - # Print any diagnosable lines - echo "$LOG_CONTENT" | grep -E "error CS[0-9]+|Scripts have compiler errors|error:" | grep -v "Licensing::" || true - REASON=$( [[ "$TUNDRA_FAILURE" -gt 0 ]] && echo "Tundra build failed" || echo "exit code: $UNITY_EXIT_CODE" ) - echo -e "${RED}COMPILATION FAILED${NC} ($REASON)" - exit 1 +elif [[ $UNITY_EXIT_CODE -eq 0 ]]; then + # No Tundra marker but Unity exited cleanly with no compiler errors — treat as success + echo -e "${GREEN}COMPILATION SUCCEEDED${NC}" else - echo -e "${YELLOW}UNKNOWN:${NC} could not determine compilation result from log." + # Non-zero exit, no Tundra success, no compiler errors extracted — surface diagnostics + echo "$LOG_CONTENT" | grep -E "error CS[0-9]+|Scripts have compiler errors|error:" | grep -v "Licensing::" || true + echo -e "${RED}COMPILATION FAILED${NC} (exit code: $UNITY_EXIT_CODE)" exit 1 fi diff --git a/.github/workflows/compile-check.yml b/.github/workflows/compile-check.yml index ec3df885..1a8c9c7a 100644 --- a/.github/workflows/compile-check.yml +++ b/.github/workflows/compile-check.yml @@ -27,6 +27,8 @@ jobs: name: Verify SDK compiles runs-on: ubuntu-latest timeout-minutes: 10 + env: + UNITY_VERSION: ${{ github.event.inputs.unityVersion || vars.AGENT_CHECK_UNITY_VERSION || '2022.3.22f1' }} steps: - name: Checkout SDK @@ -60,7 +62,7 @@ jobs: uses: actions/cache@v4 with: path: TestProject/Library - key: Library-compile-check-${{ inputs.unityVersion || vars.AGENT_CHECK_UNITY_VERSION || '2022.3.22f1' }} + key: Library-compile-check-${{ env.UNITY_VERSION }} restore-keys: | Library-compile-check- @@ -74,10 +76,10 @@ jobs: UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }} with: projectPath: TestProject - unityVersion: ${{ inputs.unityVersion || vars.AGENT_CHECK_UNITY_VERSION || '2022.3.22f1' }} + unityVersion: ${{ env.UNITY_VERSION }} testMode: editmode githubToken: ${{ secrets.GITHUB_TOKEN }} - checkName: Compile Check (${{ inputs.unityVersion || vars.AGENT_CHECK_UNITY_VERSION || '2022.3.22f1' }}) + checkName: Compile Check (${{ env.UNITY_VERSION }}) - name: Report compilation errors if: always()