-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpsake.ps1
More file actions
111 lines (83 loc) · 2.84 KB
/
psake.ps1
File metadata and controls
111 lines (83 loc) · 2.84 KB
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#### By Chris Stone <chris.stone@nuwavepartners.com>
Properties {
$TimeStamp = (Get-Date).ToUniversalTime() | Get-Date -UFormat "%Y%m%d-%H%M%SZ"
# Find the build folder based on build system
$ProjectRoot = $ENV:BHProjectPath
If (-not $ProjectRoot) {
$ProjectRoot = Resolve-Path "$PSScriptRoot\.."
}
$Verbose = @{}
If ($ENV:BHCommitMessage -match "!verbose") {
$Verbose = @{ Verbose = $True }
}
}
TaskSetup {
Write-Output "".PadRight(70,'-')
}
Task Default -depends Test
Task Init {
Set-Location $ProjectRoot
"Build System Details:"
Get-Item ENV:BH*
}
Task Test -depends Init {
# Testing links on github requires >= tls 1.2
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
# Gather test results. Store them in a variable and file
Import-Module Pester
$PesterConf = [PesterConfiguration]@{
Run = @{
Path = "$ProjectRoot\Tests"
PassThru = $true
}
TestResult = @{
Enabled = $true
OutputPath = ("{0}\TestResult_{1}.xml" -f $ProjectRoot, $TimeStamp)
OutputFormat = "NUnitXml"
}
}
$TestResults = Invoke-Pester -Configuration $PesterConf
# In Appveyor? Upload our tests! #Abstract this into a function?
If ($ENV:BHBuildSystem -eq 'AppVeyor') {
(New-Object 'System.Net.WebClient').UploadFile(
"https://ci.appveyor.com/api/testresults/nunit/$($env:APPVEYOR_JOB_ID)",
$PesterConf.TestResult.OutputPath.Value )
}
# Cleanup
Remove-Item -Path $PesterConf.TestResult.OutputPath.Value -Force -ErrorAction SilentlyContinue
# Failed tests?
# Need to tell psake or it will proceed to the deployment. Danger!
If ($TestResults.FailedCount -gt 0) {
Write-Error "Failed '$($TestResults.FailedCount)' tests, build failed"
}
}
Task Build -depends Test {
Write-Output "Updating Module Manifest:"
# FunctionsToExport, AliasesToExport; from BuildHelpers
Write-Output "`Functions"
Set-ModuleFunction
Write-Output "`Aliases"
Set-ModuleAlias
# Prerelease
Write-Output "`tPrerelease Metadata"
If ($env:BHBranchName -eq 'release') {
# Remove "Prerelease" from Manifest
Set-Content -Path $env:BHPSModuleManifest -Value (Get-Content -Path $env:BHPSModuleManifest | Select-String -Pattern 'Prerelease' -NotMatch)
} else {
# Add/Update Prerelease Version
Update-Metadata -Path $env:BHPSModuleManifest -PropertyName Prerelease -Value "PRE$(($env:BHCommitHash).Substring(0,7))"
}
# Build Number from CI
Write-Output "`tVersion Build"
[Version] $Ver = Get-Metadata -Path $env:BHPSModuleManifest -PropertyName 'ModuleVersion'
Update-Metadata -Path $env:BHPSModuleManifest -PropertyName 'ModuleVersion' -Value (@($Ver.Major,$Ver.Minor,$Env:BHBuildNumber) -join '.')
}
Task Deploy -depends Build {
$Params = @{
Path = "$ProjectRoot"
Force = $true
Recurse = $false # We keep psdeploy artifacts, avoid deploying those : )
}
Write-Output "Invoking PSDeploy"
Invoke-PSDeploy @Verbose @Params
}