-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathOutSpeech.build.ps1
85 lines (67 loc) · 2.98 KB
/
OutSpeech.build.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
Task . InstallDependencies, CleanTestResults, Tests, CleanArtifacts, BuildModuleFiles
Task InstallDependencies {
Install-Module -Name Pester -Scope CurrentUser -Force -MaximumVersion '4.99.99'
if ((Get-Module -Name PSScriptAnalyzer -ListAvailable).count -lt 1)
{
Install-Module -Name PSScriptAnalyzer -Scope CurrentUser -Force
}
}
Task CleanTestResults {
$TestResults = $(Join-Path -Path $BuildRoot -ChildPath 'TestResults')
if (Test-Path -Path $TestResults)
{
Remove-Item $TestResults -Recurse -Force
}
New-Item -ItemType Directory -Path $TestResults -Force
}
Task Tests {
Import-Module Pester -MaximumVersion '4.99.99' -Force
$TestResults = $(Join-Path -Path $BuildRoot -ChildPath 'TestResults')
$invokePesterParams = @{
Strict = $true
PassThru = $true
Verbose = $false
EnableExit = $false
OutputFormat = 'NUnitXml'
OutputFile = $(Join-Path -Path $TestResults -childPath 'Test-Pester.XML')
CodeCoverage = "$(Join-Path -Path $(Join-Path -Path $BuildRoot -ChildPath 'OutSpeech') -ChildPath 'functions')*.ps1"
}
# Publish Test Results as NUnitXml
$testResults = Invoke-Pester @invokePesterParams
$numberFails = $testResults.FailedCount
Assert($numberFails -eq 0) ('Failed "{0}" unit tests.' -f $numberFails)
}
Task CleanArtifacts {
$Artifacts = $(Join-Path -Path $BuildRoot -ChildPath 'artifacts')
if (Test-Path -Path $Artifacts)
{
Remove-Item $Artifacts -Recurse -Force
}
New-Item -ItemType Directory -Path $Artifacts -Force
}
Task BuildModuleFiles {
$Artifacts = $(Join-Path -Path $BuildRoot -ChildPath 'artifacts')
Write-Information -MessageData "Artifacts Path = $Artifacts" -InformationAction Continue
$ModuleName = $(Split-Path $BuildFile -Leaf).split('.')[0]
Write-Information -MessageData "ModuleName = $ModuleName" -InformationAction Continue
$ModuleManifestFileName = $ModuleName + '.psd1'
$ModuleFolder = $(Join-Path -Path $BuildRoot -ChildPath $ModuleName)
#Write-Information -MessageData "ModuleFolder = $ModuleFolder" -InformationAction Continue
$ModuleManifest = $(Join-Path -Path $ModuleFolder -ChildPath $ModuleManifestFileName)
#Write-Information -MessageData "ModuleManifest = $ModuleManifest" -InformationAction Continue
$Module = Import-Module -FullyQualifiedName $ModuleManifest -PassThru
$PSM1SourceFiles = $Module.Invoke( { Get-Variable -ValueOnly -Name ModuleFiles })
$Module = $null
Remove-Module $ModuleName
$PSM1Content =
foreach ($sf in $PSM1SourceFiles)
{
Get-Content -Path $sf -Raw
}
$PSM1FilePath = $(Join-Path -Path $Artifacts -ChildPath $($ModuleName + '.psm1'))
$PSM1Content | Out-File -FilePath $PSM1FilePath
Copy-Item -Destination $Artifacts -Path $ModuleManifest
Copy-Item -Destination $Artifacts -Path $(Join-Path -path $BuildRoot -ChildPath 'LICENSE')
Copy-Item -Destination $Artifacts -Path $(Join-Path -path $BuildRoot -ChildPath 'README.md')
Copy-Item -Destination $Artifacts -Path $(Join-Path -path $BuildRoot -ChildPath 'ReleaseNotes.md')
}