Skip to content

Commit 6824dd9

Browse files
lowlydbaAppveyor
andauthored
Azure sql compatibility (#110)
* make sp_sizeoptimiser Azure SQL compatible * suppress npm output * make sp_doc Azure SQL compatible * Make sp_helpme Azure SQL compatible * setup Azure SQL build env * Update README.md * Update appveyor.yml * CI produced files * Update appveyor.yml * Fix test bugs * CI produced files * fix missing insert in sp_helpme test * Upload code cov for azure sql run * CI produced files * CI produced files * CI produced files * remove git push from azure sql env Co-authored-by: Appveyor <[email protected]>
1 parent 03f1438 commit 6824dd9

18 files changed

+982
-430
lines changed

appveyor/appveyor.yml

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ max_jobs: 1
77
environment:
88
access_token:
99
secure: 'E5I+i+CQyj9EHusDrPSQKHRXmzmpTujYAoFxlvJjvSRSEQHHzqTBIFR1VuPbwLMi'
10+
AZURE_SQL_PASS:
11+
secure: 'rYm3nE1kwpbdE7QtyLb8CjvA1ENjY3usz3Qqskf1TXU='
1012

1113
APPVEYOR_RDP_PASSWORD: Np^VNSzJI5#OmRdUNqro2T9UVkCdZ
1214
TARGET_DB: tSQLt
@@ -18,26 +20,41 @@ environment:
1820
DB_INSTANCE: (local)\SQL2019
1921
LINT_CONFIG: appveyor\tsqllint\.tsqllintrc_150
2022
LATEST: True
23+
24+
# Azure SQL Env
25+
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
26+
MSSQL: AZURESQL
27+
LINT_CONFIG: appveyor\tsqllint\.tsqllintrc_150
28+
TARGET_DB: expresssql
29+
DB_INSTANCE: expresssql.database.windows.net
30+
LATEST: False
31+
COV_REPORT: appveyor\sqlcover\Coverage_azuresql.opencoverxml
32+
AZURE_SQL_USER: lowlysa
33+
AzureSQL: True
2134

2235
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
2336
MSSQL: SQL2017
2437
DB_INSTANCE: (local)\SQL2017
2538
LINT_CONFIG: appveyor\tsqllint\.tsqllintrc_140
39+
LATEST: False
2640

2741
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
2842
MSSQL: SQL2016
2943
DB_INSTANCE: (local)\SQL2016
3044
LINT_CONFIG: appveyor\tsqllint\.tsqllintrc_130
45+
LATEST: False
3146

3247
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
3348
MSSQL: SQL2014
3449
DB_INSTANCE: (local)\SQL2014
3550
LINT_CONFIG: appveyor\tsqllint\.tsqllintrc_120
51+
LATEST: False
3652

3753
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
3854
MSSQL: SQL2012SP1
3955
DB_INSTANCE: (local)\SQL2012SP1
4056
LINT_CONFIG: appveyor\tsqllint\.tsqllintrc_110
57+
LATEST: False
4158

4259
clone_script:
4360
- git config --global credential.helper store
@@ -63,9 +80,9 @@ test_script:
6380
- ps: .\appveyor\run_tsqllint.ps1
6481
- ps: .\appveyor\run_tsqlt_tests.ps1
6582

66-
# Only run code cov & push changes on latest build env
6783
for:
68-
-
84+
# Latest SQL Server - Code cov & Upload
85+
-
6986
matrix:
7087
only:
7188
- LATEST: True
@@ -81,4 +98,25 @@ for:
8198
# Upload code coverage report, push generated files
8299
on_success:
83100
- codecov -f %COV_REPORT%
84-
- ps: .\appveyor\push_git_changes.ps1
101+
- ps: .\appveyor\push_git_changes.ps1
102+
103+
# Azure SQL - Code cov & Upload
104+
-
105+
matrix:
106+
only:
107+
- AzureSQL: True
108+
109+
install:
110+
- ps: .\appveyor\install_azuresql.ps1
111+
112+
# Setup codecov, SQL Cover
113+
before_test:
114+
- ps: .\appveyor\install_coverage_dependencies.ps1
115+
116+
# Run tests with SQL Cover analysis
117+
test_script:
118+
- ps: .\appveyor\sqlcover\Run_SQLCover.ps1
119+
120+
# Upload code coverage report, push generated files
121+
on_success:
122+
- codecov -f %COV_REPORT%

appveyor/build_tsqlt_tests.ps1

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,23 @@
11
param(
22
[Parameter()]
3-
$SqlInstance = $env:DB_INSTANCE,
4-
$Database = $env:TARGET_DB,
5-
$TestPath = "tests\build",
3+
[string]$SqlInstance = $env:DB_INSTANCE,
4+
[string]$Database = $env:TARGET_DB,
5+
[string]$TestPath = "tests\build",
6+
[string]$IsAzureSQL = $env:AzureSQL,
7+
[string]$User = $env:AZURE_SQL_USER,
8+
[string]$Pass = $env:AZURE_SQL_PASS,
69
$Color = "Green"
710
)
811

912
Write-Host "Building tSQLt Tests..." -ForegroundColor $Color
1013

11-
ForEach ($filename in Get-Childitem -Path $TestPath -Filter "*.sql") {
12-
Invoke-SqlCmd -ServerInstance $SqlInstance -Database $Database -InputFile $filename.fullname
13-
}
14+
If ($IsAzureSQL -eq "True") {
15+
ForEach ($filename in Get-Childitem -Path $TestPath -Filter "*.sql") {
16+
Invoke-SqlCmd -ServerInstance $SqlInstance -Database $Database -InputFile $filename.fullname -Username $User -Password $Pass
17+
}
18+
}
19+
Else {
20+
ForEach ($filename in Get-Childitem -Path $TestPath -Filter "*.sql") {
21+
Invoke-SqlCmd -ServerInstance $SqlInstance -Database $Database -InputFile $filename.fullname
22+
}
23+
}

appveyor/install_azuresql.ps1

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
param(
2+
[Parameter()]
3+
[String]$SqlInstance = $env:DB_INSTANCE,
4+
[String]$Database = $env:TARGET_DB,
5+
[String]$tSQLtInstallScript = "tests\tSQLt\tSQLt.class.sql",
6+
[string]$User = $env:AZURE_SQL_USER,
7+
[string]$Pass = $env:AZURE_SQL_PASS,
8+
[String]$Color = "Green"
9+
)
10+
11+
Write-Host "Installing tSQLt..." -ForegroundColor $Color
12+
Invoke-SqlCmd -ServerInstance $SqlInstance -Database $Database -InputFile $tSQLtInstallScript -Username $User -Password $Pass

appveyor/install_dependencies.ps1

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ param(
66
Write-Host "Installing dependencies..." -ForegroundColor $Color
77

88
# TSQLLinter
9-
npm install tsqllint -g
9+
# Try/Catch to stop appveyor unnecessary errors
10+
Try { npm install tsqllint -g | Out-Null }
11+
Catch { }
12+
1013

1114
# SQLServer Module
1215
if (!(Get-Module -ListAvailable -Name SqlServer)) {

appveyor/install_expsql.ps1

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
11
param(
22
[Parameter()]
3-
$SqlInstance = $env:DB_INSTANCE,
4-
$Database = $env:TARGET_DB,
5-
$Color = "Green"
3+
[string]$SqlInstance = $env:DB_INSTANCE,
4+
[string]$Database = $env:TARGET_DB,
5+
[string]$IsAzureSQL = $env:AzureSQL,
6+
[string]$User = $env:AZURE_SQL_USER,
7+
[string]$Pass = $env:AZURE_SQL_PASS,
8+
[string]$Color = "Green"
69
)
710

811
Write-Host "Installing ExpressSQL scripts..." -ForegroundColor $Color
912

10-
Invoke-SqlCmd -ServerInstance $SqlInstance -Database $Database -InputFile "install_expsql.sql"
13+
If ($IsAzureSQL -eq "True") {
14+
Invoke-SqlCmd -ServerInstance $SqlInstance -Database $Database -InputFile "install_expsql.sql" -Username $User -Password $Pass
15+
}
16+
Else {
17+
Invoke-SqlCmd -ServerInstance $SqlInstance -Database $Database -InputFile "install_expsql.sql"
18+
19+
}

appveyor/install_tsqlt.ps1

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
param(
22
[Parameter()]
3-
$SqlInstance = $env:DB_INSTANCE,
4-
$Database = $env:TARGET_DB,
5-
$CLRScript = "tests\tSQLt\SetClrEnabled.sql",
6-
$CreateDBScript = "tests\tSQLt\CreateDatabase.sql",
7-
$tSQLtInstallScript = "tests\tSQLt\tSQLt.class.sql",
8-
$Color = "Green"
3+
[String]$SqlInstance = $env:DB_INSTANCE,
4+
[String]$Database = $env:TARGET_DB,
5+
[String]$CLRScript = "tests\tSQLt\SetClrEnabled.sql",
6+
[String]$CreateDBScript = "tests\tSQLt\CreateDatabase.sql",
7+
[String]$tSQLtInstallScript = "tests\tSQLt\tSQLt.class.sql",
8+
[String]$Color = "Green",
9+
[String]$Master = "master"
910
)
10-
$Master = "master"
1111

1212
Write-Host "Installing tSQLt..." -ForegroundColor $Color
1313

appveyor/run_tsqlt_tests.ps1

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,27 @@
11
param(
22
[Parameter()]
3-
$FilePath = "tests\run",
4-
$SqlInstance = $env:DB_INSTANCE,
5-
$Database = $env:TARGET_DB,
6-
$Color = "Green"
3+
[string]$FilePath = "tests\run",
4+
[string]$SqlInstance = $env:DB_INSTANCE,
5+
[string]$Database = $env:TARGET_DB,
6+
[string]$IsAzureSQL = $env:AzureSQL,
7+
[string]$User = $env:AZURE_SQL_USER,
8+
[string]$Pass = $env:AZURE_SQL_PASS,
9+
[string]$Color = "Green"
710
)
811

912
Write-Host "Running tSQLt Tests..." -ForegroundColor $Color
10-
11-
ForEach ($filename in Get-Childitem -Path $FilePath -Filter "*.sql") {
12-
Invoke-SqlCmd -ServerInstance $SqlInstance -Database $Database -InputFile $filename.fullname -Verbose | Out-Null
13+
Try {
14+
If ($IsAzureSQL -eq "True") {
15+
ForEach ($filename in Get-Childitem -Path $FilePath -Filter "*.sql") {
16+
Invoke-SqlCmd -ServerInstance $SqlInstance -Database $Database -InputFile $filename.fullname -Verbose -Username $User -Password $Pass | Out-Null
17+
}
18+
}
19+
Else {
20+
ForEach ($filename in Get-Childitem -Path $FilePath -Filter "*.sql") {
21+
Invoke-SqlCmd -ServerInstance $SqlInstance -Database $Database -InputFile $filename.fullname -Verbose | Out-Null
22+
}
23+
}
24+
}
25+
Catch {
26+
Write-Error "Unit test error!"
1327
}

0 commit comments

Comments
 (0)