Skip to content

Commit 2dfc2cc

Browse files
authored
sp_doc: add indexes (#176)
* add `<br>` to safe list for markdown linter * improve some variable naming and data type usage * add view/table indexes + tests * upgrade pester to 5.1.0+ * add timeouts to unit test calls * remove buggy sensitivity classification test (#177 )
1 parent 732456e commit 2dfc2cc

20 files changed

+2068
-1082
lines changed

.github/linter-conf/.markdown-lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ MD013:
2626
tables: false
2727
MD024: false
2828
MD033:
29-
allowed_elements: ["details", "summary", "img", "sub"]
29+
allowed_elements: ["details", "summary", "img", "sub", "br"]
3030

3131

3232

.vscode/settings.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@
22
"markdownlint.config": {
33
"MD024": false,
44
"MD010": {
5-
"code_blocks": false },
5+
"code_blocks": false
6+
},
67
"MD033": {
7-
"allowed_elements": ["details", "summary", "img", "sub"] },
8+
"allowed_elements": ["details", "summary", "img", "sub", "br"]
9+
},
810
"MD013": {
911
"code_blocks": false,
10-
"tables": false}
12+
"tables": false
13+
}
1114
},
1215
"powershell.codeFormatting.trimWhitespaceAroundPipe": true,
1316
"powershell.codeFormatting.useCorrectCasing": true

appveyor/appveyor.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ environment:
1313
AZURE_SQL_PASS:
1414
secure: 'rYm3nE1kwpbdE7QtyLb8CjvA1ENjY3usz3Qqskf1TXU='
1515
CI_COMMIT_MSG: 'CI produced files'
16-
1716
APPVEYOR_RDP_PASSWORD: Np^VNSzJI5#OmRdUNqro2T9UVkCdZ
1817
TARGET_DB: tSQLt
1918
COV_REPORT: appveyor\sqlcover\Coverage.opencoverxml
@@ -67,10 +66,8 @@ clone_script:
6766
- git config --global core.safecrlf false
6867
- git clone -q --single-branch --branch=%APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH% https://github.com/LowlyDBA/dba-multitool.git %APPVEYOR_BUILD_FOLDER%
6968
- cd %APPVEYOR_BUILD_FOLDER%
70-
- ps: .\appveyor\skip_ci_commit.ps1
7169

7270
install:
73-
- ps: Install-Product node ''
7471
- ps: .\appveyor\install_dependencies.ps1
7572
- ps: .\appveyor\start_sqlserver.ps1
7673
- ps: .\appveyor\install_tsqlt.ps1
@@ -88,7 +85,7 @@ for:
8885

8986
# Setup codecov, SQL Cover
9087
before_test:
91-
- ps: .\appveyor\install_dependencies.ps1 -CodeCoverage
88+
- ps: .\appveyor\install_dependencies.ps1 -CodeCoverageOnly
9289

9390
# Run tests with SQL Cover analysis
9491
test_script:
@@ -101,6 +98,9 @@ for:
10198
- codecov -f %COV_REPORT%
10299
- ps: .\appveyor\push_git_changes.ps1
103100

101+
#on_finish:
102+
#- ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
103+
104104
# Azure SQL: No need to start SQL Server locally
105105
-
106106
matrix:

appveyor/generate_sample_markdown.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ Invoke-DbaQuery -SqlInstance $SqlInstance -Database $UtilityDatabase -Query $Que
3030

3131
# Remove footer to avoid eternal appveyor build loop from file diffs
3232
$Temp = Get-Content $SampleMarkdown
33-
$Temp[0..($Temp.Length - 4)] | Out-File $SampleMarkdown -Encoding utf8
33+
$Temp[0..($Temp.Length - 4)] | Out-File $SampleMarkdown -Encoding ascii

appveyor/install_dependencies.ps1

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,15 @@
33

44
param(
55
[Parameter()]
6-
[switch]$CodeCoverage,
6+
[switch]$CodeCoverageOnly,
77
$Color = "Green"
88
)
99

10-
Write-Host "Installing dependencies..." -ForegroundColor $Color
1110

12-
# DbaTools
13-
if (!(Get-Module -ListAvailable -Name DbaTools)) {
14-
$DbaToolsJob = Start-Job -ScriptBlock { Install-Module DbaTools -Force -AllowClobber }
15-
}
16-
17-
# Pester
18-
if (!(Get-InstalledModule -Name Pester -MinimumVersion 5.0.0 -ErrorAction SilentlyContinue)) {
19-
Install-Module Pester -Force -AllowClobber -WarningAction SilentlyContinue -SkipPublisherCheck -MinimumVersion 5.0.0
20-
}
21-
22-
if (!(Get-Module -Name Pester | Where-Object { $PSItem.Version -lt 5.0.0 })) {
23-
if (Get-Module -Name Pester) {
24-
Remove-Module Pester -Force
25-
}
26-
Import-Module Pester -MinimumVersion 4.0.0
27-
}
11+
if ($CodeCoverageOnly.IsPresent) {
12+
Write-Host "Installing code coverage tool..." -ForegroundColor $Color
2813

29-
# GoEddie SQLCover
30-
If ($CodeCoverage.IsPresent) {
31-
# Install code coverage tool
14+
# GoEddie SQLCover
3215
If (!(Get-Package -Name GOEddie.SQLCover -ErrorAction SilentlyContinue)) {
3316
Install-Package GOEddie.SQLCover -Force | Out-Null
3417
}
@@ -37,6 +20,27 @@ If ($CodeCoverage.IsPresent) {
3720
choco install codecov --no-progress --limit-output | Out-Null
3821
}
3922

40-
If ($DbaToolsJob) {
41-
Wait-Job $DbaToolsJob.Id | Out-Null
42-
}
23+
else {
24+
Write-Host "Installing dependencies..." -ForegroundColor $Color
25+
26+
# DbaTools
27+
if (!(Get-Module -ListAvailable -Name DbaTools)) {
28+
$DbaToolsJob = Start-Job -ScriptBlock { Install-Module DbaTools -Force -AllowClobber }
29+
}
30+
31+
# Pester
32+
if (!(Get-InstalledModule -Name Pester -MaximumVersion 5.1.9 -ErrorAction SilentlyContinue)) {
33+
Install-Module Pester -Force -AllowClobber -WarningAction SilentlyContinue -SkipPublisherCheck -MaximumVersion 5.1.9
34+
}
35+
36+
if (!(Get-Module -Name Pester | Where-Object { $PSItem.Version -lt 5.1.0 })) {
37+
if (Get-Module -Name Pester) {
38+
Remove-Module Pester -Force
39+
}
40+
Import-Module Pester -MaximumVersion 5.1.9 -Force
41+
}
42+
43+
If ($DbaToolsJob) {
44+
Wait-Job $DbaToolsJob.Id | Out-Null
45+
}
46+
}

appveyor/install_tsqlt.ps1

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,13 @@ param(
1414

1515
Write-Host "Downloading and installing tSQLt..." -ForegroundColor $Color
1616

17-
# BaseUrl gets the latest version by default - blocked by https://github.com/LowlyDBA/dba-multitool/issues/165
18-
$Version = "1-0-5873-27393"
19-
$DownloadUrl = "http://tsqlt.org/download/tsqlt/?version=" + $Version
17+
$DownloadUrl = "http://tsqlt.org/download/tsqlt/?version="
2018
$TempPath = [System.IO.Path]::GetTempPath()
2119
$ZipFile = Join-Path $TempPath "tSQLt.zip"
2220
$ZipFolder = Join-Path $TempPath "tSQLt"
23-
#$SetupFile = Join-Path $ZipFolder "PrepareServer.sql" # Used in latest version after 1.0.5873.27393
24-
$SetupFile = Join-Path $ZipFolder "SetClrEnabled.sql"
2521
$InstallFile = Join-Path $ZipFolder "tSQLt.class.sql"
2622
$CreateDbQuery = "CREATE DATABASE [tSQLt];"
23+
$SetupFile = Join-Path $ZipFolder "PrepareServer.sql"
2724
$CLRSecurityQuery = "
2825
/* Turn off CLR Strict for 2017+ fix */
2926
IF EXISTS (SELECT 1 FROM sys.configurations WHERE name = 'clr strict security')
@@ -36,36 +33,40 @@ BEGIN
3633
END
3734
GO"
3835

39-
40-
# Download
41-
Try {
42-
Invoke-WebRequest -Uri $DownloadUrl -OutFile $ZipFile -ErrorAction Stop -UseBasicParsing
43-
Expand-Archive -Path $ZipFile -DestinationPath $ZipFolder -Force
44-
}
45-
46-
Catch {
47-
Write-Error -Message "Error downloading tSQLt - try manually fetching from $DownloadUrl"
48-
}
49-
5036
$Hash = @{
5137
SqlInstance = $SqlInstance
5238
Database = $Database
5339
EnableException = $true
5440
}
5541

56-
# Setup
42+
# Cant use latest for AzureSQL yet
43+
# https://github.com/LowlyDBA/dba-multitool/issues/165
5744
If ($IsAzureSQL) {
45+
$Version = "1-0-5873-27393"
46+
$DownloadUrl = $DownloadUrl + $Version
47+
48+
# Azure creds
5849
$SecPass = ConvertTo-SecureString -String $Pass -AsPlainText -Force
5950
$Credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $User, $SecPass
6051
$Hash.add("SqlCredential", $Credential)
6152
}
6253

63-
Else {
54+
# Download
55+
Try {
56+
Invoke-WebRequest -Uri $DownloadUrl -OutFile $ZipFile -ErrorAction Stop -UseBasicParsing
57+
Expand-Archive -Path $ZipFile -DestinationPath $ZipFolder -Force
58+
}
59+
60+
Catch {
61+
Write-Error -Message "Error downloading tSQLt - try manually fetching from $DownloadUrl"
62+
}
63+
64+
# Prep
65+
If (-not $IsAzureSQL) {
6466
Invoke-DbaQuery -SqlInstance $SqlInstance -Database "master" -Query $CreateDbQuery
65-
# DbaQuery doesn't play nice with the setup script GOs - default back to sqlcmd
6667
Invoke-Command -ScriptBlock { sqlcmd -S $SqlInstance -d $Database -i $SetupFile } | Out-Null
6768
Invoke-DbaQuery @Hash -Query $CLRSecurityQuery
6869
}
6970

7071
# Install
71-
Invoke-DbaQuery @Hash -File $InstallFile
72+
Invoke-DbaQuery @Hash -File $InstallFile -Verbose

appveyor/run_pester_tests.ps1

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,6 @@ If ($CodeCoverage.IsPresent) {
9292
Start-CodeCoverage @Hash
9393
}
9494

95-
# Generate all-in-one installer script
96-
Get-ChildItem -Path ".\" -Filter "sp_*.sql" | Get-Content | Out-File $InstallerFile -Encoding utf8
97-
9895
# Run Tests
9996
ForEach ($file in $TestFiles) {
10097
If (!$LocalTest.IsPresent) { Add-AppveyorTest -Name $file.BaseName -Framework NUnit -Filename $file.FullName -Outcome Running }

appveyor/skip_ci_commit.ps1

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)