-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.ps1
More file actions
109 lines (97 loc) · 3.77 KB
/
build.ps1
File metadata and controls
109 lines (97 loc) · 3.77 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
#Requires -Version 7
<#
.SYNOPSIS
Runs a Python flavoured build process.
.DESCRIPTION
This script was scaffolded using a template from the ZeroFailed project.
It uses the InvokeBuild module to orchestrate an opinionated software build process for Python projects.
.EXAMPLE
PS C:\> ./build.ps1
Downloads any missing module dependencies (ZeroFailed & InvokeBuild) and executes
the build process.
.PARAMETER Tasks
Optionally override the default task executed as the entry-point of the build.
.PARAMETER Configuration
The build configuration, defaults to 'Release'.
.PARAMETER SourcesDir
The path where the source code to be built is located, defaults to the current working directory.
.PARAMETER CoverageDir
The output path for the test coverage data, if run.
.PARAMETER TestReportTypes
The test report format that should be generated by the test report generator, if run.
.PARAMETER PackagesDir
The output path for any packages produced as part of the build.
.PARAMETER LogLevel
The logging verbosity.
.PARAMETER ZfModulePath
The path to import the ZeroFailed module from. This is useful when testing pre-release
versions of ZeroFailed that are not yet available in the PowerShell Gallery.
.PARAMETER ZfModuleVersion
The version of the ZeroFailed module to import. This is useful when testing pre-release
versions of ZeroFailed that are not yet available in the PowerShell Gallery.
.PARAMETER InvokeBuildModuleVersion
The version of the InvokeBuild module to be used.
#>
[CmdletBinding()]
param (
[Parameter(Position=0)]
[string[]] $Tasks = @("."),
[Parameter()]
[string] $Configuration = "Debug",
[Parameter()]
[string] $SourcesDir = $PWD,
[Parameter()]
[string] $CoverageDir = "_codeCoverage",
[Parameter()]
[string] $TestReportTypes = "Cobertura",
[Parameter()]
[string] $PackagesDir = "_packages",
[Parameter()]
[ValidateSet("minimal","normal","detailed")]
[string] $LogLevel = "minimal",
[Parameter()]
[string] $ZfModulePath,
[Parameter()]
[string] $ZfModuleVersion = "1.0.6",
[Parameter()]
[version] $InvokeBuildModuleVersion = "5.12.1"
)
$ErrorActionPreference = 'Stop'
$here = Split-Path -Parent $PSCommandPath
#region InvokeBuild setup
# This handles calling the build engine when this file is run like a normal PowerShell script
# (i.e. avoids the need to have another script to setup the InvokeBuild environment and issue the 'Invoke-Build' command )
if ($MyInvocation.ScriptName -notlike '*Invoke-Build.ps1') {
Install-PSResource InvokeBuild -Version $InvokeBuildModuleVersion -Scope CurrentUser -TrustRepository -Verbose:$false | Out-Null
try {
Invoke-Build $Tasks $MyInvocation.MyCommand.Path @PSBoundParameters
}
catch {
Write-Host -f Yellow "`n`n***`n*** Build Failure Summary - check previous logs for more details`n***"
Write-Host -f Yellow $_.Exception.Message
Write-Host -f Yellow $_.ScriptStackTrace
exit 1
}
return
}
#endregion
#region Initialise build framework
$splat = @{ Force = $true; Verbose = $false}
Import-Module Microsoft.PowerShell.PSResourceGet
if (!($ZfModulePath)) {
Install-PSResource ZeroFailed -Version $ZfModuleVersion -Scope CurrentUser -TrustRepository | Out-Null
$ZfModulePath = "ZeroFailed"
$splat.Add("RequiredVersion", ($ZfModuleVersion -split '-')[0])
}
else {
Write-Host "ZfModulePath: $ZfModulePath"
}
$splat.Add("Name", $ZfModulePath)
# Ensure only 1 version of the module is loaded
Get-Module ZeroFailed | Remove-Module
Import-Module @splat
$ver = "{0} {1}" -f (Get-Module ZeroFailed).Version, (Get-Module ZeroFailed).PrivateData.PsData.PreRelease
Write-Host "Using ZeroFailed module version: $ver"
#endregion
# Load the build configuration
. $here/.zf/config.ps1