53 lines
2.6 KiB
Batchfile
53 lines
2.6 KiB
Batchfile
@echo off
|
|
setlocal
|
|
|
|
REM FORCE_BUILD=1: rebuild image with --no-cache before running tests.
|
|
REM FORCE_BUILD=0: reuse existing image; build only when the image is missing.
|
|
set "FORCE_BUILD=0"
|
|
|
|
REM VERBOSE=1: print full stdout/stderr logs for every test.
|
|
REM VERBOSE=0: print only [PASS], [NO], and reason lines; full logs stay in logs\.
|
|
set "VERBOSE=0"
|
|
|
|
cd /d "%~dp0"
|
|
|
|
if not exist logs mkdir logs
|
|
|
|
for /f %%i in ('powershell -NoProfile -ExecutionPolicy Bypass -Command "$files = Get-ChildItem -Recurse -File scripts,rootfs,Dockerfile,compose.yml,.env; ($files | Sort-Object LastWriteTimeUtc -Descending | Select-Object -First 1).LastWriteTimeUtc.Ticks"') do set "SOURCE_VERSION=%%i"
|
|
|
|
if "%FORCE_BUILD%"=="1" (
|
|
docker compose --env-file .env -f compose.yml build --quiet --no-cache >logs\build.out 2>logs\build.err
|
|
if errorlevel 1 exit /b %errorlevel%
|
|
) else (
|
|
docker compose --env-file .env -f compose.yml build --quiet >logs\build.out 2>logs\build.err
|
|
if errorlevel 1 (
|
|
docker image inspect ubuntu-xray-transparent-test >nul 2>nul
|
|
if errorlevel 1 exit /b 1
|
|
)
|
|
)
|
|
|
|
docker compose --env-file .env -f compose.yml run --rm --no-deps ipv6-default-off >logs\ipv6-default-off.out 2>logs\ipv6-default-off.err
|
|
set "IPV6_OFF_CODE=%errorlevel%"
|
|
call :print_result logs\ipv6-default-off.out logs\ipv6-default-off.err
|
|
|
|
docker compose --env-file .env -f compose.yml run --rm --no-deps ipv6-enabled >logs\ipv6-enabled.out 2>logs\ipv6-enabled.err
|
|
set "IPV6_ON_CODE=%errorlevel%"
|
|
call :print_result logs\ipv6-enabled.out logs\ipv6-enabled.err
|
|
|
|
docker compose --env-file .env -f compose.yml run --rm --no-deps proxy-on >logs\proxy-on.out 2>logs\proxy-on.err
|
|
set "PROXY_ON_CODE=%errorlevel%"
|
|
call :print_result logs\proxy-on.out logs\proxy-on.err
|
|
|
|
docker compose --env-file .env -f compose.yml run --rm --no-deps proxy-off >logs\proxy-off.out 2>logs\proxy-off.err
|
|
set "PROXY_OFF_CODE=%errorlevel%"
|
|
call :print_result logs\proxy-off.out logs\proxy-off.err
|
|
|
|
if not "%IPV6_OFF_CODE%"=="0" exit /b %IPV6_OFF_CODE%
|
|
if not "%IPV6_ON_CODE%"=="0" exit /b %IPV6_ON_CODE%
|
|
if not "%PROXY_ON_CODE%"=="0" exit /b %PROXY_ON_CODE%
|
|
exit /b %PROXY_OFF_CODE%
|
|
|
|
:print_result
|
|
powershell -NoProfile -ExecutionPolicy Bypass -Command "$verbose='%VERBOSE%'; $paths=@('%~1','%~2'); foreach($path in $paths){ if(!(Test-Path -LiteralPath $path)){ continue }; foreach($line in Get-Content -LiteralPath $path){ if($verbose -eq '1'){ Write-Host $line; continue }; if($line.StartsWith('[PASS]')){ Write-Host $line -ForegroundColor Green } elseif($line.StartsWith('[NO]') -or $line.StartsWith('reason:')){ Write-Host $line -ForegroundColor Red } } }"
|
|
exit /b 0
|