Working with Build Options
This commit is contained in:
+51
-12
@@ -1,17 +1,45 @@
|
|||||||
task . InstallDependencies, Analyze
|
#Requires -Modules 'InvokeBuild'
|
||||||
|
|
||||||
task InstallDependencies {
|
. '.\ZertoApiWrapper.settings.ps1'
|
||||||
Install-Module Pester -Force
|
import-module .\ZertoApiWrapper\ZertoApiWrapper.psd1
|
||||||
Install-Module PSScriptAnalyzer -Force
|
|
||||||
|
[CmdletBinding()]
|
||||||
|
param([switch]$Install,
|
||||||
|
[string]$Configuration = (property Configuration Release))
|
||||||
|
|
||||||
|
$targetDir = "temp/$Configuration/ZertoApiWrapper"
|
||||||
|
|
||||||
|
task . Analyze
|
||||||
|
|
||||||
|
<# Synopsis: Ensure platyPS is installed #>
|
||||||
|
task CheckPlatyPSInstalled {
|
||||||
|
if ($null -eq (Get-Module -List platyPS)) {
|
||||||
|
Install-Module -Scope CurrentUser -Repository PSGallery -Name platyPS
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
task Analyze {
|
<# Synopsis: Ensure Pester is installed #>
|
||||||
|
task CheckPesterInstalled {
|
||||||
|
if ($null -eq (Get-Module -List Pester)) {
|
||||||
|
Install-Module -Scope CurrentUser -Repository PSGallery -Name Pester
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
<# Synopsis: Ensure PSScriptAnalyzer is installed #>
|
||||||
|
task CheckPSScriptAnalyzerInstalled {
|
||||||
|
if ($null -eq (Get-Module -List PSScriptAnalyzer)) {
|
||||||
|
Install-Module -Scope CurrentUser -Repository PSGallery -Name PSScriptAnalyzer
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
<# Synopsis: Analyze ZertoApiWrapper functions for Code Violations #>
|
||||||
|
task Analyze CheckPSScriptAnalyzerInstalled, CheckPesterInstalled, CheckPlatyPSInstalled, {
|
||||||
$scriptAnalyzerParams = @{
|
$scriptAnalyzerParams = @{
|
||||||
Path = "$BuildRoot\ZertoApiWrapper\"
|
Path = "$BuildRoot\ZertoApiWrapper\"
|
||||||
Severity = @('Error', 'Warning')
|
Severity = @('Error', 'Warning')
|
||||||
Recurse = $true
|
Recurse = $true
|
||||||
Verbose = $false
|
Verbose = $false
|
||||||
ExcludeRule = 'PSUseDeclaredVarsMoreThanAssignments'
|
ExcludeRule = @('PSUseDeclaredVarsMoreThanAssignments', 'PSUseShouldProcessForStateChangingFunctions')
|
||||||
}
|
}
|
||||||
$saresults = Invoke-ScriptAnalyzer @scriptAnalyzerParams
|
$saresults = Invoke-ScriptAnalyzer @scriptAnalyzerParams
|
||||||
|
|
||||||
@@ -21,12 +49,23 @@ task Analyze {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
task FileTests {
|
$buildMamlParams = @{
|
||||||
Invoke-Pester "$BuildRoot\Tests\Public\ZertoApiWrapper.Tests.ps1"
|
Inputs = { Get-ChildItem docs/*.md }
|
||||||
|
Outputs = "$targetDir/en-us/ZertoApiWrapper-help.xml"
|
||||||
}
|
}
|
||||||
|
|
||||||
task BuildPsd1 {
|
task BuildMamlHelp @buildMamlParams {
|
||||||
$functionsToExportPath = "{0}\ZertoApiWrapper\Public\" -f $MyInvocation.MyCommand.PSPath
|
platyPS\New-ExternalHelp .\docs -Force -OutputPath $buildMamlParams.Outputs
|
||||||
$functionsToExport = (Get-ChildItem -Path $functionsToExportPath -File).name.Replace('.ps1', '')
|
}
|
||||||
$functionsToExport
|
|
||||||
|
task FileTests CheckPesterInstalled, {
|
||||||
|
Invoke-Pester "$BuildRoot\Tests\Public\ZertoApiWrapper.Tests.ps1" -Show Fails
|
||||||
|
}
|
||||||
|
|
||||||
|
task UpdateModuleManifest {
|
||||||
|
$functionsToExportPath = "$BuildRoot\ZertoApiWrapper\Public\"
|
||||||
|
$functionsToExport = (Get-ChildItem -Path $functionsToExportPath -File).name.Replace('.ps1', '')
|
||||||
|
$version = Get-Module -Name ZertoApiWrapper | select Version
|
||||||
|
$buildVersion = $version.Build
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
task . FileTests, BuildPsd1, Analyze
|
||||||
|
|
||||||
|
task InstallDependencies {
|
||||||
|
Install-Module Pester -Force
|
||||||
|
Install-Module PSScriptAnalyzer -Force
|
||||||
|
}
|
||||||
|
|
||||||
|
task Analyze {
|
||||||
|
$scriptAnalyzerParams = @{
|
||||||
|
Path = "$BuildRoot\ZertoApiWrapper\"
|
||||||
|
Severity = @('Error', 'Warning')
|
||||||
|
Recurse = $true
|
||||||
|
Verbose = $false
|
||||||
|
ExcludeRule = @('PSUseDeclaredVarsMoreThanAssignments','PSUseShouldProcessForStateChangingFunctions')
|
||||||
|
}
|
||||||
|
$saresults = Invoke-ScriptAnalyzer @scriptAnalyzerParams
|
||||||
|
|
||||||
|
if ($saResults) {
|
||||||
|
$saResults | Format-Table
|
||||||
|
throw "One or more PSScriptAnalyzer errors/warnings were found"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
task FileTests {
|
||||||
|
Invoke-Pester "$BuildRoot\Tests\Public\ZertoApiWrapper.Tests.ps1"
|
||||||
|
}
|
||||||
|
|
||||||
|
task BuildPsd1 {
|
||||||
|
$functionsToExportPath = "$BuildRoot\ZertoApiWrapper\Public\"
|
||||||
|
$functionsToExport = (Get-ChildItem -Path $functionsToExportPath -File).name.Replace('.ps1', '')
|
||||||
|
$functionsToExport
|
||||||
|
}
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
# This file stores variables which are used by the build script
|
||||||
|
|
||||||
|
# Storing all values in a single $Settings variable to make it obvious that the values are coming from this BuildSettings file when accessing them.
|
||||||
|
$Settings = @{
|
||||||
|
|
||||||
|
BuildOutput = "$PSScriptRoot\BuildOutput"
|
||||||
|
Dependency = @('Pester', 'PsScriptAnalyzer', 'platyPS')
|
||||||
|
SourceFolder = "$PSScriptRoot\ZertoApiWrapper"
|
||||||
|
#SourceFolder = "$PSScriptRoot\$($env:APPVEYOR_PROJECT_NAME)"
|
||||||
|
#TestUploadUrl = "https://ci.appveyor.com/api/testresults/nunit/$($env:APPVEYOR_JOB_ID)"
|
||||||
|
#CoverallsKey = $env:Coveralls_Key
|
||||||
|
#Branch = $env:APPVEYOR_REPO_BRANCH
|
||||||
|
|
||||||
|
UnitTestParams = @{
|
||||||
|
Script = '.\Tests\Unit'
|
||||||
|
CodeCoverage = (Get-ChildItem -Path '.\PSCodeHealth\' -File -Filter "*.ps1" -Recurse).FullName | Where-Object { $_ -Match "Public|Private" }
|
||||||
|
OutputFile = "$PSScriptRoot\BuildOutput\UnitTestsResult.xml"
|
||||||
|
PassThru = $True
|
||||||
|
}
|
||||||
|
|
||||||
|
IntegrationTestParams = @{
|
||||||
|
Script = '.\Tests\Integration'
|
||||||
|
OutputFile = "$PSScriptRoot\BuildOutput\IntegrationTestsResult.xml"
|
||||||
|
PassThru = $True
|
||||||
|
}
|
||||||
|
|
||||||
|
AnalyzeParams = @{
|
||||||
|
Path = "$PSScriptRoot\$($env:APPVEYOR_PROJECT_NAME)"
|
||||||
|
Severity = 'Error'
|
||||||
|
Recurse = $True
|
||||||
|
}
|
||||||
|
|
||||||
|
IsPullRequest = ($env:APPVEYOR_PULL_REQUEST_NUMBER -gt 0)
|
||||||
|
Version = $env:APPVEYOR_BUILD_VERSION
|
||||||
|
ManifestPath = '{0}\{1}\{1}.psd1' -f $PSScriptRoot, $env:APPVEYOR_PROJECT_NAME
|
||||||
|
VersionRegex = "ModuleVersion\s=\s'(?<ModuleVersion>\S+)'" -as [regex]
|
||||||
|
|
||||||
|
ModuleName = $env:APPVEYOR_PROJECT_NAME
|
||||||
|
HeaderPath = "$PSScriptRoot\header-mkdocs.yml"
|
||||||
|
MkdocsPath = "$PSScriptRoot\mkdocs.yml"
|
||||||
|
PublicFunctionDocsPath = "$PSScriptRoot\docs\PublicFunctions"
|
||||||
|
PlatyPSParams = @{
|
||||||
|
Module = $env:APPVEYOR_PROJECT_NAME
|
||||||
|
OutputFolder = "$PSScriptRoot\docs\PublicFunctions"
|
||||||
|
NoMetadata = $True
|
||||||
|
Force = $True
|
||||||
|
}
|
||||||
|
PrivateFunctionDocsPath = "$PSScriptRoot\docs\InternalFunctions"
|
||||||
|
InternalDocsPlatyPSParams = @{
|
||||||
|
OutputFolder = "$PSScriptRoot\docs\InternalFunctions"
|
||||||
|
WarningAction = 'SilentlyContinue'
|
||||||
|
NoMetadata = $True
|
||||||
|
Force = $True
|
||||||
|
}
|
||||||
|
FunctionsToExclude = @('Write-VerboseOutput', 'Get-SwitchCombination')
|
||||||
|
|
||||||
|
GitHubKey = $env:GitHub_Key
|
||||||
|
Email = 'MathieuBuisson@users.noreply.github.com'
|
||||||
|
Name = 'Mathieu Buisson'
|
||||||
|
ScreenshotPath = "$($env:TEMP)\*Screenshot.png"
|
||||||
|
PSGalleryKey = $env:PSGallery_Key
|
||||||
|
OutputModulePath = "$PSScriptRoot\BuildOutput\$($env:APPVEYOR_PROJECT_NAME)"
|
||||||
|
}
|
||||||
|
|
||||||
|
$ModuleManifestParams = @{
|
||||||
|
RootModule = "ZertoApiWrapper"
|
||||||
|
GUID = '4c0b9e17-141b-4dd5-8549-fb21cccaa325'
|
||||||
|
Author = 'Wes Carroll'
|
||||||
|
CompanyName = 'Zerto'
|
||||||
|
Copyright = "(c) $(Get-Date -Format "yyyy") Wes Carroll. All rights reserved."
|
||||||
|
Description = 'PowerShell Core Wrapper Module for Zerto Virtual Manager API'
|
||||||
|
PowerShellVersion = '6.0.0'
|
||||||
|
}
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
0.1.0
|
||||||
Reference in New Issue
Block a user