Skip to content

Commit 57c9e67

Browse files
Fix CI: use log-based health check and handle pre-configured Microsoft apt repo
- Health check: grep errorlog instead of sqlcmd (works across all container versions) - Install sqlcmd: skip repo setup if Microsoft repo already configured (Ubuntu 24.04) - Increase health retries from 10 to 15 for slower container starts Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 1b95689 commit 57c9e67

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

.github/workflows/sql-tests.yml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,12 @@ jobs:
1515
include:
1616
- version: '2017'
1717
image: mcr.microsoft.com/mssql/server:2017-latest
18-
health_cmd: /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 'CI_Test#2026!' -Q 'SELECT 1' -b
1918
- version: '2019'
2019
image: mcr.microsoft.com/mssql/server:2019-latest
21-
health_cmd: /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 'CI_Test#2026!' -Q 'SELECT 1' -b
2220
- version: '2022'
2321
image: mcr.microsoft.com/mssql/server:2022-latest
24-
health_cmd: /opt/mssql-tools18/bin/sqlcmd -S localhost -U sa -P 'CI_Test#2026!' -C -No -Q 'SELECT 1' -b
2522
- version: '2025'
2623
image: mcr.microsoft.com/mssql/server:2025-latest
27-
health_cmd: /opt/mssql-tools18/bin/sqlcmd -S localhost -U sa -P 'CI_Test#2026!' -C -No -Q 'SELECT 1' -b
2824

2925
name: SQL Server ${{ matrix.version }}
3026

@@ -37,19 +33,22 @@ jobs:
3733
ports:
3834
- 1433:1433
3935
options: >-
40-
--health-cmd "${{ matrix.health_cmd }}"
36+
--health-cmd "grep -q 'SQL Server is now ready for client connections' /var/opt/mssql/log/errorlog || exit 1"
4137
--health-interval 10s
4238
--health-timeout 5s
43-
--health-retries 10
39+
--health-retries 15
4440
4541
steps:
4642
- uses: actions/checkout@v4
4743

4844
- name: Install sqlcmd
4945
run: |
50-
curl -sSL https://packages.microsoft.com/keys/microsoft.asc | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc > /dev/null
51-
source /etc/os-release
52-
echo "deb [arch=amd64] https://packages.microsoft.com/ubuntu/${VERSION_ID}/prod ${VERSION_CODENAME} main" | sudo tee /etc/apt/sources.list.d/mssql-release.list
46+
# Ubuntu 24.04 runners have Microsoft repo pre-configured; avoid Signed-By conflicts
47+
if ! grep -rql 'packages.microsoft.com' /etc/apt/sources.list.d/ 2>/dev/null; then
48+
curl -sSL https://packages.microsoft.com/keys/microsoft.asc | sudo gpg --dearmor -o /usr/share/keyrings/microsoft-prod.gpg
49+
source /etc/os-release
50+
echo "deb [arch=amd64,signed-by=/usr/share/keyrings/microsoft-prod.gpg] https://packages.microsoft.com/ubuntu/${VERSION_ID}/prod ${VERSION_CODENAME} main" | sudo tee /etc/apt/sources.list.d/mssql-release.list
51+
fi
5352
sudo apt-get update
5453
sudo ACCEPT_EULA=Y apt-get install -y mssql-tools18
5554

0 commit comments

Comments
 (0)