Skip to content

Commit 9a3d516

Browse files
authored
Merge pull request #113 from LowlyDBA/development
Development
2 parents c9a379d + c4f2d63 commit 9a3d516

22 files changed

+1108
-482
lines changed

appveyor/appveyor.yml

Lines changed: 62 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,10 @@ 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
12-
MSSQL_LOGIN: sa
13-
MSSQL_PASS: Password12!
14-
TSQLTSETCLR: tests\tSQLt\SetClrEnabled.sql
15-
TSQLTCREATEDB: tests\tSQLt\CreateDatabase.sql
16-
TSQLTINSTALL: tests\tSQLt\tSQLt.class.sql
17-
TSQLTBUILDPATH: tests\build
18-
TSQLTTESTPATH: tests\run
1914
TARGET_DB: tSQLt
2015
COV_REPORT: appveyor\sqlcover\Coverage.opencoverxml
2116

@@ -25,64 +20,80 @@ environment:
2520
DB_INSTANCE: (local)\SQL2019
2621
LINT_CONFIG: appveyor\tsqllint\.tsqllintrc_150
2722
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
2834

2935
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
3036
MSSQL: SQL2017
3137
DB_INSTANCE: (local)\SQL2017
3238
LINT_CONFIG: appveyor\tsqllint\.tsqllintrc_140
39+
LATEST: False
40+
AzureSQL: False
3341

3442
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
3543
MSSQL: SQL2016
3644
DB_INSTANCE: (local)\SQL2016
3745
LINT_CONFIG: appveyor\tsqllint\.tsqllintrc_130
46+
LATEST: False
47+
AzureSQL: False
3848

3949
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
4050
MSSQL: SQL2014
4151
DB_INSTANCE: (local)\SQL2014
4252
LINT_CONFIG: appveyor\tsqllint\.tsqllintrc_120
53+
LATEST: False
54+
AzureSQL: False
4355

4456
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
4557
MSSQL: SQL2012SP1
4658
DB_INSTANCE: (local)\SQL2012SP1
4759
LINT_CONFIG: appveyor\tsqllint\.tsqllintrc_110
60+
LATEST: False
61+
AzureSQL: False
4862

4963
clone_script:
50-
- git config --global credential.helper store
51-
- ps: Add-Content "$HOME\.git-credentials" "https://$($env:access_token):[email protected]`n" -NoNewLine
52-
- git config --global user.email "[email protected]"
53-
- git config --global user.name "Appveyor"
54-
- git config --global core.safecrlf false
55-
- git clone -q --single-branch --branch=%APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH% https://github.com/LowlyDBA/ExpressSQL.git %APPVEYOR_BUILD_FOLDER%
56-
- cd %APPVEYOR_BUILD_FOLDER%
64+
- git config --global credential.helper store
65+
- ps: Add-Content "$HOME\.git-credentials" "https://$($env:access_token):[email protected]`n" -NoNewLine
66+
- git config --global user.email "[email protected]"
67+
- git config --global user.name "Appveyor"
68+
- git config --global core.safecrlf false
69+
- git clone -q --single-branch --branch=%APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH% https://github.com/LowlyDBA/ExpressSQL.git %APPVEYOR_BUILD_FOLDER%
70+
- cd %APPVEYOR_BUILD_FOLDER%
5771

5872
install:
59-
- ps: Install-Module SqlServer -Force -AllowClobber
60-
- npm install tsqllint -g
61-
- ps: .\appveyor\start_sqlserver.ps1
62-
- ps: .\appveyor\install_tsqlt.ps1
73+
- ps: .\appveyor\install_dependencies.ps1
74+
- ps: .\appveyor\start_sqlserver.ps1
75+
- ps: .\appveyor\install_tsqlt.ps1
6376

6477
build_script:
65-
- ps: .\appveyor\make_combined_script.ps1
66-
- ps: .\appveyor\install_expsql.ps1
67-
- ps: .\appveyor\build_tsqlt_tests.ps1
68-
- echo Running TSQLLint tests
69-
- npx tsqllint -c %LINT_CONFIG% *.sql
78+
- ps: .\appveyor\make_combined_script.ps1
79+
- ps: .\appveyor\install_expsql.ps1
80+
- ps: .\appveyor\build_tsqlt_tests.ps1
7081

7182
# Non-covered test run
7283
test_script:
73-
- ps: .\appveyor\run_tsqlt_tests.ps1
84+
- ps: .\appveyor\run_tsqllint.ps1
85+
- ps: .\appveyor\run_tsqlt_tests.ps1
7486

75-
# Only run code cov & push changes on latest build env
7687
for:
77-
-
88+
# Latest SQL Server - Code cov & Upload
89+
-
7890
matrix:
7991
only:
8092
- LATEST: True
8193

8294
# Setup codecov, SQL Cover
8395
before_test:
84-
- ps: Install-Package GOEddie.SQLCover -Force | Out-Null
85-
- ps: choco install codecov --no-progress --limit-output | Out-Null
96+
- ps: .\appveyor\install_coverage_dependencies.ps1
8697

8798
# Run tests with SQL Cover analysis
8899
test_script:
@@ -91,4 +102,26 @@ for:
91102
# Upload code coverage report, push generated files
92103
on_success:
93104
- codecov -f %COV_REPORT%
94-
- ps: .\appveyor\push_git_changes.ps1
105+
- ps: .\appveyor\push_git_changes.ps1
106+
107+
# Azure SQL
108+
-
109+
matrix:
110+
only:
111+
- AzureSQL: True
112+
113+
install:
114+
- ps: .\appveyor\install_dependencies.ps1
115+
- ps: .\appveyor\install_tsqlt.ps1
116+
117+
# Setup codecov, SQL Cover
118+
#before_test:
119+
# - ps: .\appveyor\install_coverage_dependencies.ps1
120+
121+
# Run tests with SQL Cover analysis
122+
#test_script:
123+
# - ps: .\appveyor\sqlcover\Run_SQLCover.ps1
124+
125+
# Upload code coverage report, push generated files
126+
#on_success:
127+
# - codecov -f %COV_REPORT%

appveyor/build_tsqlt_tests.ps1

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,23 @@
1-
Write-Host "Building tSQLt Tests"
1+
param(
2+
[Parameter()]
3+
[string]$SqlInstance = $env:DB_INSTANCE,
4+
[string]$Database = $env:TARGET_DB,
5+
[string]$TestPath = "tests\build",
6+
[bool]$IsAzureSQL = [System.Convert]::ToBoolean($env:AzureSQL),
7+
[string]$User = $env:AZURE_SQL_USER,
8+
[string]$Pass = $env:AZURE_SQL_PASS,
9+
$Color = "Green"
10+
)
211

3-
ForEach ($filename in Get-Childitem -Path $env:TSQLTBUILDPATH -Filter "*.sql") {
4-
Invoke-SqlCmd -ServerInstance $env:DB_INSTANCE -Database $env:TARGET_DB -InputFile $filename.fullname -Username $env:MSSQL_LOGIN -Password $env:MSSQL_PASS
5-
}
12+
Write-Host "Building tSQLt Tests..." -ForegroundColor $Color
13+
14+
If ($IsAzureSQL) {
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
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Install code coverage tool
2+
Install-Package GOEddie.SQLCover -Force | Out-Null
3+
4+
# Install codecov.io uploader
5+
choco install codecov --no-progress --limit-output | Out-Null

appveyor/install_dependencies.ps1

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
param(
2+
[Parameter()]
3+
$Color = "Green"
4+
)
5+
6+
Write-Host "Installing dependencies..." -ForegroundColor $Color
7+
8+
# TSQLLinter
9+
# Try/Catch to stop appveyor unnecessary errors
10+
Try { npm install tsqllint -g | Out-Null }
11+
Catch { }
12+
13+
14+
# SQLServer Module
15+
if (!(Get-Module -ListAvailable -Name SqlServer)) {
16+
Install-Module SqlServer -Force -AllowClobber
17+
}

appveyor/install_expsql.ps1

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1-
Write-Host "Installing ExpressSQL Scripts"
1+
param(
2+
[Parameter()]
3+
[string]$SqlInstance = $env:DB_INSTANCE,
4+
[string]$Database = $env:TARGET_DB,
5+
[bool]$IsAzureSQL = [System.Convert]::ToBoolean($env:AzureSQL),
6+
[string]$User = $env:AZURE_SQL_USER,
7+
[string]$Pass = $env:AZURE_SQL_PASS,
8+
[string]$Color = "Green"
9+
)
210

3-
Invoke-SqlCmd -ServerInstance $env:DB_INSTANCE -Database $env:TARGET_DB -InputFile "install_expsql.sql" -Username $env:MSSQL_LOGIN -Password $env:MSSQL_PASS
11+
Write-Host "Installing ExpressSQL scripts..." -ForegroundColor $Color
12+
13+
If ($IsAzureSQL) {
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: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,24 @@
1-
Write-Host "Installing tSQLt"
1+
param(
2+
[Parameter()]
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",
10+
[string]$User = $env:AZURE_SQL_USER,
11+
[string]$Pass = $env:AZURE_SQL_PASS,
12+
[bool]$IsAzureSQL = [System.Convert]::ToBoolean($env:AzureSQL)
13+
)
214

3-
$CLRScript = Join-Path $env:APPVEYOR_BUILD_FOLDER $env:TSQLTSETCLR
4-
$CreateDBScript = Join-Path $env:APPVEYOR_BUILD_FOLDER $env:TSQLTCREATEDB
5-
$tSQLtInstallScript = Join-Path $env:APPVEYOR_BUILD_FOLDER $env:TSQLTINSTALL
15+
Write-Host "Installing tSQLt..." -ForegroundColor $Color
616

7-
Invoke-SqlCmd -ServerInstance $env:DB_INSTANCE -Database "master" -InputFile $clrscript -Username $env:MSSQL_LOGIN -Password $env:MSSQL_PASS | Out-Null
8-
Invoke-SqlCmd -ServerInstance $env:DB_INSTANCE -Database "master" -InputFile $CreateDBScript -Username $env:MSSQL_LOGIN -Password $env:MSSQL_PASS | Out-Null
9-
Invoke-SqlCmd -ServerInstance $env:DB_INSTANCE -Database $env:TARGET_DB -InputFile $tSQLtInstallScript -Username $env:MSSQL_LOGIN -Password $env:MSSQL_PASS
17+
If ($IsAzureSQL) {
18+
Invoke-SqlCmd -ServerInstance $SqlInstance -Database $Database -InputFile $tSQLtInstallScript -Username $User -Password $Pass
19+
}
20+
Else {
21+
Invoke-SqlCmd -ServerInstance $SqlInstance -Database $Master -InputFile $clrscript | Out-Null
22+
Invoke-SqlCmd -ServerInstance $SqlInstance -Database $Master -InputFile $CreateDBScript | Out-Null
23+
Invoke-SqlCmd -ServerInstance $SqlInstance -Database $Database -InputFile $tSQLtInstallScript
24+
}

appveyor/run_tsqllint.ps1

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
param(
2+
[Parameter()]
3+
$Config = $env:LINT_CONFIG,
4+
$Color = "Green"
5+
)
6+
7+
Write-Host "Running TSQLLint with config $Config..." -ForegroundColor $Color
8+
tsqllint -c $Config *.sql

appveyor/run_tsqlt_tests.ps1

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,27 @@
11
param(
22
[Parameter()]
3-
$FilePath = $env:TSQLTTESTPATH,
4-
$SqlInstance = $env:DB_INSTANCE,
5-
$Database = $env:TARGET_DB,
6-
$SqlUser = $env:MSSQL_LOGIN,
7-
$SqlPass = $env:MSSQL_PASS,
8-
$SQLAuth = $true
3+
[string]$FilePath = "tests\run",
4+
[string]$SqlInstance = $env:DB_INSTANCE,
5+
[string]$Database = $env:TARGET_DB,
6+
[bool]$IsAzureSQL = [System.Convert]::ToBoolean($env:AzureSQL),
7+
[string]$User = $env:AZURE_SQL_USER,
8+
[string]$Pass = $env:AZURE_SQL_PASS,
9+
[string]$Color = "Green"
910
)
1011

11-
Write-Host "Run tSQLt Tests"
12-
13-
ForEach ($filename in Get-Childitem -Path $FilePath -Filter "*.sql") {
14-
If ($SQLAuth) {
15-
Invoke-SqlCmd -ServerInstance $SqlInstance -Database $Database -InputFile $filename.fullname -Username $SqlUser -Password $SqlPass -Verbose | Out-Null
12+
Write-Host "Running tSQLt Tests..." -ForegroundColor $Color
13+
Try {
14+
If ($IsAzureSQL) {
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+
}
1618
}
1719
Else {
18-
Invoke-SqlCmd -ServerInstance $SqlInstance -Database $Database -InputFile $filename.fullname -Verbose | Out-Null
20+
ForEach ($filename in Get-Childitem -Path $FilePath -Filter "*.sql") {
21+
Invoke-SqlCmd -ServerInstance $SqlInstance -Database $Database -InputFile $filename.fullname -Verbose | Out-Null
22+
}
1923
}
24+
}
25+
Catch {
26+
Write-Error "Unit test error!"
2027
}

0 commit comments

Comments
 (0)