Skip to content

Commit

Permalink
Fixed issues in tests and replaced 'CommonTasks' with 'DscConfig.Demo' (
Browse files Browse the repository at this point in the history
#134)

* Fixed binary file issue

* Added missing dependency

* Added psd1 which is required if GitVersion is not available on the build machine

* Updated 'Sampler.DscPipeline' version

* Added modules to import for Sampler.DscPipeline

* Removed script for MOF and MetaMOF compilation as these are now part of Sampler.DscPipeline

* New version for Sampler.DscPipeline

* Updated changelog

* Merge conflict

* Updated to latest version of test scripts

* Changed from 'CommonTasks' to 'DscConfig.Demo' for faster build time

* Changed 'DscCompositeResourceModules'
  • Loading branch information
raandree authored Feb 25, 2022
1 parent fee58e0 commit f0974de
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 46 deletions.
47 changes: 21 additions & 26 deletions .build/TestBuildAcceptance.build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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[]]
Expand All @@ -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
Expand Down
47 changes: 34 additions & 13 deletions .build/TestConfigData.build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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
})
Expand All @@ -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
Expand Down
11 changes: 6 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
is no IP address configured.
- Module versions incremented.
- Fix typo in ConfigData tests.
2 changes: 1 addition & 1 deletion RequiredModules.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,6 @@ TaskHeader: |
Sampler.DscPipeline:
DscCompositeResourceModules:
- PSDesiredStateConfiguration
- CommonTasks
- DscConfig.Demo
#- Name: CommonTasks
# Version: 0.3.259

0 comments on commit f0974de

Please sign in to comment.