diff --git a/BuildTasks/GenerateMarkdown.Task.ps1 b/BuildTasks/GenerateMarkdown.Task.ps1 index cfb4204..28ffc98 100644 --- a/BuildTasks/GenerateMarkdown.Task.ps1 +++ b/BuildTasks/GenerateMarkdown.Task.ps1 @@ -27,6 +27,7 @@ task GenerateMarkdown { Module = $ModuleName OutputFolder = "$DocsPath\en-US" WithModulePage = $true + Force = $true } # ErrorAction is set to SilentlyContinue so this diff --git a/BuildTasks/ImportDevModule.Task.ps1 b/BuildTasks/ImportDevModule.Task.ps1 index c868aa7..178bf1f 100644 --- a/BuildTasks/ImportDevModule.Task.ps1 +++ b/BuildTasks/ImportDevModule.Task.ps1 @@ -1,4 +1,4 @@ task ImportDevModule { - ImportModule -Path "$Source\$ModuleName.psd1" -Force + Import-BuildModule -Path "$Source\$ModuleName.psd1" -Force } diff --git a/BuildTasks/ImportModule.Task.ps1 b/BuildTasks/ImportModule.Task.ps1 index a903b45..39e0286 100644 --- a/BuildTasks/ImportModule.Task.ps1 +++ b/BuildTasks/ImportModule.Task.ps1 @@ -1,4 +1,4 @@ -function ImportModule +function Import-BuildModule { param( [string]$path, @@ -29,5 +29,5 @@ function ImportModule } task ImportModule { - ImportModule -Path $ManifestPath + Import-BuildModule -Path $ManifestPath } diff --git a/BuildTasks/InvokeBuildInit.ps1 b/BuildTasks/InvokeBuildInit.ps1 index 620e51d..ae1c03d 100644 --- a/BuildTasks/InvokeBuildInit.ps1 +++ b/BuildTasks/InvokeBuildInit.ps1 @@ -22,6 +22,8 @@ Write-Verbose " ModulePath [$ModulePath]" -Verbose $Script:Folders = 'Classes', 'Includes', 'Internal', 'Private', 'Public', 'Resources' Write-Verbose " Folders [$Folders]" -Verbose +$timestamp = Get-Date -Format o | ForEach-Object { $_ -replace ":", "." } +$PSVersion = $PSVersionTable.PSVersion.ToString() $Script:TestFile = "$BuildRoot\Output\TestResults_PS$PSVersion`_$TimeStamp.xml" Write-Verbose " TestFile [$TestFile]" -Verbose diff --git a/BuildTasks/Pester.Task.ps1 b/BuildTasks/Pester.Task.ps1 index 3a4f2fe..4487ae3 100644 --- a/BuildTasks/Pester.Task.ps1 +++ b/BuildTasks/Pester.Task.ps1 @@ -1,34 +1,34 @@ task Pester { $requiredPercent = $Script:CodeCoveragePercent + Import-Module Pester -Force + $configuration = [PesterConfiguration]::Default + # assing properties & discover via intellisense + $configuration.Run.Path = 'Tests' + $configuration.Filter.Tag = 'Build' + $configuration.Run.PassThru = $true + $configuration.Output.Verbosity = 'Detailed' + $configuration.TestResult.Enabled = $true + $configuration.TestResult.OutputFormat = 'NUnitXml' + $configuration.TestResult.OutputPath = $testFile - $params = @{ - OutputFile = $testFile - OutputFormat = 'NUnitXml' - PassThru = $true - Path = 'Tests' - Show = 'Failed', 'Fails', 'Summary' - Tag = 'Build' - } + if ($requiredPercent -gt 0.00) { - if($requiredPercent -gt 0.00) - { - $params['CodeCoverage'] = 'Output\*\*.psm1' - $params['CodeCoverageOutputFile'] = 'Output\codecoverage.xml' + $configuration.CodeCoverage.Enabled = $true + $configuration.CodeCoverage.OutputPath = 'Output\codecoverage.xml' } - $results = Invoke-Pester @params - if ($results.FailedCount -gt 0) - { - Write-Error -Message "Failed [$($results.FailedCount)] Pester tests." - } + $results = Invoke-Pester -Configuration $configuration + if ($requiredPercent -gt 0.00) { - if($results.codecoverage.NumberOfCommandsAnalyzed -gt 0) - { - $codeCoverage = $results.codecoverage.NumberOfCommandsExecuted / $results.codecoverage.NumberOfCommandsAnalyzed + if ($results.TotalCount -gt 0) { + $CodeCoveragePercent = $results.TotalCount * ($results.PassedCount / 100) + $codeCoverage = [math]::Round($CodeCoveragePercent,2) - if($codeCoverage -lt $requiredPercent) - { - Write-Error ("Failed Code Coverage [{0:P}] below {1:P}" -f $codeCoverage,$requiredPercent) + if ($codeCoverage -lt [Math]::Round($requiredPercent,2)) { + Write-Error ("Failed Code Coverage [{0:P}] below {1:P}" -f $codeCoverage, $requiredPercent) + } } + } elseif ($results.FailedCount -gt 0) { + Write-Error -Message "Failed [$($results.FailedCount)] Pester tests." } } diff --git a/BuildTasks/SetVersion.Task.ps1 b/BuildTasks/SetVersion.Task.ps1 index 9dc7556..f1df7da 100644 --- a/BuildTasks/SetVersion.Task.ps1 +++ b/BuildTasks/SetVersion.Task.ps1 @@ -1,7 +1,7 @@ function GetModulePublicInterfaceMap { param($Path) - $module = ImportModule -Path $Path -PassThru + $module = Import-BuildModule -Path $Path -PassThru $exportedCommands = @( $module.ExportedFunctions.values $module.ExportedCmdlets.values diff --git a/Docs/en-US/Add-SnowSqlRoleMember.md b/Docs/en-US/Add-SnowSqlRoleMember.md index c06f625..32405f7 100644 --- a/Docs/en-US/Add-SnowSqlRoleMember.md +++ b/Docs/en-US/Add-SnowSqlRoleMember.md @@ -21,7 +21,7 @@ Add users to role ## EXAMPLES -### EXAMPLE 1 +### EXEMPLE 1 ``` Add-SnowSqlRoleMember -Role TEST_ROLE -Name TEST_USER ``` diff --git a/Docs/en-US/Disable-SnowSqlUser.md b/Docs/en-US/Disable-SnowSqlUser.md index 0575604..49e2394 100644 --- a/Docs/en-US/Disable-SnowSqlUser.md +++ b/Docs/en-US/Disable-SnowSqlUser.md @@ -21,7 +21,7 @@ Disable user account ## EXAMPLES -### EXAMPLE 1 +### EXEMPLE 1 ``` Disable-SnowSqlUser -Name TEST_USER ``` diff --git a/Docs/en-US/Enable-SnowSqlUser.md b/Docs/en-US/Enable-SnowSqlUser.md index 6ca9346..cd4e71e 100644 --- a/Docs/en-US/Enable-SnowSqlUser.md +++ b/Docs/en-US/Enable-SnowSqlUser.md @@ -21,7 +21,7 @@ Enable user account ## EXAMPLES -### EXAMPLE 1 +### EXEMPLE 1 ``` Enable-SnowSqlUser -Name TEST_USER ``` diff --git a/Docs/en-US/Get-SnowSqlConnection.md b/Docs/en-US/Get-SnowSqlConnection.md index 217a847..8d0ebe7 100644 --- a/Docs/en-US/Get-SnowSqlConnection.md +++ b/Docs/en-US/Get-SnowSqlConnection.md @@ -21,7 +21,7 @@ Gets the current Snowflake connection ## EXAMPLES -### EXAMPLE 1 +### EXEMPLE 1 ``` Get-SnowSqlConnection ``` diff --git a/Docs/en-US/Get-SnowSqlRole.md b/Docs/en-US/Get-SnowSqlRole.md index ab65f58..5acdaa9 100644 --- a/Docs/en-US/Get-SnowSqlRole.md +++ b/Docs/en-US/Get-SnowSqlRole.md @@ -21,7 +21,7 @@ Get list of Snowflake roles ## EXAMPLES -### EXAMPLE 1 +### EXEMPLE 1 ``` Get-SnowSqlRole ``` diff --git a/Docs/en-US/Get-SnowSqlRoleMember.md b/Docs/en-US/Get-SnowSqlRoleMember.md index 8c32411..c475052 100644 --- a/Docs/en-US/Get-SnowSqlRoleMember.md +++ b/Docs/en-US/Get-SnowSqlRoleMember.md @@ -21,7 +21,7 @@ Gets the members of the Snowflake role ## EXAMPLES -### EXAMPLE 1 +### EXEMPLE 1 ``` Get-SnowSqlRoleMember ``` diff --git a/Docs/en-US/Get-SnowSqlUser.md b/Docs/en-US/Get-SnowSqlUser.md index 527b7ca..68e876b 100644 --- a/Docs/en-US/Get-SnowSqlUser.md +++ b/Docs/en-US/Get-SnowSqlUser.md @@ -21,7 +21,7 @@ Get list of Snowflake users ## EXAMPLES -### EXAMPLE 1 +### EXEMPLE 1 ``` Get-SnowSqlUser ``` diff --git a/Docs/en-US/New-SnowSqlRole.md b/Docs/en-US/New-SnowSqlRole.md index 33189fc..11b7850 100644 --- a/Docs/en-US/New-SnowSqlRole.md +++ b/Docs/en-US/New-SnowSqlRole.md @@ -21,7 +21,7 @@ Create a new Snowflake role ## EXAMPLES -### EXAMPLE 1 +### EXEMPLE 1 ``` New-SnowSqlRole -Role TEST_ROLE ``` diff --git a/Docs/en-US/New-SnowSqlUser.md b/Docs/en-US/New-SnowSqlUser.md index 187f574..1af668b 100644 --- a/Docs/en-US/New-SnowSqlUser.md +++ b/Docs/en-US/New-SnowSqlUser.md @@ -22,7 +22,7 @@ Create a new Snowflake user account ## EXAMPLES -### EXAMPLE 1 +### EXEMPLE 1 ``` New-SnowSqlUser -Name TESTUSER -LoginName TESTUSER@CONTOSO.COM -Description 'AD Account' ``` diff --git a/Docs/en-US/Remove-SnowSqlRoleMember.md b/Docs/en-US/Remove-SnowSqlRoleMember.md index 6b35e2a..8594717 100644 --- a/Docs/en-US/Remove-SnowSqlRoleMember.md +++ b/Docs/en-US/Remove-SnowSqlRoleMember.md @@ -21,7 +21,7 @@ Remove Snowflake user from role ## EXAMPLES -### EXAMPLE 1 +### EXEMPLE 1 ``` Remove-SnowSqlRoleMember -Role TEST_ROLE -Name TEST_USER ``` diff --git a/ScriptAnalyzerSettings.psd1 b/ScriptAnalyzerSettings.psd1 index e42e87d..cca85a3 100644 --- a/ScriptAnalyzerSettings.psd1 +++ b/ScriptAnalyzerSettings.psd1 @@ -3,7 +3,7 @@ # subset of: Error, Warning and Information. # Uncomment the following line if you only want Errors and Warnings but # not Information diagnostic records. - Severity = @('Error','Warning') + #Severity = @('Error','Warning') # Use IncludeRules when you want to run only a subset of the default rule set. #IncludeRules = @('PSAvoidDefaultValueSwitchParameter', @@ -18,17 +18,17 @@ # Use ExcludeRules when you want to run most of the default set of rules except # for a few rules you wish to "exclude". Note: if a rule is in both IncludeRules # and ExcludeRules, the rule will be excluded. - ExcludeRules = @('PSUseToExportFieldsInManifest','PSMissingModuleManifestField') + ExcludeRules = @('PSMissingModuleManifestField') # You can use the following entry to supply parameters to rules that take parameters. # For instance, the PSAvoidUsingCmdletAliases rule takes a whitelist for aliases you # want to allow. - Rules = @{ + #Rules = @{ # Do not flag 'cd' alias. - PSAvoidUsingCmdletAliases = @{Whitelist = @('Where','Select')} + # PSAvoidUsingCmdletAliases = @{Whitelist = @('Where','Select')} # Check if your script uses cmdlets that are compatible on PowerShell Core, # version 6.0.0-alpha, on Linux. # PSUseCompatibleCmdlets = @{Compatibility = @("core-6.0.0-alpha-linux")} - } + #} } diff --git a/SnowSQL/SnowSQL.psd1 b/SnowSQL/SnowSQL.psd1 index e7deb16..f50107e 100644 --- a/SnowSQL/SnowSQL.psd1 +++ b/SnowSQL/SnowSQL.psd1 @@ -12,7 +12,7 @@ RootModule = 'SnowSQL.psm1' # Version number of this module. -ModuleVersion = '0.1.1' +ModuleVersion = '0.1.3' # Supported PSEditions # CompatiblePSEditions = @() diff --git a/Tests/Project/Help.Tests.ps1 b/Tests/Project/Help.Tests.ps1 index 954cf88..25b34e4 100644 --- a/Tests/Project/Help.Tests.ps1 +++ b/Tests/Project/Help.Tests.ps1 @@ -1,6 +1,8 @@ $Script:ModuleRoot = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent $Script:ModuleName = $Script:ModuleName = Get-ChildItem $ModuleRoot\*\*.psm1 | Select-object -ExpandProperty BaseName +$Script:SourceRoot = Join-Path -Path $ModuleRoot -ChildPath $ModuleName + Describe "Public commands have comment-based or external help" -Tags 'Build' { $functions = Get-Command -Module $ModuleName $help = foreach ($function in $functions) { @@ -11,20 +13,19 @@ Describe "Public commands have comment-based or external help" -Tags 'Build' { { Context $node.Name { It "Should have a Description or Synopsis" { - ($node.Description + $node.Synopsis) | Should Not BeNullOrEmpty + ($node.Description + $node.Synopsis) | Should -Not -BeNullOrEmpty } - It "Should have an Example" { - $node.Examples | Should Not BeNullOrEmpty + It "Should have an Example" { + $node.Examples | Should -Not -BeNullOrEmpty $node.Examples | Out-String | Should -Match ($node.Name) } - - foreach ($parameter in $node.Parameters.Parameter) + foreach ($par in $node.Parameters.Parameter) { - if ($parameter -notmatch 'WhatIf|Confirm') + if ($par -notmatch 'WhatIf|Confirm') { - It "Should have a Description for Parameter [$($parameter.Name)]" { - $parameter.Description.Text | Should Not BeNullOrEmpty + It "Should have a Description for Parameter [$($par.Name)]" { + $par.Description[0].Text.length | Should -BeGreaterOrEqual 1 } } } diff --git a/Tests/Project/Module.Tests.ps1 b/Tests/Project/Module.Tests.ps1 index f652dc4..411c5d5 100644 --- a/Tests/Project/Module.Tests.ps1 +++ b/Tests/Project/Module.Tests.ps1 @@ -6,7 +6,7 @@ $Script:SourceRoot = Join-Path -Path $ModuleRoot -ChildPath $ModuleName Describe "All commands pass PSScriptAnalyzer rules" -Tag 'Build' { $rules = "$ModuleRoot\ScriptAnalyzerSettings.psd1" $scripts = Get-ChildItem -Path $SourceRoot -Include '*.ps1', '*.psm1', '*.psd1' -Recurse | - Where-Object FullName -notmatch 'Classes' + Where-Object FullName -notmatch 'Classes' foreach ($script in $scripts) { @@ -18,14 +18,14 @@ Describe "All commands pass PSScriptAnalyzer rules" -Tag 'Build' { { It $rule.RuleName { $message = "{0} Line {1}: {2}" -f $rule.Severity, $rule.Line, $rule.Message - $message | Should Be "" + $message | Should -Be "" } } } else { It "Should not fail any rules" { - $results | Should BeNullOrEmpty + $results | Should -BeNullOrEmpty } } } @@ -39,7 +39,7 @@ Describe "Public commands have Pester tests" -Tag 'Build' { { $file = Get-ChildItem -Path "$ModuleRoot\Tests" -Include "$command.Tests.ps1" -Recurse It "Should have a Pester test for [$command]" { - $file.FullName | Should Not BeNullOrEmpty + $file.FullName | Should -Not -BeNullOrEmpty } } } diff --git a/build.ps1 b/build.ps1 index ec892fc..a45409e 100644 --- a/build.ps1 +++ b/build.ps1 @@ -20,7 +20,7 @@ Get-PackageProvider -Name 'NuGet' -ForceBootstrap | Out-Null Install-Module -Name $Script:Modules -Scope $Script:ModuleInstallScope -Force -SkipPublisherCheck -Set-BuildEnvironment +Set-BuildEnvironment -Force Get-ChildItem Env:BH* Get-ChildItem Env:APPVEYOR*