diff --git a/.build/TestBuildAcceptance.build.ps1 b/.build/TestBuildAcceptance.build.ps1 index a25be909..d3b8df36 100644 --- a/.build/TestBuildAcceptance.build.ps1 +++ b/.build/TestBuildAcceptance.build.ps1 @@ -20,11 +20,7 @@ param [Parameter()] [System.Object[]] - $AcceptanceTestDirectory = (property AcceptanceTestDirectory 'Acceptance'), - - [Parameter()] - [string] - $BuildAcceptanceTestResults = (property BuildAcceptanceTestResults 'BuildAcceptanceTestResults.xml'), + $AcceptancePesterScript = (property AcceptancePesterScript 'Acceptance'), [Parameter()] [string[]] @@ -45,49 +41,48 @@ param ) task TestBuildAcceptance { - $OutputDirectory = Get-SamplerAbsolutePath -Path $OutputDirectory -RelativeTo $ProjectPath + $PesterOutputFolder = Get-SamplerAbsolutePath -Path $PesterOutputFolder -RelativeTo $OutputDirectory + "`tPester Output Folder = '$PesterOutputFolder" + if (-not (Test-Path -Path $PesterOutputFolder)) + { + Write-Build -Color 'Yellow' -Text "Creating folder $PesterOutputFolder" + + $null = New-Item -Path $PesterOutputFolder -ItemType 'Directory' -Force -ErrorAction 'Stop' + } + $DatumConfigDataDirectory = Get-SamplerAbsolutePath -Path $DatumConfigDataDirectory -RelativeTo $ProjectPath $PesterScript = $PesterScript.Foreach({ Get-SamplerAbsolutePath -Path $_ -RelativeTo $ProjectPath }) - $AcceptanceTestDirectory = $AcceptanceTestDirectory.Foreach({ + $AcceptancePesterScript = $AcceptancePesterScript.Foreach({ Get-SamplerAbsolutePath -Path $_ -RelativeTo $PesterScript[0] }) - if (-not (Test-Path -Path $AcceptanceTestDirectory)) - { - Write-Build Yellow "Path for tests '$AcceptanceTestDirectory' does not exist" - return - } + Write-Build Green "Acceptance Data Pester Scripts = [$($AcceptancePesterScript -join ';')]" - if (-not ([System.IO.Path]::IsPathRooted($BuildOutput))) + if (-not (Test-Path -Path $AcceptancePesterScript)) { - $BuildOutput = Join-Path -Path $PSScriptRoot -ChildPath $BuildOutput - } - - if ($env:BHBuildSystem -in 'AppVeyor', 'Unknown') - { - #AppVoyor build are not deploying to a pull server yet. - $excludeTag = 'PullServer' + Write-Build Yellow "Path for tests '$AcceptancePesterScript' does not exist" + return } - $testResultsPath = Get-SamplerAbsolutePath -Path $testResultsPath -RelativeTo $OutputDirectory + $testResultsPath = Get-SamplerAbsolutePath -Path AcceptanceTestResults.xml -RelativeTo $PesterOutputFolder - Write-Build DarkGray "testResultsPath is: $testResultsPath" - Write-Build DarkGray "AcceptanceTestDirectory is: $AcceptanceTestDirectory" - Write-Build DarkGray "BuildOutput is: $BuildOutput" + Write-Build DarkGray "TestResultsPath is: $testResultsPath" + Write-Build DarkGray "BuildOutput is: $OutputDirectory" Import-Module -Name Pester - $po = [PesterConfiguration]::new() + $po = $po = New-PesterConfiguration $po.Run.PassThru = $true - $po.Run.Path = [string[]]$AcceptanceTestDirectory + $po.Run.Path = [string[]]$AcceptancePesterScript $po.Output.Verbosity = 'Detailed' if ($excludeTag) { $po.Filter.ExcludeTag = $excludeTag } $po.Filter.Tag = 'BuildAcceptance' + $po.TestResult.Enabled = $true $po.TestResult.OutputFormat = 'NUnitXml' $po.TestResult.OutputPath = $testResultsPath $testResults = Invoke-Pester -Configuration $po diff --git a/.build/TestConfigData.build.ps1 b/.build/TestConfigData.build.ps1 index ab2ad785..7ff88ada 100644 --- a/.build/TestConfigData.build.ps1 +++ b/.build/TestConfigData.build.ps1 @@ -11,20 +11,20 @@ param $OutputDirectory = (property OutputDirectory (Join-Path $BuildRoot 'output')), [Parameter()] - [string] - $DatumConfigDataDirectory = (property DatumConfigDataDirectory 'source'), + [System.String] + $PesterOutputFolder = (property PesterOutputFolder 'TestResults'), [Parameter()] - [System.Object[]] - $PesterScript = (property PesterScript 'tests'), + [System.String] + $PesterOutputFormat = (property PesterOutputFormat ''), [Parameter()] [System.Object[]] - $ConfigDataPesterScript = (property ConfigDataPesterScript 'ConfigData'), + $PesterScript = (property PesterScript ''), [Parameter()] - [string] - $testResultsPath = (property TestResultsPath 'IntegrationTestResults.xml'), + [System.Object[]] + $ConfigDataPesterScript = (property ConfigDataPesterScript 'ConfigData'), [Parameter()] [int] @@ -41,8 +41,28 @@ param ) task TestConfigData { - $OutputDirectory = Get-SamplerAbsolutePath -Path $OutputDirectory -RelativeTo $ProjectPath - $DatumConfigDataDirectory = Get-SamplerAbsolutePath -Path $DatumConfigDataDirectory -RelativeTo $ProjectPath + + $isWrongPesterVersion = (Get-Module -Name 'Pester' -ListAvailable | Select-Object -First 1).Version -lt [System.Version] '5.0.0' + + # If the correct module is not imported, then exit. + if ($isWrongPesterVersion) + { + "Pester 5 is not used in the pipeline, skipping task.`n" + + return + } + + . Set-SamplerTaskVariable -AsNewBuild + + $PesterOutputFolder = Get-SamplerAbsolutePath -Path $PesterOutputFolder -RelativeTo $OutputDirectory + "`tPester Output Folder = '$PesterOutputFolder" + if (-not (Test-Path -Path $PesterOutputFolder)) + { + Write-Build -Color 'Yellow' -Text "Creating folder $PesterOutputFolder" + + $null = New-Item -Path $PesterOutputFolder -ItemType 'Directory' -Force -ErrorAction 'Stop' + } + $PesterScript = $PesterScript.Foreach( { Get-SamplerAbsolutePath -Path $_ -RelativeTo $ProjectPath }) @@ -59,17 +79,18 @@ task TestConfigData { return } - $testResultsPath = Get-SamplerAbsolutePath -Path $testResultsPath -RelativeTo $OutputDirectory + $testResultsPath = Get-SamplerAbsolutePath -Path IntegrationTestResults.xml -RelativeTo $PesterOutputFolder - Write-Build DarkGray "testResultsPath is: $testResultsPath" - Write-Build DarkGray "OutputDirectory is: $OutputDirectory" + Write-Build DarkGray "TestResultsPath is: $TestResultsPath" + Write-Build DarkGray "OutputDirectory is: $PesterOutputFolder" Import-Module -Name Pester - $po = [PesterConfiguration]::new() + $po = New-PesterConfiguration $po.Run.PassThru = $true $po.Run.Path = [string[]]$ConfigDataPesterScript $po.Output.Verbosity = 'Detailed' $po.Filter.Tag = 'Integration' + $po.TestResult.Enabled = $true $po.TestResult.OutputFormat = 'NUnitXml' $po.TestResult.OutputPath = $testResultsPath $testResults = Invoke-Pester -Configuration $po diff --git a/CHANGELOG.md b/CHANGELOG.md index d73bfd83..f17f8bc8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,11 +10,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed -- Migration to 'Sampler' and 'Sampler.DscPipeline' -- Migration to Pester 5+ +- Migration to 'Sampler' and 'Sampler.DscPipeline'. +- Migration to Pester 5+. +- Changed from 'CommonTasks' to 'DscConfig.Demo' for faster build time. ### Fixed - Config data test 'No duplicate IP addresses should be used' threw when there - is no IP address configured -- Module versions incremented -- Fix typo in ConfigData tests \ No newline at end of file + is no IP address configured. +- Module versions incremented. +- Fix typo in ConfigData tests. diff --git a/RequiredModules.psd1 b/RequiredModules.psd1 index bc0fcb76..d054ee57 100644 --- a/RequiredModules.psd1 +++ b/RequiredModules.psd1 @@ -33,7 +33,7 @@ 'DscResource.Test' = 'latest' # Composites - CommonTasks = '0.6.1-preview0001' + 'DscConfig.Demo' = '0.7.1-preview0002' # DSC Resources xPSDesiredStateConfiguration = '9.1.0' diff --git a/build.yaml b/build.yaml index 1f2f234f..46036203 100644 --- a/build.yaml +++ b/build.yaml @@ -98,6 +98,6 @@ TaskHeader: | Sampler.DscPipeline: DscCompositeResourceModules: - PSDesiredStateConfiguration - - CommonTasks + - DscConfig.Demo #- Name: CommonTasks # Version: 0.3.259