Skip to content

Commit

Permalink
Merge pull request #111 from NicolasBn/task
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasBn authored Jun 9, 2021
2 parents 749ebb6 + ad388d6 commit d2ced82
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 97 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed

- Refactoring all tasks to initialise variable with `Set-SamplerTaskVariable` script ([issue #110](https://github.com/dsccommunity/DscResource.Test/issues/110)).

## [0.15.1] - 2021-03-29

### Added
Expand Down
50 changes: 2 additions & 48 deletions source/tasks/Fail_Build_If_HQRM_Tests_Failed.build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -57,56 +57,10 @@ param
task Fail_Build_If_HQRM_Tests_Failed {
"Asserting that no test failed."

$OutputDirectory = Get-SamplerAbsolutePath -Path $OutputDirectory -RelativeTo $BuildRoot

"`tOutputDirectory = '$OutputDirectory'"

$BuiltModuleSubdirectory = Get-SamplerAbsolutePath -Path $BuiltModuleSubdirectory -RelativeTo $OutputDirectory

if ($VersionedOutputDirectory)
{
# VersionedOutputDirectory is not [bool]'' nor $false nor [bool]$null
# Assume true, wherever it was set
$VersionedOutputDirectory = $true
}
else
{
# VersionedOutputDirectory may be [bool]'' but we can't tell where it's
# coming from, so assume the build info (Build.yaml) is right
$VersionedOutputDirectory = $BuildInfo['VersionedOutputDirectory']
}

$GetBuiltModuleManifestParams = @{
OutputDirectory = $OutputDirectory
BuiltModuleSubdirectory = $BuiltModuleSubDirectory
ModuleName = $ProjectName
VersionedOutputDirectory = $VersionedOutputDirectory
ErrorAction = 'Stop'
}

$builtModuleManifest = Get-SamplerBuiltModuleManifest @GetBuiltModuleManifestParams
$builtModuleManifest = [string](Get-Item -Path $builtModuleManifest).FullName

"`tBuilt Module Manifest = '$builtModuleManifest'"

$builtModuleBase = Get-SamplerBuiltModuleBase @GetBuiltModuleManifestParams
$builtModuleBase = [string](Get-Item -Path $builtModuleBase).FullName

"`tBuilt Module Base = '$builtModuleBase'"

$moduleVersion = Get-BuiltModuleVersion @GetBuiltModuleManifestParams

$moduleVersionObject = Split-ModuleVersion -ModuleVersion $moduleVersion
$moduleVersionFolder = $moduleVersionObject.Version
$preReleaseTag = $moduleVersionObject.PreReleaseString

"`tModule Version = '$ModuleVersion'"
"`tModule Version Folder = '$moduleVersionFolder'"
"`tPre-release Tag = '$preReleaseTag'"
# Get the values for task variables
. Set-SamplerTaskVariable

"`tProject Path = $ProjectPath"
"`tProject Name = $ProjectName"
"`tBuilt Module Base = $builtModuleBase"

if (-not (Split-Path -IsAbsolute $DscTestOutputFolder))
{
Expand Down
51 changes: 2 additions & 49 deletions source/tasks/Invoke_HQRM_Tests.build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -82,57 +82,10 @@ param

# Synopsis: Making sure the Module meets some quality standard (help, tests)
task Invoke_HQRM_Tests {
$OutputDirectory = Get-SamplerAbsolutePath -Path $OutputDirectory -RelativeTo $BuildRoot

"`tOutputDirectory = '$OutputDirectory'"

$BuiltModuleSubdirectory = Get-SamplerAbsolutePath -Path $BuiltModuleSubdirectory -RelativeTo $OutputDirectory

if ($VersionedOutputDirectory)
{
# VersionedOutputDirectory is not [bool]'' nor $false nor [bool]$null
# Assume true, wherever it was set
$VersionedOutputDirectory = $true
}
else
{
# VersionedOutputDirectory may be [bool]'' but we can't tell where it's
# coming from, so assume the build info (Build.yaml) is right
$VersionedOutputDirectory = $BuildInfo['VersionedOutputDirectory']
}

$GetBuiltModuleManifestParams = @{
OutputDirectory = $OutputDirectory
BuiltModuleSubdirectory = $BuiltModuleSubDirectory
ModuleName = $ProjectName
VersionedOutputDirectory = $VersionedOutputDirectory
ErrorAction = 'Stop'
}

$builtModuleManifest = Get-SamplerBuiltModuleManifest @GetBuiltModuleManifestParams
$builtModuleManifest = [string](Get-Item -Path $builtModuleManifest).FullName

"`tBuilt Module Manifest = '$builtModuleManifest'"

$builtModuleBase = Get-SamplerBuiltModuleBase @GetBuiltModuleManifestParams
$builtModuleBase = [string](Get-Item -Path $builtModuleBase).FullName

"`tBuilt Module Base = '$builtModuleBase'"

$moduleVersion = Get-BuiltModuleVersion @GetBuiltModuleManifestParams

$moduleVersionObject = Split-ModuleVersion -ModuleVersion $moduleVersion
$moduleVersionFolder = $moduleVersionObject.Version
$preReleaseTag = $moduleVersionObject.PreReleaseString

"`tModule Version = '$ModuleVersion'"
"`tModule Version Folder = '$moduleVersionFolder'"
"`tPre-release Tag = '$preReleaseTag'"
# Get the values for task variables
. Set-SamplerTaskVariable

"`tProject Path = $ProjectPath"
"`tProject Name = $ProjectName"
"`tSource Path = $SourcePath"
"`tBuilt Module Base = $builtModuleBase"

if (-not (Split-Path -IsAbsolute $DscTestOutputFolder))
{
Expand Down

0 comments on commit d2ced82

Please sign in to comment.