@@ -43,18 +43,36 @@ jobs:
4343 env :
4444 ACCEPT_EULA : ' Y'
4545 SA_PASSWORD : ' SSpaSS__1_123'
46+ MSSQL_PID : ' Express'
47+ MSSQL_MEMORY_LIMIT_MB : ' 2048'
48+ MSSQL_ENABLE_HADR : ' 0'
49+ MSSQL_AGENT_ENABLED : ' false'
4650 options : >-
47- --health-cmd "/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 'SSpaSS__1_123' -l 30 -Q 'SELECT 1'"
48- --health-interval 4s
49- --health-timeout 2s
50- --health-retries 16
51+ --health-cmd "timeout 30s /opt/mssql-tools18/bin/sqlcmd -S localhost -U sa -P 'SSpaSS__1_123' -C -Q 'SELECT 1' || exit 1"
52+ --health-interval 10s
53+ --health-timeout 30s
54+ --health-retries 30
55+ --health-start-period 60s
5156 ports :
5257 - 11433:1433
5358
5459 steps :
5560 - name : 📦 Check out the codebase
56615762
63+ - name : 🔧 Install Microsoft ODBC Driver for SQL Server
64+ run : |
65+ # Get Ubuntu version dynamically (ubuntu-latest is currently 24.04)
66+ UBUNTU_VERSION=$(lsb_release -rs 2>/dev/null || echo "24.04")
67+ echo "Installing ODBC driver for Ubuntu $UBUNTU_VERSION"
68+
69+ curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
70+ curl https://packages.microsoft.com/config/ubuntu/$UBUNTU_VERSION/prod.list | sudo tee /etc/apt/sources.list.d/msprod.list
71+ sudo apt-get update
72+ sudo ACCEPT_EULA=Y apt-get install -y msodbcsql18 mssql-tools18 unixodbc-dev
73+ echo 'export PATH="$PATH:/opt/mssql-tools18/bin"' >> ~/.bashrc
74+ source ~/.bashrc
75+
5876 - name : 🛠️ Setup PHP
5977 uses :
shivammathur/[email protected] 6078 with :
@@ -90,5 +108,27 @@ jobs:
90108 with :
91109 dependencies : ${{ matrix.dependencies }}
92110
111+ - name : ⏳ Verify SQL Server Connection
112+ run : |
113+ echo "Verifying SQL Server is fully ready..."
114+ for i in {1..30}; do
115+ echo "Connection test attempt $i/30..."
116+ if /opt/mssql-tools18/bin/sqlcmd -S 127.0.0.1,11433 -U sa -P 'SSpaSS__1_123' -C -Q "SELECT 1 AS TestConnection" -o /tmp/sqltest.log 2>&1; then
117+ echo "✅ SQL Server connection successful!"
118+ cat /tmp/sqltest.log
119+ break
120+ else
121+ echo "❌ SQL Server connection failed, retrying in 5 seconds..."
122+ cat /tmp/sqltest.log 2>/dev/null || true
123+ if [ $i -eq 30 ]; then
124+ echo "💥 SQL Server failed to become ready after 150 seconds"
125+ # Show container logs for debugging
126+ docker logs $(docker ps -q --filter "ancestor=mcr.microsoft.com/mssql/server:2022-latest") || true
127+ exit 1
128+ fi
129+ sleep 5
130+ fi
131+ done
132+
93133 - name : 🧪 Run phpunit tests with Pest
94134 run : composer test
0 commit comments