diff --git a/scripts/win-ci/serve/stage2.ps1 b/scripts/win-ci/serve/stage2.ps1 index d707222..95f50fa 100644 --- a/scripts/win-ci/serve/stage2.ps1 +++ b/scripts/win-ci/serve/stage2.ps1 @@ -212,6 +212,12 @@ Log "=== stage2 완료 ===" # ================================================================== $Repo = 'C:\win-ci\live-app-translator' $OutDir = 'C:\win-ci\out' + +# 검증 대상 리비전. 'main' 이면 origin/main 최신. +# 호스트에서 `./sync.sh ` 를 쓰면 이 한 줄이 그 sha 로 바뀐 사본이 배포되고, +# 내용이 바뀌므로 게스트 agent 가 해시 차이를 보고 20초 안에 다시 돈다. +# = "이 커밋을 검증해라" 라는 요청이 곧 재실행 트리거다. +$TargetRev = 'main' New-Item -ItemType Directory -Force -Path $OutDir | Out-Null # 출력 원본을 호스트 파일로 회수한다. @@ -267,13 +273,16 @@ function Step($name, $block) { $ErrorActionPreference = 'Continue' try { Sync-Path - if (Test-Path $Repo) { - Log "저장소 갱신" - Push-Location $Repo; & git fetch --all -q; & git reset --hard origin/main -q; Pop-Location - } else { + if (-not (Test-Path $Repo)) { Log "저장소 clone" & git clone -q https://git.tkrmagid.kr/tkrmagid/live-app-translator $Repo } + $ref = if ($TargetRev -eq 'main') { 'origin/main' } else { $TargetRev } + Log "저장소 갱신 -> $ref" + Push-Location $Repo + & git fetch --all -q + & git reset --hard $ref -q + Pop-Location Push-Location $Repo $py = Join-Path $Repo '.venv-ci\Scripts\python.exe' diff --git a/scripts/win-ci/sync.sh b/scripts/win-ci/sync.sh index e6f6ba7..883414b 100755 --- a/scripts/win-ci/sync.sh +++ b/scripts/win-ci/sync.sh @@ -1,19 +1,29 @@ #!/bin/bash # 저장소의 win-ci 스크립트를 /home/claude/win-ci 로 반영한다. # +# ./sync.sh stage2.ps1 을 그대로 배포 (origin/main 최신을 검증) +# ./sync.sh 그 커밋을 검증하도록 $TargetRev 를 박아서 배포 +# # build.sh 를 다시 돌리면 안 된다. build.sh 의 fetch 는 지워둔 Windows ISO(4.8GB)를 # 다시 내려받는다. 설치가 끝난 VM 에 스크립트만 갱신할 때는 이걸 쓴다. # # stage2.ps1 은 게스트 agent 가 20초마다 해시를 비교해 받아가므로, 복사만 하면 -# VM 재시작 없이 다음 폴링에 새 버전이 실행된다. +# VM 재시작 없이 다음 폴링에 새 버전이 실행된다. 반대로 내용이 같으면 다시 돌지 +# 않는다 — 그래서 재검증을 요청할 때는 sha 를 넘겨 내용이 바뀌게 한다. # serve-host.py 는 호스트 프로세스라 유닛을 재시작해야 반영된다. set -euo pipefail D="${WIN_CI_DIR:-/home/claude/win-ci}" HERE="$(cd "$(dirname "$0")" && pwd)" +REV="${1:-}" mkdir -p "$D/serve" "$D/results" cp "$HERE/serve/stage2.ps1" "$D/serve/" +if [ -n "$REV" ]; then + sed -i "s/^\$TargetRev = 'main'$/\$TargetRev = '$REV'/" "$D/serve/stage2.ps1" + grep -q "^\$TargetRev = '$REV'$" "$D/serve/stage2.ps1" || { echo "TargetRev 치환 실패"; exit 1; } + echo "검증 대상 리비전 = $REV" +fi cp "$HERE"/*.sh "$HERE/serve-host.py" "$D/" chmod +x "$D"/*.sh