-
Notifications
You must be signed in to change notification settings - Fork 3
118 lines (101 loc) · 4.1 KB
/
Copy pathunity-test.yml
File metadata and controls
118 lines (101 loc) · 4.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
name: Unity Tests
on:
push:
branches: [ main, 'dev-ci' ]
workflow_dispatch:
env:
BYPASS_UNITY_INIT: $false # Set to $true to bypass initialization check if needed
jobs:
run-tests:
runs-on: self-hosted
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Clean Python tool cache
run: |
$pythonPath = Join-Path $env:RUNNER_TOOL_CACHE "Python"
if (Test-Path $pythonPath) {
Write-Host "Cleaning corrupted Python tool cache..."
Remove-Item -Path $pythonPath -Recurse -Force -ErrorAction SilentlyContinue
}
shell: powershell
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Set PowerShell execution policy
run: Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope Process -Force
shell: powershell
- name: Execute setup script
run: powershell.exe -ExecutionPolicy bypass -File .\setup.ps1
shell: cmd
- name: Check Unity installation path
run: |
$UnityPath="C:\Program Files\Unity\Hub\Editor\2022.3.8f1\Editor\Unity.exe"
if (Test-Path $UnityPath) {
Write-Host "Unity executable found at $UnityPath"
} else {
Write-Host "Unity executable not found, checking other locations..."
$unityInstallations = Get-ChildItem "C:\Program Files\Unity\Hub\Editor\" -ErrorAction SilentlyContinue | Where-Object { $_.PSIsContainer }
if ($unityInstallations -and $unityInstallations.Count -gt 0) {
foreach ($dir in $unityInstallations) {
$testPath = Join-Path $dir.FullName "Editor\Unity.exe"
if (Test-Path $testPath) {
Write-Host "Found Unity at: $testPath"
$UnityPath = $testPath
break
}
}
}
if (-not (Test-Path $UnityPath)) {
Write-Host "No Unity installation found, the test will fail."
}
}
echo "UNITY_PATH=$UnityPath" >> $env:GITHUB_ENV
shell: powershell
- name: Run CI simulation
run: |
$unityPath = $Env:UNITY_PATH
if (-not $unityPath) {
throw "UNITY_PATH environment variable is not set"
}
Write-Host "[INFO] Using Unity executable at $unityPath"
$positionLogDir = Join-Path (Get-Location) "Logs\PositionAccuracy"
if (-not (Test-Path $positionLogDir)) {
Write-Host "[INFO] Creating position accuracy directory at $positionLogDir"
New-Item -Path $positionLogDir -ItemType Directory -Force | Out-Null
}
$logFile = "unity_test_run.log"
if (Test-Path $logFile) {
Write-Host "[INFO] Removing previous Unity log file $logFile"
Remove-Item -Path $logFile -Force -ErrorAction SilentlyContinue
}
$logFilePath = Join-Path (Get-Location) $logFile
Write-Host "[INFO] Invoking run_scene_automated.ps1"
$params = @{
UnityPath = $unityPath
LogFile = $logFile
LogFilePath = $logFilePath
ErrorThreshold = 1.5
}
if ($Env:BYPASS_UNITY_INIT -eq '$true') {
Write-Host "[INFO] Bypass Unity initialization requested"
$params["BypassInitCheck"] = $true
}
& powershell.exe -NoProfile -ExecutionPolicy Bypass -File .\run_scene_automated.ps1 @params
$exitCode = $LASTEXITCODE
if ($exitCode -ne 0) {
throw "run_scene_automated.ps1 failed with exit code $exitCode"
}
shell: powershell
- name: Upload test artifacts
uses: actions/upload-artifact@v4
with:
name: test-results
path: |
Logs\ci-simulation.log
Logs\PositionAccuracy\statistics_summary_*.txt
Logs\PositionAccuracy\position_accuracy_*.csv
retention-days: 7