# ================================================================== # 겜녹이 (game_voice_recorder) Windows 검증 · 빌드 # $TargetRev : 검증할 커밋 (run.sh 가 박는다) # $Phase : worker = 워커 테스트 + PyInstaller / full = + Electron 포터블 exe 빌드 · 기동 확인 # 결과는 호스트 /home/claude/win-ci/results/gvr-* 로 회수된다. # 이 블록은 실패해도 exit 0 (agent 가 무한 재시도하지 않게) - 판정은 summary 로 한다. # ================================================================== $TargetRev = '__REV__' $Phase = '__PHASE__' $Repo = 'C:\win-ci\gvr' $OutDir = 'C:\win-ci\gvr-out' New-Item -ItemType Directory -Force -Path $OutDir | Out-Null function Send-Artifact($name, $path) { if (-not (Test-Path $path)) { return } try { $bytes = [IO.File]::ReadAllBytes($path) $req = @{ Uri = "http://10.0.2.2:8099/artifact/$name"; Method = 'Post'; TimeoutSec = 3600; Body = $bytes; ContentType = 'application/octet-stream' } Invoke-RestMethod @req | Out-Null Log " -> 호스트로 $name ($($bytes.Length) bytes)" } catch { Log " -> $name 업로드 실패: $($_.Exception.Message)" } } function Step($name, $block) { $log = Join-Path $OutDir "$name.log" Remove-Item $log -Force -ErrorAction SilentlyContinue Log "--- [$name] 시작" $sw = [IO.StreamWriter]::new($log, $false, [Text.UTF8Encoding]::new($false)) $sw.AutoFlush = $true $tail = [System.Collections.Generic.Queue[string]]::new() $ok = $true $t0 = Get-Date try { & $block 2>&1 | ForEach-Object { $line = "$_" $sw.WriteLine($line) $tail.Enqueue($line) if ($tail.Count -gt 15) { [void]$tail.Dequeue() } } } catch { $ok = $false $sw.WriteLine("[step 예외] $($_.Exception.Message)") } $sw.WriteLine("[소요] $([int]((Get-Date) - $t0).TotalSeconds)s") $sw.Close() foreach ($l in $tail) { Log " $l" } if ($ok) { Log "--- [$name] 통과" } else { Log "--- [$name] 실패" } Send-Artifact "gvr-$name.log" $log return $ok } $ErrorActionPreference = 'Continue' $env:PYTHONUTF8 = '1' $env:PYTHONIOENCODING = 'utf-8' $r = [ordered]@{} try { Sync-Path if (-not (Test-Path $Repo)) { Log "gvr clone" & git clone -q https://git.tkrmagid.kr/tkrmagid/game_voice_recorder $Repo } Push-Location $Repo & git fetch --all -q & git reset --hard $TargetRev -q & git clean -fdq -e node_modules -e .venv -e worker/dist -e worker/build Log "gvr rev $(& git rev-parse --short HEAD)" $py = Join-Path $Repo 'worker\.venv\Scripts\python.exe' if ($Phase -eq 'debug') { # 원인 조사용: worker/scripts/win_debug.py 만 돌린다 (venv 는 이전 실행 것을 그대로 씀) $r['debug'] = Step 'debug' { & $py -X faulthandler worker\scripts\win_debug.py protocol "exit $LASTEXITCODE" } $sum = Join-Path $OutDir 'summary.log' Set-Content -Path $sum -Value @("phase=debug", "debug $($r['debug'])") -Encoding UTF8 Send-Artifact 'gvr-summary.log' $sum Pop-Location Log "=== gvr 끝 ===" exit 0 } $r['worker_setup'] = Step 'worker_setup' { Push-Location (Join-Path $Repo 'worker') if (-not (Test-Path $py)) { & python -m venv .venv } & $py -m pip install --upgrade pip -q & $py -m pip install -r requirements.txt -r requirements-dev.txt -q if ($LASTEXITCODE -ne 0) { Pop-Location; throw "pip exit $LASTEXITCODE" } # pywinrt 가 넣어 둔 오래된 MSVC 런타임(msvcp140 14.29)은 지운다. 남겨 두면 PyInstaller 분석과 실행 중에 # onnxruntime 이 0xC0000005 로 죽는다 (시스템/번들의 새 런타임을 쓰게 한다) Get-ChildItem (Join-Path $Repo 'worker\.venv\Lib\site-packages\winrt') -Filter 'msvcp140*.dll' -ErrorAction SilentlyContinue | ForEach-Object { "삭제: $($_.FullName)"; Remove-Item $_.FullName -Force } & $py -c "import onnxruntime, faster_whisper, ctranslate2; print('faster-whisper', faster_whisper.__version__, 'ct2', ctranslate2.__version__, 'ort', onnxruntime.__version__)" Pop-Location } $r['worker_pytest'] = Step 'worker_pytest' { Push-Location (Join-Path $Repo 'worker') & $py -m pytest -q -rf $c = $LASTEXITCODE Pop-Location if ($c -ne 0) { throw "pytest exit $c" } } $r['win_smoke'] = Step 'win_smoke' { & $py worker\scripts\win_smoke.py --out (Join-Path $OutDir 'win_smoke.json') if ($LASTEXITCODE -ne 0) { throw "smoke exit $LASTEXITCODE" } } Send-Artifact 'gvr-win_smoke.json' (Join-Path $OutDir 'win_smoke.json') $r['worker_build'] = Step 'worker_build' { Push-Location (Join-Path $Repo 'worker') & $py -m PyInstaller gvr-worker.spec --noconfirm --clean $c = $LASTEXITCODE Pop-Location if ($c -ne 0) { throw "PyInstaller exit $c" } "크기 $([math]::Round((Get-ChildItem worker\dist\gvr-worker -Recurse | Measure-Object Length -Sum).Sum / 1MB, 1)) MB" } $r['worker_exe_smoke'] = Step 'worker_exe_smoke' { & $py worker\scripts\win_smoke.py --exe worker\dist\gvr-worker\gvr-worker.exe --out (Join-Path $OutDir 'win_smoke_exe.json') if ($LASTEXITCODE -ne 0) { throw "exe smoke exit $LASTEXITCODE" } } if ($Phase -eq 'full') { # 3D 리플레이 변환기 (v1.5.0~): .NET SDK 10 (없으면 받음) → ValorantReplayParser 고정 커밋 → win-x64 단일 exe $r['replay_build'] = Step 'replay_build' { $dn = 'C:\win-ci\dotnet' if (-not (Test-Path (Join-Path $dn 'dotnet.exe'))) { $inst = Get-File 'https://dot.net/v1/dotnet-install.ps1' 'dotnet-install.ps1' & powershell -NoProfile -ExecutionPolicy Bypass -File $inst -Channel 10.0 -InstallDir $dn } $env:DOTNET_ROOT = $dn $env:DOTNET_CLI_TELEMETRY_OPTOUT = '1' $env:DOTNET_NOLOGO = '1' & (Join-Path $dn 'dotnet.exe') --version $tx = Join-Path $Repo 'tools\replay-extract' $vd = Join-Path $tx 'vendor\ValorantReplayParser' $pc = (Select-String -Path (Join-Path $tx 'fetch-parser.sh') -Pattern 'PARSER_COMMIT:-([0-9a-f]{40})').Matches[0].Groups[1].Value if (-not (Test-Path (Join-Path $vd '.git'))) { & git clone -q https://github.com/michel-giehl/ValorantReplayParser $vd } & git -C $vd fetch -q origin & git -C $vd checkout -q --force $pc # global.json 의 SDK 패치 버전 고정을 푼다 (fetch-parser.sh 와 같게) $gj = Join-Path $vd 'global.json' $j = Get-Content $gj -Raw | ConvertFrom-Json $j.sdk | Add-Member -NotePropertyName rollForward -NotePropertyValue 'latestFeature' -Force $j | ConvertTo-Json -Depth 5 | Set-Content $gj -Encoding UTF8 "parser @ $(& git -C $vd rev-parse --short HEAD)" Push-Location $tx & (Join-Path $dn 'dotnet.exe') publish -c Release -r win-x64 --self-contained true -p:PublishSingleFile=true -p:EnableCompressionInSingleFile=true -p:IncludeNativeLibrariesForSelfExtract=true -p:DebugType=none -o out\win $c = $LASTEXITCODE Pop-Location if ($c -ne 0) { throw "dotnet publish exit $c" } $exe = Join-Path $tx 'out\win\gvr-replay.exe' if (-not (Test-Path $exe)) { throw 'gvr-replay.exe 없음' } "gvr-replay.exe $([math]::Round((Get-Item $exe).Length / 1MB, 1)) MB" # 실제 13.08 리플레이 변환 (호스트가 serve/ 에 둔 시험 파일, 없으면 건너뜀) $vrf = Join-Path $OutDir '4145f041-7d83-4785-ac4b-b532154f14a4.vrf' try { Invoke-WebRequest -Uri 'http://10.0.2.2:8099/gvr-test.vrf' -OutFile $vrf -UseBasicParsing -TimeoutSec 600 } catch { Remove-Item $vrf -Force -ErrorAction SilentlyContinue; "시험 리플레이 없음: $($_.Exception.Message)" } if (Test-Path $vrf) { $out = & $exe $vrf (Join-Path $OutDir 'replay.json') $out if ($LASTEXITCODE -ne 0) { throw "gvr-replay exit $LASTEXITCODE" } } } $r['app_build'] = Step 'app_build' { Push-Location (Join-Path $Repo 'app') & npm.cmd ci --no-audit --no-fund if ($LASTEXITCODE -ne 0) { Pop-Location; throw "npm ci exit $LASTEXITCODE" } & npm.cmd run dist:win $c = $LASTEXITCODE Pop-Location if ($c -ne 0) { throw "electron-builder exit $c" } Get-ChildItem app\release -File | ForEach-Object { "$($_.Name) $([math]::Round($_.Length / 1MB, 1)) MB" } } $r['app_smoke'] = Step 'app_smoke' { $exe = Get-ChildItem app\release\win-unpacked\GameVoiceRecorder.exe $data = Join-Path $OutDir 'smoke-data' Remove-Item $data -Recurse -Force -ErrorAction SilentlyContinue # 시험 리플레이가 있으면 앱 안의 변환기로 실제 변환까지 확인한다 $vrf = Join-Path $OutDir '4145f041-7d83-4785-ac4b-b532154f14a4.vrf' if (Test-Path $vrf) { $env:GVR_SMOKE_VRF = $vrf } else { Remove-Item Env:GVR_SMOKE_VRF -ErrorAction SilentlyContinue } $p = Start-Process $exe.FullName -ArgumentList '--smoke', "--data-dir=$data" -PassThru -Wait Get-Content (Join-Path $data 'smoke.json') -ErrorAction SilentlyContinue if ($p.ExitCode -ne 0) { throw "app smoke exit $($p.ExitCode)" } } if ($r['app_build'] -and $r['app_smoke']) { foreach ($f in Get-ChildItem app\release\* -File -Include *.exe, *.zip) { Send-Artifact $f.Name $f.FullName } } } $rev = (& git rev-parse --short HEAD 2>&1 | Select-Object -First 1) $sum = Join-Path $OutDir 'summary.log' $lines = @("rev=$rev", "phase=$Phase", "utc=$([DateTime]::UtcNow.ToString('yyyy-MM-dd HH:mm:ss'))") foreach ($k in $r.Keys) { $lines += ("{0,-18} {1}" -f $k, $(if ($r[$k]) { 'PASS' } else { 'FAIL' })) } Set-Content -Path $sum -Value $lines -Encoding UTF8 foreach ($l in $lines) { Log $l } Send-Artifact 'gvr-summary.log' $sum Pop-Location } catch { Log "gvr 검증 준비 실패: $($_.Exception.Message)" try { Pop-Location } catch {} } Log "=== gvr 끝 ===" exit 0