Files
game_voice_recorder/tools/win-ci/gvr.ps1
EJClaw c2a5547a68 앱 v1.2.0: exe 디스코드 로그인 · 유저 등록 · 관리자 페이지
- 사이트 서버: 앱 로그인(/auth/app/begin·start·poll, 기존 OAuth 콜백 재사용), 앱 토큰(/app/me, 해시 저장),
  유저 등록 API(/app/admin/users, 등록·역할·해제는 최고 관리자만, 목록은 관리자도). 최고 관리자 2명 고정
- 앱: 등록된 계정으로 로그인해야 코어(봇·녹음·사이트 연결)를 띄운다. 미등록이면 "등록되지 않은 아이디" + 아이디 표시.
  10분마다 재확인, 등록 해제 시 즉시 잠금. 서버 연결 실패 시 마지막 확인 후 3일 유예
- 겜녹이 봇 토큰을 exe 에 넣지 않고 로그인한 등록 유저에게 서버가 내려준다 (잠기면 삭제). win-ci 토큰 주입 제거
- 관리자 탭(유저 등록·목록·접속 기록), 관리자 전용 설정(봇 변경·TTS 안내·보관 기간·사이트·학습 데이터·파인튜닝)은
  일반 유저에게 잠금 표시 + 메인 프로세스에서 차단
- 테스트: 서버 앱 로그인 2건, 앱↔서버 통합 3건, Electron 로그인 E2E 스크립트(scripts/login-e2e.mts)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-15 08:08:44 +09:00

167 lines
7.7 KiB
PowerShell

# ==================================================================
# 겜녹이 (game_voice_recorder) Windows 검증 · 빌드
# $TargetRev : 검증할 커밋 (run.sh 가 박는다)
# $Phase : worker = 워커 테스트 + OCR + 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 winrt.windows.media.ocr as o; import onnxruntime, faster_whisper, ctranslate2; print('faster-whisper', faster_whisper.__version__, 'ct2', ctranslate2.__version__, 'ort', onnxruntime.__version__)"
Pop-Location
}
# 한국어 OCR 언어 기능 (롤 채팅 OCR 에 필요. 게임 PC 에서는 첫 실행 마법사가 안내)
$r['ocr_lang'] = Step 'ocr_lang' {
$cap = Get-WindowsCapability -Online -Name 'Language.OCR~~~ko-KR~0.0.1.0'
"상태: $($cap.State)"
if ($cap.State -ne 'Installed') { Add-WindowsCapability -Online -Name 'Language.OCR~~~ko-KR~0.0.1.0' | Out-String }
(Get-WindowsCapability -Online -Name 'Language.OCR~~~ko-KR~0.0.1.0').State
}
$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') {
$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
$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