diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3e66294b..f180e2ea 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -43,11 +43,22 @@ jobs: echo "port = 5432" >> "$PGDATA/postgresql.conf" $PG_BIN = "C:\Program Files\PostgreSQL\14\bin" $env:PATH = "$PG_BIN;$env:PATH" - Write-Host "PATH=$env:PATH" + # Write-Host "PATH=$env:PATH" # start and wait pg_ctl start - Start-Sleep -Seconds 15 + $timeout = 120 + $elapsedTime = 0 + Write-Host "Waiting for PostgreSQL to start" + while ($elapsedTime -lt $timeout) { + $pgIsReadyResult = & $PG_BIN\pg_isready.exe -h localhost -p 5432 -t 1 + if ($pgIsReadyResult -eq "localhost:5432 - accepting connections") { + Write-Host "PostgreSQL is ready" + break + } + Start-Sleep -Seconds 5 + $elapsedTime += 5 + } # setup db cd database @@ -72,6 +83,26 @@ jobs: sc.exe create Redis binpath=C:\redis\RedisService.exe start= auto net start Redis + # wait for redis + Write-Host "Waiting for Redis to start" + while ($elapsedTime -lt $timeout) { + $redisPingResult = & C:\redis\redis-cli.exe ping + echo $redisPingResult + if ($redisPingResult -eq "PONG") { + Write-Host "Redis is ready" + break + } + Start-Sleep -Seconds 5 + $elapsedTime += 5 + } + + if ($elapsedTime -ge $timeout) { + Write-Host "Timeout waiting for services to start." + exit 1 + } + + Write-Host "Services are ready" + - name: Setup (on Linux) if: runner.os == 'Linux' run: |