Skip to content

Commit e239433

Browse files
authored
Update mssql.yml (#53)
1 parent 10e6d92 commit e239433

File tree

1 file changed

+33
-14
lines changed

1 file changed

+33
-14
lines changed

.github/workflows/mssql.yml

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ on:
66
- '.github/workflows/mssql.yml'
77
- 'composer.json'
88
- 'phpunit.xml.dist'
9-
109
push:
1110
branches: ['master']
1211
paths:
@@ -15,18 +14,16 @@ on:
1514
- '.github/workflows/mssql.yml'
1615
- 'composer.json'
1716
- 'phpunit.xml.dist'
18-
1917
name: mssql
20-
2118
jobs:
2219
tests:
20+
permissions:
21+
contents: read
22+
pull-requests: write
2323
name: PHP ${{ matrix.php }}-mssql-${{ matrix.mssql.server }}
24-
2524
env:
2625
extensions: pdo, pdo_sqlsrv-5.12
27-
2826
runs-on: ${{ matrix.mssql.os || 'ubuntu-latest' }}
29-
3027
strategy:
3128
matrix:
3229
php:
@@ -40,17 +37,22 @@ jobs:
4037
- server: 2022-latest
4138
odbc-version: 18
4239
flag: "-C"
40+
tools-path: "/opt/mssql-tools18"
4341

4442
include:
4543
- php: 8.3
4644
mssql:
4745
server: 2017-latest
48-
os: ubuntu-20.04
46+
odbc-version: 17
47+
flag: ""
48+
tools-path: "/opt/mssql-tools"
49+
os: ubuntu-22.04
4950
- php: 8.3
5051
mssql:
5152
server: 2019-latest
5253
odbc-version: 18
53-
flag: "-C"
54+
flag: "-C"
55+
tools-path: "/opt/mssql-tools18"
5456

5557
services:
5658
mssql:
@@ -61,19 +63,36 @@ jobs:
6163
MSSQL_PID: Developer
6264
ports:
6365
- 1433:1433
64-
options: --name=mssql --health-cmd="/opt/mssql-tools${{ matrix.mssql.odbc-version }}/bin/sqlcmd ${{ matrix.mssql.flag }} -S localhost -U SA -P 'YourStrong!Passw0rd' -Q 'SELECT 1'" --health-interval=10s --health-timeout=5s --health-retries=3
65-
66+
options: --name=mssql --health-cmd="${{ matrix.mssql.tools-path }}/bin/sqlcmd ${{ matrix.mssql.flag }} -S localhost -U SA -P 'YourStrong!Passw0rd' -Q 'SELECT 1'" --health-interval=10s --health-timeout=5s --health-retries=3
6667
steps:
6768
- name: Install ODBC driver.
6869
run: |
69-
sudo curl https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/prod.list | sudo tee /etc/apt/sources.list.d/mssql-release.list
70-
sudo ACCEPT_EULA=Y apt-get install -y msodbcsql18
70+
curl -fsSL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor | sudo tee /usr/share/keyrings/microsoft-prod.gpg > /dev/null
71+
curl -fsSL https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/prod.list | sudo tee /etc/apt/sources.list.d/mssql-release.list
72+
sudo apt-get update
73+
sudo ACCEPT_EULA=Y apt-get install -y msodbcsql${{ matrix.mssql.odbc-version }}
74+
75+
- name: Verify ODBC driver installation
76+
run: |
77+
echo "=== Installed ODBC Drivers ==="
78+
odbcinst -q -d
79+
echo ""
80+
echo "=== Expected Driver: ODBC Driver ${{ matrix.mssql.odbc-version }} for SQL Server ==="
81+
if odbcinst -q -d -n "ODBC Driver ${{ matrix.mssql.odbc-version }} for SQL Server"; then
82+
echo "✓ Correct driver version installed!"
83+
else
84+
echo "✗ Expected driver not found!"
85+
exit 1
86+
fi
87+
echo ""
88+
echo "=== ODBC Driver Package Info ==="
89+
dpkg -l | grep msodbcsql
7190
7291
- name: Checkout
73-
uses: actions/checkout@v3
92+
uses: actions/checkout@v6
7493

7594
- name: Create MS SQL Database
76-
run: docker exec -i mssql /opt/mssql-tools${{ matrix.mssql.odbc-version }}/bin/sqlcmd ${{ matrix.mssql.flag }} -S localhost -U SA -P 'YourStrong!Passw0rd' -Q 'CREATE DATABASE yiitest'
95+
run: docker exec -i mssql ${{ matrix.mssql.tools-path }}/bin/sqlcmd ${{ matrix.mssql.flag }} -S localhost -U SA -P 'YourStrong!Passw0rd' -Q 'CREATE DATABASE yiitest'
7796

7897
- name: Install PHP with extensions
7998
uses: shivammathur/setup-php@v2

0 commit comments

Comments
 (0)