Skip to content

Commit 4d8629e

Browse files
authored
Merge pull request #169 from LowlyDBA/development
Development
2 parents 083408b + 9c906f3 commit 4d8629e

24 files changed

+1317
-1007
lines changed

.github/CONTRIBUTING.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,9 @@ for your commits to be automatically linted using Github Actions.
4343

4444
### PowerShell
4545

46-
PowerShell is only used in the automation piece of this project, but could probably
47-
benefit from being better documented and standardized. Right now no particular
48-
style is enforced,
49-
but [PSScriptAnalyzer](https://github.com/PowerShell/PSScriptAnalyzer) is recommended.
46+
PowerShell is only used in the automation piece of this project,
47+
but [PSScriptAnalyzer](https://github.com/PowerShell/PSScriptAnalyzer)
48+
is used to lint it for general best practice adherement.
5049

5150
[mdconfig]: https://github.com/LowlyDBA/dba-multitool/blob/master/.github/linters/.markdown-lint.yml
5251
[mdlint]: https://github.com/DavidAnson/markdownlint

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<!--- Why is this change required? What problem does it solve? -->
77

88
<!--- Associated issue number -->
9-
**Issue:**
9+
**Issue:** Fixes
1010

1111
## How Has This Been Tested?
1212
<!--- Please describe in detail how you tested your changes. -->

.github/codecov.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@ coverage:
33
round: down
44
precision: 2
55
status:
6+
project:
7+
default:
8+
# basic
9+
target: auto
10+
threshold: 1%
611
patch: off
712

813
fixes:
9-
- "::"
14+
- "::"

.github/linters/.markdown-lint.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,15 @@
1818
###############
1919
# Rules by id #
2020
###############
21-
MD033:
22-
allowed_elements: ["details", "summary", "img", "sub"]
21+
MD009: false
22+
MD010:
23+
code_blocks: false
2324
MD013:
2425
code_blocks: false
2526
tables: false
2627
MD024: false
27-
MD010:
28-
code_blocks: false
29-
MD009: false
28+
MD033:
29+
allowed_elements: ["details", "summary", "img", "sub"]
30+
31+
32+

.github/workflows/super-linter.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,6 @@ jobs:
4545
- name: Lint Code Base
4646
uses: docker://github/super-linter:v3.13.5
4747
env:
48-
VALIDATE_MD: true
48+
VALIDATE_MARKDOWN: true
49+
VALIDATE_POWERSHELL: true
50+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

appveyor/generate_sample_markdown.ps1

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
param(
2-
[Parameter()]
1+
#PSScriptAnalyzer rule excludes
2+
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingWriteHost', '')]
3+
4+
param(
5+
[Parameter()]
36
[string]$SqlInstance = $env:DB_INSTANCE,
47
[string]$UtilityDatabase = $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,
88
[string]$Color = "Green"
99
)
1010

1111
$ErrorActionPreference = "Stop";
1212
$Url = "https://github.com/Microsoft/sql-server-samples/releases/download/wide-world-importers-v1.0/WideWorldImporters-Full.bak"
1313
$BackupPath = "C:\WideWorldImporters-Full.bak"
1414
$SampleDatabase = "WideWorldImporters"
15-
$SampleMarkdown = "docs/$SampleDatabase.md"
15+
$SampleMarkdown = "docs/assets/$SampleDatabase.md"
1616

1717
Write-Host "Generating $SampleDatabase markdown sample..." -ForegroundColor $Color
1818

@@ -25,7 +25,8 @@ If (!(Get-DbaDatabase -SqlInstance $SqlInstance -Database $SampleDatabase -Warni
2525
}
2626

2727
# Generate documentation
28-
sqlcmd -S $SqlInstance -d $UtilityDatabase -Q "EXEC sp_doc @DatabaseName = '$SampleDatabase';" -o $SampleMarkdown -y 0
28+
$Query = "EXEC sp_doc @DatabaseName = '$SampleDatabase';"
29+
Invoke-DbaQuery -SqlInstance $SqlInstance -Database $UtilityDatabase -Query $Query -As SingleValue | Out-File $SampleMarkdown
2930

3031
# Remove footer to avoid eternal appveyor build loop from file diffs
3132
$Temp = Get-Content $SampleMarkdown

appveyor/install_dependencies.ps1

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
param(
2-
[Parameter()]
1+
#PSScriptAnalyzer rule excludes
2+
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingWriteHost', '')]
3+
4+
param(
5+
[Parameter()]
36
[switch]$CodeCoverage,
47
$Color = "Green"
58
)

appveyor/install_tsqlt.ps1

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
#PSScriptAnalyzer rule excludes
2+
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingWriteHost', '')]
3+
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingConvertToSecureStringWithPlainText', '')]
4+
15
param(
26
[Parameter()]
37
[String]$SqlInstance = $env:DB_INSTANCE,
@@ -10,7 +14,7 @@ param(
1014

1115
Write-Host "Downloading and installing tSQLt..." -ForegroundColor $Color
1216

13-
# BaseUrl gets the latest version by default - blocked by https://github.com/LowlyDBA/dba-multitool/issues/165
17+
# BaseUrl gets the latest version by default - blocked by https://github.com/LowlyDBA/dba-multitool/issues/165
1418
$Version = "1-0-5873-27393"
1519
$DownloadUrl = "http://tsqlt.org/download/tsqlt/?version=" + $Version
1620
$TempPath = [System.IO.Path]::GetTempPath()
@@ -26,7 +30,7 @@ IF EXISTS (SELECT 1 FROM sys.configurations WHERE name = 'clr strict security')
2630
BEGIN
2731
EXEC sp_configure 'show advanced options', 1;
2832
RECONFIGURE;
29-
33+
3034
EXEC sp_configure 'clr strict security', 0;
3135
RECONFIGURE;
3236
END

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 "CI produced files" -q
1010
git push origin $env:APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH -f -q
1111
}

appveyor/run_pester_tests.ps1

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,42 @@
11
using namespace System.IO.Path
22

3-
param(
4-
[Parameter()]
3+
#PSScriptAnalyzer rule excludes
4+
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingWriteHost', '')]
5+
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseShouldProcessForStateChangingFunctions', '')]
6+
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidGlobalVars', '')]
7+
param(
8+
[Parameter()]
59
[switch]$LocalTest,
610
[string]$CoverageXMLPath = $env:COV_REPORT,
711
[string]$SqlInstance = $env:DB_INSTANCE,
812
[string]$Database = $env:TARGET_DB,
913
[bool]$IsAzureSQL = [System.Convert]::ToBoolean($env:AzureSQL),
1014
[string]$User = $env:AZURE_SQL_USER,
1115
[string]$Pass = $env:AZURE_SQL_PASS,
12-
[string]$Color = "Green",
16+
[System.ConsoleColor]$Color = "Green",
1317
[switch]$CodeCoverage
1418
)
19+
1520
. ".\tests\constants.ps1"
1621
$ErrorActionPreference = "Stop"
1722
$TestFiles = Get-ChildItem -Path .\tests\*.Tests.ps1
1823
$FailedTests = 0
1924

2025
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+
)
2134
# Setup vars
35+
$ConnString = "server=$SqlInstance;initial catalog=$Database;Trusted_Connection=yes"
2236
If ($IsAzureSQL) {
2337
$ConnString = "server=$SqlInstance;initial catalog=$Database;User Id=$User;pwd=$Pass"
2438
}
2539

26-
Else {
27-
$ConnString = "server=$SqlInstance;initial catalog=$Database;Trusted_Connection=yes"
28-
}
29-
3040
$NugetPath = (Get-Package GOEddie.SQLCover).Source | Convert-Path
3141
$SQLCoverRoot = Split-Path $NugetPath
3242
$SQLCoverPath = Join-Path $SQLCoverRoot "lib"
@@ -42,7 +52,11 @@ function Start-CodeCoverage {
4252
}
4353

4454
function Complete-CodeCoverage {
45-
# Stop covering
55+
param (
56+
[string]$CoverageXMLPath,
57+
[string]$Color
58+
)
59+
# Stop covering
4660
Write-Host "Stopping SQLCover..." -ForegroundColor $Color
4761
$coverageResults = $global:SQLCover.Stop()
4862

@@ -51,10 +65,10 @@ function Complete-CodeCoverage {
5165
If (!($LocalTest.IsPresent)) {
5266
$SavePath = Join-Path -Path $PSScriptRoot -ChildPath "sqlcover"
5367
$coverageResults.OpenCoverXml() | Out-File $CoverageXMLPath -Encoding utf8
54-
$coverageResults.SaveSourceFiles($SavePath)
68+
$coverageResults.SaveSourceFiles($SavePath)
5569
}
5670

57-
Else {
71+
Else {
5872
# Don't save any files and bring up html report for review
5973
$tmpFile = Join-Path $env:TEMP "Coverage.html"
6074
Set-Content -Path $tmpFile -Value $coverageResults.Html2() -Force
@@ -66,7 +80,15 @@ function Complete-CodeCoverage {
6680

6781
# Start Coverage
6882
If ($CodeCoverage.IsPresent) {
69-
Start-CodeCoverage
83+
$Hash = @{
84+
SqlInstance = $SqlInstance
85+
Database = $Database
86+
User = $User
87+
Pass = $Pass
88+
IsAzureSQL = $IsAzureSQL
89+
Color = $Color
90+
}
91+
Start-CodeCoverage @Hash
7092
}
7193

7294
# Generate all-in-one installer script
@@ -88,7 +110,7 @@ ForEach ($file in $TestFiles) {
88110

89111
# End Coverage
90112
If ($CodeCoverage.IsPresent) {
91-
Complete-CodeCoverage
113+
Complete-CodeCoverage -CoverageXMLPath $CoverageXMLPath -Color $Color
92114
}
93115

94116
# Check for failures

0 commit comments

Comments
 (0)