-
Notifications
You must be signed in to change notification settings - Fork 18
/
psake.ps1
78 lines (66 loc) · 4.99 KB
/
psake.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
# Set Properties Here
Properties {
$lines = '----------------------------------------------------------------------'
# Find the build folder based on build system
$ProjectRoot = $ENV:BHProjectPath
if (-not $ProjectRoot) {
$ProjectRoot = $PSScriptRoot
}
$ProjectRoot = Convert-Path $ProjectRoot
$Timestamp = Get-date -uformat "%Y%m%d-%H%M%S"
$PSVersion = $PSVersionTable.PSVersion.Major
$TestFile = "TestResults_PS$PSVersion`_$TimeStamp.xml"
$lines = '----------------------------------------------------------------------'
$Verbose = @{}
if($ENV:BHCommitMessage -match "!verbose")
{
$Verbose = @{Verbose = $True}
}
try {
$script:IsWindows = (-not (Get-Variable -Name IsWindows -ErrorAction Ignore)) -or $IsWindows
$script:IsLinux = (Get-Variable -Name IsLinux -ErrorAction Ignore) -and $IsLinux
$script:IsMacOS = (Get-Variable -Name IsMacOS -ErrorAction Ignore) -and $IsMacOS
$script:IsCoreCLR = $PSVersionTable.ContainsKey('PSEdition') -and $PSVersionTable.PSEdition -eq 'Core'
} catch { }
}
Task Default -depends Test
Task Init {
$lines
Set-BuildEnvironment -force
}
Task Test -depends Init,Pester {
$lines
}
Task Pester {
$Lines
"`nSTATUS: Testing with PowerShell $PSVersion"
$TestResults = Invoke-Pester -Tag "Project","API" -Path $ProjectRoot\Tests -PassThru -OutputFormat NUnitXml -OutputFile "$ProjectRoot\$TestFile"
If($ENV:BHBuildSystem -eq 'AppVeyor')
{
(New-Object 'System.Net.WebClient').UploadFile("https://ci.appveyor.com/api/testresults/nunit/${env:APPVEYOR_JOB_ID}", "$ProjectRoot\$TestFile")
}
Remove-Item "$ProjectRoot\$TestFile" -Force -ErrorAction SilentlyContinue
if($TestResults.FailedCount -gt 0)
{
Write-Error "Failed '$($TestResults.FailedCount)' tests, build failed"
exit 1
}
"`n"
}
Task Build -depends Init {
$lines
#Set-ModuleFunctions
write-host "module manifest path $($env:BHPSModuleManifest)"
# Bump the module version
$Version= Get-NextNugetPackageVersion -name $ENV:BHProjectName
Update-Metadata -Path $env:BHPSModuleManifest -PropertyName ModuleVersion -Value $Version
}
Task Deploy -depends Build{
$lines
$Params = @{
Path = $ProjectRoot
Force = $true
Recurse = $false # We keep psdeploy artifacts, avoid deploying those : )
}
Invoke-PSDeploy @Verbose @Params
}