Skip to content

Commit 7ce0bad

Browse files
authored
Merge pull request #179 from LowlyDBA/development
2 parents fb04d3f + ab83e6e commit 7ce0bad

22 files changed

+2216
-1180
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: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"markdownlint.config": {
3+
"MD024": false,
4+
"MD010": {
5+
"code_blocks": false
6+
},
7+
"MD033": {
8+
"allowed_elements": ["details", "summary", "img", "sub", "br"]
9+
},
10+
"MD013": {
11+
"code_blocks": false,
12+
"tables": false
13+
}
14+
},
15+
"powershell.codeFormatting.trimWhitespaceAroundPipe": true,
16+
"powershell.codeFormatting.useCorrectCasing": true
17+
}

appveyor/appveyor.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ pull_requests:
44
do_not_increment_build_number: false
55
max_jobs: 2
66
build: off
7-
skip_commits:
8-
author: Appveyor
7+
# skip_commits:
8+
# author: Appveyor
99

1010
environment:
1111
access_token:
1212
secure: 'E5I+i+CQyj9EHusDrPSQKHRXmzmpTujYAoFxlvJjvSRSEQHHzqTBIFR1VuPbwLMi'
1313
AZURE_SQL_PASS:
1414
secure: 'rYm3nE1kwpbdE7QtyLb8CjvA1ENjY3usz3Qqskf1TXU='
15-
15+
CI_COMMIT_MSG: 'CI produced files'
1616
APPVEYOR_RDP_PASSWORD: Np^VNSzJI5#OmRdUNqro2T9UVkCdZ
1717
TARGET_DB: tSQLt
1818
COV_REPORT: appveyor\sqlcover\Coverage.opencoverxml
@@ -68,10 +68,10 @@ clone_script:
6868
- cd %APPVEYOR_BUILD_FOLDER%
6969

7070
install:
71-
- ps: Install-Product node ''
7271
- ps: .\appveyor\install_dependencies.ps1
7372
- ps: .\appveyor\start_sqlserver.ps1
7473
- ps: .\appveyor\install_tsqlt.ps1
74+
# - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
7575

7676
# Non-covered test run
7777
test_script:
@@ -86,21 +86,21 @@ for:
8686

8787
# Setup codecov, SQL Cover
8888
before_test:
89-
- ps: .\appveyor\install_dependencies.ps1 -CodeCoverage
89+
- ps: .\appveyor\install_dependencies.ps1 -CodeCoverageOnly
9090

9191
# Run tests with SQL Cover analysis
9292
test_script:
9393
- ps: .\appveyor\run_pester_tests.ps1 -CodeCoverage
9494

95-
# Build markdown w/ sp_doc
95+
# Build markdown with sp_doc
96+
# Upload code coverage report, push generated files
9697
after_test:
9798
- ps: .\appveyor\generate_sample_markdown.ps1
98-
99-
# Upload code coverage report, push generated files
100-
on_success:
10199
- codecov -f %COV_REPORT%
102100
- ps: .\appveyor\push_git_changes.ps1
103101

102+
# on_finish:
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: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,12 @@ 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"
26-
$CreateDbQuery = "CREATE DATABASE [tSQLt];"
22+
$SetupFile = Join-Path $ZipFolder "PrepareServer.sql"
2723
$CLRSecurityQuery = "
2824
/* Turn off CLR Strict for 2017+ fix */
2925
IF EXISTS (SELECT 1 FROM sys.configurations WHERE name = 'clr strict security')
@@ -36,36 +32,40 @@ BEGIN
3632
END
3733
GO"
3834

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-
5035
$Hash = @{
5136
SqlInstance = $SqlInstance
5237
Database = $Database
5338
EnableException = $true
5439
}
5540

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

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

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

appveyor/push_git_changes.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ $StagedFiles = git diff --staged
66

77
# Commit & push if stated
88
If ($StagedFiles) {
9-
git commit -a -m "CI produced files" -q
9+
git commit -a -m $env:CI_COMMIT_MSG -q
1010
git push origin $env:APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH -f -q
1111
}

appveyor/run_pester_tests.ps1

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,15 @@ $TestFiles = Get-ChildItem -Path .\tests\*.Tests.ps1
2323
$FailedTests = 0
2424

2525
function Start-CodeCoverage {
26-
param(
27-
[string]$SqlInstance,
28-
[string]$Database,
29-
[string]$User,
30-
[string]$Pass,
31-
[bool]$IsAzureSQL,
32-
[System.ConsoleColor]$Color
33-
)
26+
param(
27+
[string]$SqlInstance,
28+
[string]$Database,
29+
[string]$User,
30+
[string]$Pass,
31+
[bool]$IsAzureSQL,
32+
[System.ConsoleColor]$Color
33+
)
34+
3435
# Setup vars
3536
$ConnString = "server=$SqlInstance;initial catalog=$Database;Trusted_Connection=yes"
3637
If ($IsAzureSQL) {
@@ -52,10 +53,10 @@ param(
5253
}
5354

5455
function Complete-CodeCoverage {
55-
param (
56-
[string]$CoverageXMLPath,
57-
[string]$Color
58-
)
56+
param (
57+
[string]$CoverageXMLPath,
58+
[string]$Color
59+
)
5960
# Stop covering
6061
Write-Host "Stopping SQLCover..." -ForegroundColor $Color
6162
$coverageResults = $global:SQLCover.Stop()
@@ -91,9 +92,6 @@ If ($CodeCoverage.IsPresent) {
9192
Start-CodeCoverage @Hash
9293
}
9394

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

0 commit comments

Comments
 (0)