Skip to content

Commit bc4c062

Browse files
Fail workflow explicitly if SQL Server doesn't become ready
Co-authored-by: dlevy-msft-sql <[email protected]>
1 parent a0582a9 commit bc4c062

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

.github/workflows/pr-validation.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,19 @@ jobs:
2424
export SQLCMDUSER=sa
2525
docker run -m 2GB -e ACCEPT_EULA=1 -d --name sql2022 -p:1433:1433 -e SA_PASSWORD=$SQLCMDPASSWORD mcr.microsoft.com/mssql/server:2022-latest
2626
echo "Waiting for SQL Server to be ready..."
27+
READY=0
2728
for i in {1..60}; do
2829
if docker exec sql2022 /opt/mssql-tools18/bin/sqlcmd -S localhost -U sa -P "$SQLCMDPASSWORD" -C -Q "SELECT 1" &>/dev/null; then
2930
echo "SQL Server is ready!"
31+
READY=1
3032
break
3133
fi
3234
echo "Attempt $i: SQL Server not ready yet, waiting..."
3335
sleep 2
3436
done
37+
if [ $READY -eq 0 ]; then
38+
echo "ERROR: SQL Server failed to become ready within 2 minutes"
39+
exit 1
40+
fi
3541
cd ../..
3642
go test -v ./...

0 commit comments

Comments
 (0)