|
|
|
@@ -0,0 +1,59 @@
|
|
|
|
|
@echo off
|
|
|
|
|
setlocal
|
|
|
|
|
|
|
|
|
|
REM FORCE_BUILD=1: rebuild the Bun image with --no-cache before running tests.
|
|
|
|
|
REM FORCE_BUILD=0: reuse the existing Bun image; build only with Docker cache.
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
if "%FORCE_BUILD%"=="1" (
|
|
|
|
|
docker compose --env-file .env -f compose.yml build --no-cache >logs\build.out 2>logs\build.err
|
|
|
|
|
if errorlevel 1 (
|
|
|
|
|
call :build_failed
|
|
|
|
|
exit /b %errorlevel%
|
|
|
|
|
)
|
|
|
|
|
) else (
|
|
|
|
|
docker compose --env-file .env -f compose.yml build >logs\build.out 2>logs\build.err
|
|
|
|
|
if errorlevel 1 (
|
|
|
|
|
call :build_failed
|
|
|
|
|
exit /b %errorlevel%
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
docker compose --env-file .env -f compose.yml run --rm --no-deps test bun --version >logs\bun-exists.out 2>logs\bun-exists.err
|
|
|
|
|
set "BUN_EXISTS_CODE=%errorlevel%"
|
|
|
|
|
if "%BUN_EXISTS_CODE%"=="0" (
|
|
|
|
|
call :pass "bun exists"
|
|
|
|
|
) else (
|
|
|
|
|
call :no "bun exists" logs\bun-exists.err
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
docker compose --env-file .env -f compose.yml run --rm --no-deps test bash -lc "grep -F registry.npmmirror.com /root/.bunfig.toml && tmpdir=$(mktemp -d) && cd $tmpdir && printf '{\"name\":\"bun-registry-test\",\"version\":\"0.0.0\",\"private\":true,\"dependencies\":{\"is-number\":\"7.0.0\"}}\n' > package.json && bun install --lockfile-only" >logs\bun-install-registry.out 2>logs\bun-install-registry.err
|
|
|
|
|
set "BUN_INSTALL_REGISTRY_CODE=%errorlevel%"
|
|
|
|
|
if "%BUN_INSTALL_REGISTRY_CODE%"=="0" (
|
|
|
|
|
call :pass "bun install uses npmmirror registry"
|
|
|
|
|
) else (
|
|
|
|
|
call :no "bun install uses npmmirror registry" logs\bun-install-registry.err
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
if not "%BUN_EXISTS_CODE%"=="0" exit /b %BUN_EXISTS_CODE%
|
|
|
|
|
exit /b %BUN_INSTALL_REGISTRY_CODE%
|
|
|
|
|
|
|
|
|
|
:pass
|
|
|
|
|
powershell -NoProfile -ExecutionPolicy Bypass -Command "Write-Host '[PASS] %~1' -ForegroundColor Green"
|
|
|
|
|
exit /b 0
|
|
|
|
|
|
|
|
|
|
:no
|
|
|
|
|
powershell -NoProfile -ExecutionPolicy Bypass -Command "Write-Host '[NO] %~1' -ForegroundColor Red; $reason=(Get-Content -LiteralPath '%~2' -ErrorAction SilentlyContinue | Where-Object { $_ } | Select-Object -Last 1); if(!$reason){ $reason='see logs for details' }; Write-Host ('reason: ' + $reason) -ForegroundColor Red"
|
|
|
|
|
exit /b 0
|
|
|
|
|
|
|
|
|
|
:build_failed
|
|
|
|
|
powershell -NoProfile -ExecutionPolicy Bypass -Command "Write-Host '[NO] build Bun image' -ForegroundColor Red; $reason=(Get-Content -LiteralPath 'logs\build.err' -ErrorAction SilentlyContinue | Where-Object { $_ } | Select-Object -Last 1); if(!$reason){ $reason='docker compose build failed; see Bun\logs\build.err' }; Write-Host ('reason: ' + $reason) -ForegroundColor Red"
|
|
|
|
|
exit /b 0
|