@@ -7,6 +7,44 @@ trigger:
77 - main
88
99jobs :
10+ - job : CodeQLAnalysis
11+ displayName : ' CodeQL Security Analysis'
12+ pool :
13+ vmImage : ' ubuntu-latest'
14+
15+ steps :
16+ - script : |
17+ sudo apt-get update
18+ sudo apt-get install -y build-essential cmake curl git python3 python3-pip python3-dev python3-venv unixodbc-dev
19+ displayName: 'Install build dependencies for CodeQL'
20+
21+ - task : UsePythonVersion@0
22+ inputs :
23+ versionSpec : ' 3.13'
24+ addToPath : true
25+ displayName : ' Use Python 3.13 for CodeQL'
26+
27+ - script : |
28+ python -m pip install --upgrade pip
29+ pip install -r requirements.txt
30+ displayName: 'Install Python dependencies for CodeQL'
31+
32+ - task : CodeQL3000Init@0
33+ inputs :
34+ Enabled : true
35+ displayName : ' Initialize CodeQL'
36+
37+ # Build the C++ extension for CodeQL analysis
38+ - script : |
39+ cd mssql_python/pybind
40+ chmod +x build.sh
41+ ./build.sh
42+ displayName: 'Build C++ extension for CodeQL analysis'
43+
44+ - task : CodeQL3000Finalize@0
45+ condition : always()
46+ displayName : ' Finalize CodeQL'
47+
1048- job : PytestOnWindows
1149 displayName : ' Windows x64'
1250 pool :
@@ -72,11 +110,11 @@ jobs:
72110 testResultsFiles : ' **/test-results.xml'
73111 testRunTitle : ' Publish test results'
74112
75- - task : PublishCodeCoverageResults@1
76- inputs :
77- codeCoverageTool : ' Cobertura'
78- summaryFileLocation : ' coverage.xml'
79- displayName : ' Publish code coverage results'
113+ # - task: PublishCodeCoverageResults@1
114+ # inputs:
115+ # codeCoverageTool: 'Cobertura'
116+ # summaryFileLocation: 'coverage.xml'
117+ # displayName: 'Publish code coverage results'
80118
81119- job : PytestOnMacOS
82120 displayName : ' macOS x86_64'
@@ -1477,3 +1515,79 @@ jobs:
14771515 inputs :
14781516 testResultsFiles : ' **/test-results-alpine-arm64.xml'
14791517 testRunTitle : ' Publish pytest results on Alpine ARM64'
1518+
1519+ - job : CodeCoverageReport
1520+ displayName : ' Full Code Coverage Report in Ubuntu x86_64'
1521+ pool :
1522+ vmImage : ' ubuntu-latest'
1523+
1524+ steps :
1525+ - script : |
1526+ # Install build dependencies
1527+ sudo apt-get update
1528+ sudo apt-get install -y cmake gcc g++ lcov unixodbc-dev llvm clang
1529+ displayName: 'Install build dependencies'
1530+
1531+ - script : |
1532+ # Start SQL Server container
1533+ docker pull mcr.microsoft.com/mssql/server:2022-latest
1534+ docker run \
1535+ --name sqlserver \
1536+ -e ACCEPT_EULA=Y \
1537+ -e MSSQL_SA_PASSWORD="$(DB_PASSWORD)" \
1538+ -p 1433:1433 \
1539+ -d mcr.microsoft.com/mssql/server:2022-latest
1540+
1541+ # Wait until SQL Server is ready
1542+ for i in {1..30}; do
1543+ docker exec sqlserver \
1544+ /opt/mssql-tools18/bin/sqlcmd \
1545+ -S localhost \
1546+ -U SA \
1547+ -P "$(DB_PASSWORD)" \
1548+ -C -Q "SELECT 1" && break
1549+ sleep 2
1550+ done
1551+ displayName: 'Start SQL Server container'
1552+ env:
1553+ DB_PASSWORD: $(DB_PASSWORD)
1554+
1555+ - script : |
1556+ # Install Python dependencies
1557+ python -m pip install --upgrade pip
1558+ pip install -r requirements.txt
1559+ pip install coverage-lcov lcov-cobertura
1560+ displayName: 'Install Python dependencies'
1561+
1562+ - script : |
1563+ # Build pybind bindings with coverage instrumentation
1564+ cd mssql_python/pybind
1565+ ./build.sh codecov
1566+ displayName: 'Build pybind bindings with coverage'
1567+
1568+ - script : |
1569+ # Generate unified coverage (Python + C++)
1570+ chmod +x ./generate_codecov.sh
1571+ ./generate_codecov.sh
1572+
1573+ # Convert unified LCOV to Cobertura XML for ADO reporting
1574+ lcov_cobertura total.info --output unified-coverage/coverage.xml
1575+ displayName: 'Generate unified coverage (Python + C++)'
1576+ env:
1577+ DB_CONNECTION_STRING: 'Driver=ODBC Driver 18 for SQL Server;Server=tcp:127.0.0.1,1433;Database=master;Uid=SA;Pwd=$(DB_PASSWORD);TrustServerCertificate=yes'
1578+ DB_PASSWORD: $(DB_PASSWORD)
1579+
1580+ - task : PublishTestResults@2
1581+ condition : succeededOrFailed()
1582+ inputs :
1583+ testResultsFiles : ' **/test-results.xml'
1584+ testRunTitle : ' Publish pytest results with unified coverage'
1585+
1586+ - task : PublishCodeCoverageResults@2
1587+ condition : succeededOrFailed()
1588+ inputs :
1589+ codeCoverageTool : Cobertura
1590+ summaryFileLocation : ' unified-coverage/coverage.xml'
1591+ reportDirectory : ' unified-coverage'
1592+ failIfCoverageEmpty : true
1593+ displayName : ' Publish unified code coverage results'
0 commit comments