forked from chocolatey-community/Chocolatey-Module
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.build.ps1
113 lines (95 loc) · 3.77 KB
/
.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
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
112
113
[cmdletBinding()]
Param (
[Parameter(Position=0)]
$Tasks,
[switch]
$ResolveDependency,
[System.String]
$BuildOutput = "BuildOutput",
$ModuleVersion = $(if($Env:APPVEYOR_BUILD_VERSION) {$ENV:APPVEYOR_BUILD_VERSION} else { try { Get-NextNugetPackageVersion -Name 'Chocolatey' -EA Stop} catch { '0.0.1' }} ),
[String[]]
$GalleryRepository,
[Uri]
$GalleryProxy,
[Switch]
$ForceEnvironmentVariables = [switch]$true,
$MergeList = @('enum*',[PSCustomObject]@{Name='class*';order={(Import-PowerShellDataFile .\SampleModule\Classes\classes.psd1).order.indexOf($_.BaseName)}},'priv*','pub*')
,$CodeCoverageThreshold = 6
)
Process {
if ($MyInvocation.ScriptName -notlike '*Invoke-Build.ps1') {
Invoke-Build $Tasks $MyInvocation.MyCommand.Path @PSBoundParameters
return
}
Write-Warning $ModuleVersion
if (![io.path]::IsPathRooted($BuildOutput)) {
$BuildOutput = Join-Path -Path $PSScriptRoot -ChildPath $BuildOutput
}
if (($Env:PSModulePath -split ';') -notcontains (Join-Path $BuildOutput 'modules') ) {
$Env:PSModulePath += ';' + (Join-Path $BuildOutput 'modules')
}
Get-ChildItem -Path "$PSScriptRoot/.build/" -Recurse -Include *.ps1 -Verbose |
Foreach-Object {
"Importing file $($_.BaseName)" | Write-Verbose
. $_.FullName
}
task none {}
task . Clean,
SetBuildEnvironment,
QualityTestsStopOnFail,
CopySourceToModuleOut,
MergeFilesToPSM1,
CleanOutputEmptyFolders,
UpdateModuleManifest,
UnitTests,
UploadUnitTestResultsToAppVeyor,
FailBuildIfFailedUnitTest,
FailIfLastCodeConverageUnderThreshold,
IntegrationTests,
DeployAll
task testAll UnitTests, IntegrationTests, QualityTestsStopOnFail
}
begin {
Push-Location $PSScriptRoot
function Resolve-Dependency {
[CmdletBinding()]
param()
if (!(Get-PackageProvider -Name NuGet -ForceBootstrap)) {
$providerBootstrapParams = @{
Name = 'nuget'
force = $true
ForceBootstrap = $true
}
if ($PSBoundParameters.ContainsKey('verbose')) { $providerBootstrapParams.add('verbose',$verbose)}
if ($GalleryProxy) { $providerBootstrapParams.Add('Proxy',$GalleryProxy) }
$null = Install-PackageProvider @providerBootstrapParams
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
}
if (!(Get-Module -Listavailable PSDepend)) {
Write-verbose "BootStrapping PSDepend"
"Parameter $BuildOutput"| Write-verbose
$InstallPSDependParams = @{
Name = 'PSDepend'
AllowClobber = $true
Confirm = $false
Force = $true
Scope = 'CurrentUser'
}
if ($PSBoundParameters.ContainsKey('verbose')) { $InstallPSDependParams.add('verbose',$verbose)}
if ($GalleryRepository) { $InstallPSDependParams.Add('Repository',$GalleryRepository) }
if ($GalleryProxy) { $InstallPSDependParams.Add('Proxy',$GalleryProxy) }
if ($GalleryCredential) { $InstallPSDependParams.Add('ProxyCredential',$GalleryCredential) }
Install-Module @InstallPSDependParams
}
$PSDependParams = @{
Force = $true
Path = "$PSScriptRoot\Dependencies.psd1"
}
if ($PSBoundParameters.ContainsKey('verbose')) { $PSDependParams.add('verbose',$verbose)}
Invoke-PSDepend @PSDependParams
Write-Verbose "Project Bootstrapped, returning to Invoke-Build"
}
if ($ResolveDependency) {
Resolve-Dependency
}
}