Skip to content

Commit c68611b

Browse files
committed
Add Azure SQL jobs and remove stale CodeQL workarounds
1 parent e95f53c commit c68611b

File tree

1 file changed

+187
-62
lines changed

1 file changed

+187
-62
lines changed

eng/pipelines/pr-validation-pipeline.yml

Lines changed: 187 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,6 @@ trigger:
66
include:
77
- main
88

9-
parameters:
10-
- name: enableAzureSQL
11-
displayName: 'Enable Azure SQL Database testing'
12-
type: boolean
13-
default: false
14-
159
jobs:
1610
- job: CodeQLAnalysis
1711
displayName: 'CodeQL Security Analysis'
@@ -55,18 +49,9 @@ jobs:
5549
displayName: 'Windows x64'
5650
pool:
5751
vmImage: 'windows-latest'
58-
variables:
59-
# Enable CodeQL for this job to update the old stale snapshot (build_jobname=pytestonwindows)
60-
# This can be removed once the old CodeQL issue SM02986 is cleared
61-
Codeql.Enabled: true
6252

6353
strategy:
6454
matrix:
65-
pytestonwindows:
66-
# Temporary entry to clear stale CodeQL snapshot SM02986
67-
# Remove this once the issue is resolved
68-
sqlVersion: 'SQL2022'
69-
pythonVersion: '3.13'
7055
SQLServer2022:
7156
sqlVersion: 'SQL2022'
7257
pythonVersion: '3.13'
@@ -76,10 +61,6 @@ jobs:
7661
LocalDB_Python314:
7762
sqlVersion: 'LocalDB'
7863
pythonVersion: '3.14'
79-
${{ if eq(parameters.enableAzureSQL, true) }}:
80-
AzureSQL:
81-
sqlVersion: 'AzureSQL'
82-
pythonVersion: '3.13'
8364

8465
steps:
8566
- task: UsePythonVersion@0
@@ -244,22 +225,11 @@ jobs:
244225
env:
245226
DB_PASSWORD: $(DB_PASSWORD)
246227
247-
# ============== CodeQL Init (temporary - remove after SM02986 is cleared) ==============
248-
- task: CodeQL3000Init@0
249-
inputs:
250-
Enabled: true
251-
displayName: 'Initialize CodeQL (temporary)'
252-
253228
- script: |
254229
cd mssql_python\pybind
255230
build.bat x64
256231
displayName: 'Build .pyd file'
257232
258-
# ============== CodeQL Finalize (temporary - remove after SM02986 is cleared) ==============
259-
- task: CodeQL3000Finalize@0
260-
condition: always()
261-
displayName: 'Finalize CodeQL (temporary)'
262-
263233
# Run tests for LocalDB
264234
- script: |
265235
python -m pytest -v --junitxml=test-results-localdb.xml --cov=. --cov-report=xml:coverage-localdb.xml --capture=tee-sys --cache-clear
@@ -284,14 +254,6 @@ jobs:
284254
env:
285255
DB_CONNECTION_STRING: 'Server=localhost;Database=TestDB;Uid=testuser;Pwd=$(DB_PASSWORD);TrustServerCertificate=yes'
286256
287-
# Run tests for Azure SQL Database
288-
- script: |
289-
python -m pytest -v --junitxml=test-results-azuresql.xml --cov=. --cov-report=xml:coverage-azuresql.xml --capture=tee-sys --cache-clear
290-
displayName: 'Run tests with coverage on Azure SQL Database'
291-
condition: eq(variables['sqlVersion'], 'AzureSQL')
292-
env:
293-
DB_CONNECTION_STRING: $(AZURE_CONNECTION_STRING)
294-
295257
# Download and restore AdventureWorks2022 database for benchmarking
296258
- powershell: |
297259
Write-Host "Downloading AdventureWorks2022.bak..."
@@ -467,16 +429,9 @@ jobs:
467429
SQL2022:
468430
sqlServerImage: 'mcr.microsoft.com/mssql/server:2022-latest'
469431
sqlVersion: 'SQL2022'
470-
useAzureSQL: 'false'
471432
SQL2025:
472433
sqlServerImage: 'mcr.microsoft.com/mssql/server:2025-latest'
473434
sqlVersion: 'SQL2025'
474-
useAzureSQL: 'false'
475-
${{ if eq(parameters.enableAzureSQL, true) }}:
476-
AzureSQL:
477-
sqlServerImage: ''
478-
sqlVersion: 'AzureSQL'
479-
useAzureSQL: 'true'
480435

481436
steps:
482437
- task: UsePythonVersion@0
@@ -507,7 +462,6 @@ jobs:
507462
docker version
508463
docker ps
509464
displayName: 'Install and start Colima-based Docker'
510-
condition: eq(variables['useAzureSQL'], 'false')
511465
512466
- script: |
513467
# Pull and run SQL Server container
@@ -530,7 +484,6 @@ jobs:
530484
sleep 2
531485
done
532486
displayName: 'Pull & start SQL Server (Docker)'
533-
condition: eq(variables['useAzureSQL'], 'false')
534487
env:
535488
DB_PASSWORD: $(DB_PASSWORD)
536489
@@ -548,19 +501,10 @@ jobs:
548501
echo "Build successful, running tests now"
549502
python -m pytest -v --junitxml=test-results.xml --cov=. --cov-report=xml --capture=tee-sys --cache-clear
550503
displayName: 'Run pytest with coverage'
551-
condition: eq(variables['useAzureSQL'], 'false')
552504
env:
553505
DB_CONNECTION_STRING: 'Server=tcp:127.0.0.1,1433;Database=master;Uid=SA;Pwd=$(DB_PASSWORD);TrustServerCertificate=yes'
554506
DB_PASSWORD: $(DB_PASSWORD)
555507
556-
- script: |
557-
echo "Build successful, running tests now against Azure SQL Database"
558-
python -m pytest -v --junitxml=test-results.xml --cov=. --cov-report=xml --capture=tee-sys --cache-clear
559-
displayName: 'Run pytest with coverage on Azure SQL Database'
560-
condition: eq(variables['useAzureSQL'], 'true')
561-
env:
562-
DB_CONNECTION_STRING: $(AZURE_CONNECTION_STRING)
563-
564508
- task: PublishTestResults@2
565509
condition: succeededOrFailed()
566510
inputs:
@@ -584,17 +528,12 @@ jobs:
584528
distroName: 'Ubuntu-SQL2025'
585529
sqlServerImage: 'mcr.microsoft.com/mssql/server:2025-latest'
586530
useAzureSQL: 'false'
587-
${{ if eq(parameters.enableAzureSQL, true) }}:
531+
${{ if ne(variables['AZURE_CONNECTION_STRING'], '') }}:
588532
Ubuntu_AzureSQL:
589533
dockerImage: 'ubuntu:22.04'
590534
distroName: 'Ubuntu-AzureSQL'
591535
sqlServerImage: ''
592536
useAzureSQL: 'true'
593-
Debian_AzureSQL:
594-
dockerImage: 'debian:12'
595-
distroName: 'Debian-AzureSQL'
596-
sqlServerImage: ''
597-
useAzureSQL: 'true'
598537
Debian:
599538
dockerImage: 'debian:12'
600539
distroName: 'Debian'
@@ -2016,6 +1955,192 @@ jobs:
20161955
testResultsFiles: '**/test-results-alpine-arm64.xml'
20171956
testRunTitle: 'Publish pytest results on Alpine ARM64'
20181957

1958+
# ===========================================================================================
1959+
# Azure SQL Database Testing Jobs
1960+
# Gated on the AZURE_CONNECTION_STRING pipeline variable being set.
1961+
# No local SQL Server install needed — tests run directly against the cloud database.
1962+
# ===========================================================================================
1963+
1964+
- job: PytestOnWindows_AzureSQL
1965+
displayName: 'Windows x64 AzureSQL'
1966+
condition: ne(variables['AZURE_CONNECTION_STRING'], '')
1967+
pool:
1968+
vmImage: 'windows-latest'
1969+
1970+
steps:
1971+
- task: UsePythonVersion@0
1972+
inputs:
1973+
versionSpec: '3.13'
1974+
addToPath: true
1975+
githubToken: $(GITHUB_TOKEN)
1976+
displayName: 'Use Python 3.13'
1977+
1978+
- script: |
1979+
python -m pip install --upgrade pip
1980+
pip install -r requirements.txt
1981+
displayName: 'Install dependencies'
1982+
1983+
- script: |
1984+
cd mssql_python\pybind
1985+
build.bat x64
1986+
displayName: 'Build .pyd file'
1987+
1988+
- script: |
1989+
python -m pytest -v --junitxml=test-results-azuresql.xml --cov=. --cov-report=xml:coverage-azuresql.xml --capture=tee-sys --cache-clear
1990+
displayName: 'Run tests on Azure SQL Database'
1991+
env:
1992+
DB_CONNECTION_STRING: $(AZURE_CONNECTION_STRING)
1993+
1994+
- task: PublishTestResults@2
1995+
condition: succeededOrFailed()
1996+
inputs:
1997+
testResultsFiles: '**/test-results-azuresql.xml'
1998+
testRunTitle: 'Publish test results for Windows AzureSQL'
1999+
2000+
- job: PytestOnMacOS_AzureSQL
2001+
displayName: 'macOS x86_64 AzureSQL'
2002+
condition: ne(variables['AZURE_CONNECTION_STRING'], '')
2003+
pool:
2004+
vmImage: 'macos-latest'
2005+
2006+
steps:
2007+
- task: UsePythonVersion@0
2008+
inputs:
2009+
versionSpec: '3.13'
2010+
addToPath: true
2011+
displayName: 'Use Python 3.13'
2012+
2013+
- script: |
2014+
brew update
2015+
brew uninstall cmake --ignore-dependencies || echo "CMake not installed or already removed"
2016+
brew install cmake
2017+
displayName: 'Install CMake'
2018+
2019+
- script: |
2020+
python -m pip install --upgrade pip
2021+
pip install -r requirements.txt
2022+
displayName: 'Install Python dependencies'
2023+
2024+
- script: |
2025+
cd mssql_python/pybind
2026+
./build.sh
2027+
displayName: 'Build pybind bindings (.so)'
2028+
2029+
- script: |
2030+
python -m pytest -v --junitxml=test-results-azuresql.xml --cov=. --cov-report=xml:coverage-azuresql.xml --capture=tee-sys --cache-clear
2031+
displayName: 'Run tests on Azure SQL Database'
2032+
env:
2033+
DB_CONNECTION_STRING: $(AZURE_CONNECTION_STRING)
2034+
2035+
- task: PublishTestResults@2
2036+
condition: succeededOrFailed()
2037+
inputs:
2038+
testResultsFiles: '**/test-results-azuresql.xml'
2039+
testRunTitle: 'Publish pytest results on macOS AzureSQL'
2040+
2041+
- job: PytestOnLinux_AzureSQL
2042+
displayName: 'Linux x86_64 AzureSQL'
2043+
condition: ne(variables['AZURE_CONNECTION_STRING'], '')
2044+
pool:
2045+
vmImage: 'ubuntu-latest'
2046+
2047+
steps:
2048+
- script: |
2049+
docker run -d --name test-container-ubuntu-azuresql \
2050+
-v $(Build.SourcesDirectory):/workspace \
2051+
-w /workspace \
2052+
--network bridge \
2053+
ubuntu:22.04 \
2054+
tail -f /dev/null
2055+
displayName: 'Create Ubuntu container'
2056+
2057+
- script: |
2058+
docker exec test-container-ubuntu-azuresql bash -c "
2059+
export DEBIAN_FRONTEND=noninteractive
2060+
export TZ=UTC
2061+
ln -snf /usr/share/zoneinfo/\$TZ /etc/localtime && echo \$TZ > /etc/timezone
2062+
apt-get update &&
2063+
apt-get install -y python3 python3-pip python3-venv python3-full cmake curl wget gnupg software-properties-common build-essential python3-dev pybind11-dev
2064+
"
2065+
displayName: 'Install basic dependencies in Ubuntu container'
2066+
2067+
- script: |
2068+
docker exec test-container-ubuntu-azuresql bash -c "
2069+
export DEBIAN_FRONTEND=noninteractive
2070+
curl -sSL -O https://packages.microsoft.com/config/ubuntu/22.04/packages-microsoft-prod.deb
2071+
dpkg -i packages-microsoft-prod.deb || true
2072+
rm packages-microsoft-prod.deb
2073+
apt-get update
2074+
ACCEPT_EULA=Y apt-get install -y msodbcsql18
2075+
ACCEPT_EULA=Y apt-get install -y mssql-tools18
2076+
apt-get install -y unixodbc-dev
2077+
"
2078+
displayName: 'Install ODBC Driver in Ubuntu container'
2079+
2080+
- script: |
2081+
docker exec test-container-ubuntu-azuresql bash -c "
2082+
python3 -m venv /opt/venv
2083+
source /opt/venv/bin/activate
2084+
python -m pip install --upgrade pip
2085+
python -m pip install -r requirements.txt
2086+
echo 'source /opt/venv/bin/activate' >> ~/.bashrc
2087+
"
2088+
displayName: 'Install Python dependencies in Ubuntu container'
2089+
2090+
- script: |
2091+
docker exec test-container-ubuntu-azuresql bash -c "
2092+
source /opt/venv/bin/activate
2093+
cd mssql_python/pybind
2094+
chmod +x build.sh
2095+
./build.sh
2096+
"
2097+
displayName: 'Build pybind bindings (.so) in Ubuntu container'
2098+
2099+
- script: |
2100+
docker exec test-container-ubuntu-azuresql bash -c "
2101+
export DEBIAN_FRONTEND=noninteractive
2102+
apt-get remove --purge -y msodbcsql18 mssql-tools18 unixodbc-dev
2103+
rm -f /usr/bin/sqlcmd
2104+
rm -f /usr/bin/bcp
2105+
rm -rf /opt/microsoft/msodbcsql
2106+
rm -f /lib/x86_64-linux-gnu/libodbcinst.so.2
2107+
odbcinst -u -d -n 'ODBC Driver 18 for SQL Server' || true
2108+
echo 'Uninstalled ODBC Driver and cleaned up libraries'
2109+
echo 'Verifying x86_64 debian_ubuntu driver library signatures:'
2110+
ldd mssql_python/libs/linux/debian_ubuntu/x86_64/lib/libmsodbcsql-18.5.so.1.1
2111+
"
2112+
displayName: 'Uninstall ODBC Driver before running tests in Ubuntu container'
2113+
2114+
- script: |
2115+
docker exec \
2116+
-e DB_CONNECTION_STRING="$(AZURE_CONNECTION_STRING)" \
2117+
test-container-ubuntu-azuresql bash -c "
2118+
source /opt/venv/bin/activate
2119+
echo 'Running tests on Ubuntu against Azure SQL Database'
2120+
python -m pytest -v --junitxml=test-results-ubuntu-azuresql.xml --cov=. --cov-report=xml:coverage-ubuntu-azuresql.xml --capture=tee-sys --cache-clear
2121+
"
2122+
displayName: 'Run pytest on Azure SQL in Ubuntu container'
2123+
env:
2124+
AZURE_CONNECTION_STRING: $(AZURE_CONNECTION_STRING)
2125+
2126+
- script: |
2127+
docker cp test-container-ubuntu-azuresql:/workspace/test-results-ubuntu-azuresql.xml $(Build.SourcesDirectory)/
2128+
docker cp test-container-ubuntu-azuresql:/workspace/coverage-ubuntu-azuresql.xml $(Build.SourcesDirectory)/
2129+
displayName: 'Copy test results from Ubuntu container'
2130+
condition: always()
2131+
2132+
- script: |
2133+
docker stop test-container-ubuntu-azuresql || true
2134+
docker rm test-container-ubuntu-azuresql || true
2135+
displayName: 'Clean up Ubuntu container'
2136+
condition: always()
2137+
2138+
- task: PublishTestResults@2
2139+
condition: succeededOrFailed()
2140+
inputs:
2141+
testResultsFiles: '**/test-results-ubuntu-azuresql.xml'
2142+
testRunTitle: 'Publish pytest results on Ubuntu AzureSQL'
2143+
20192144
- job: CodeCoverageReport
20202145
displayName: 'Full Code Coverage Report in Ubuntu x86_64'
20212146
pool:

0 commit comments

Comments
 (0)