From 830f5633b50f3d9acd4d6da25a7278f80d714419 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Thu, 28 Mar 2019 09:13:38 -0400 Subject: [PATCH] Building Out Build Items --- ZertoApiWrapper.Depend.psd1 | 50 +++++++++++++++++++++++++++++++++++++ ZertoApiWrapper.build.ps1 | 42 ++++++++++++++++++++++++++----- build.ps1 | 16 ++++++++++++ 3 files changed, 102 insertions(+), 6 deletions(-) create mode 100644 ZertoApiWrapper.Depend.psd1 create mode 100644 build.ps1 diff --git a/ZertoApiWrapper.Depend.psd1 b/ZertoApiWrapper.Depend.psd1 new file mode 100644 index 0000000..e0e013c --- /dev/null +++ b/ZertoApiWrapper.Depend.psd1 @@ -0,0 +1,50 @@ +@{ + psake = @{ + Name = 'InvokeBuild' + DependencyType = 'PSGalleryModule' + Parameters = @{ + Repository = 'PSGallery' + SkipPublisherCheck = $true + } + Target = 'CurrentUser' + Version = '5.4.3' + Tags = 'Bootstrap' + } + + Pester = @{ + Name = 'Pester' + DependencyType = 'PSGalleryModule' + Parameters = @{ + Repository = 'PSGallery' + SkipPublisherCheck = $true + } + Target = 'CurrentUser' + Version = '4.6.0' + Tags = 'Test' + } + + PSScriptAnalyzer = @{ + Name = 'PSScriptAnalyzer' + DependencyType = 'PSGalleryModule' + Parameters = @{ + Repository = 'PSGallery' + SkipPublisherCheck = $true + } + Target = 'CurrentUser' + Version = '1.17.1' + Tags = 'Test' + } + + Platyps = @{ + Name = 'Platyps' + DependencyType = 'PSGalleryModule' + Parameters = @{ + Repository = 'PSGallery' + SkipPublisherCheck = $true + } + Target = 'CurrentUser' + Version = '0.12.0' + Tags = 'Build' + } + +} diff --git a/ZertoApiWrapper.build.ps1 b/ZertoApiWrapper.build.ps1 index d4f7348..a8df4ca 100644 --- a/ZertoApiWrapper.build.ps1 +++ b/ZertoApiWrapper.build.ps1 @@ -1,17 +1,44 @@ -task . InstallDependencies, Analyze +#Requires -Modules 'InvokeBuild' -task InstallDependencies { - Install-Module Pester -Force - Install-Module PSScriptAnalyzer -Force +. '.\ZertoApiWrapper.settings.ps1' +# import-module "$BuildRoot\ZertoApiWrapper\ZertoApiWrapper.psd1" -Verbose -Force + +<# [CmdletBinding()] +param([switch]$Install, + [string]$Configuration = (property Configuration Release)) +$targetDir = "temp/$Configuration/ZertoApiWrapper" #> + +task . Analyze, FileTests + +<# 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 = @{ Path = "$BuildRoot\ZertoApiWrapper\" Severity = @('Error', 'Warning') Recurse = $true Verbose = $false - ExcludeRule = 'PSUseDeclaredVarsMoreThanAssignments' + ExcludeRule = @('PSUseDeclaredVarsMoreThanAssignments', 'PSUseShouldProcessForStateChangingFunctions') } $saresults = Invoke-ScriptAnalyzer @scriptAnalyzerParams @@ -21,3 +48,6 @@ task Analyze { } } +task FileTests CheckPesterInstalled, { + Invoke-Pester "$BuildRoot\Tests\Public\ZertoApiWrapper.Tests.ps1" -Show Fails +} \ No newline at end of file diff --git a/build.ps1 b/build.ps1 new file mode 100644 index 0000000..9ce90cf --- /dev/null +++ b/build.ps1 @@ -0,0 +1,16 @@ +# Bootstrap the environment +$null = Get-PackageProvider -Name NuGet -ForceBootstrap + +if (-not (Get-Module -Name PSDepend -ListAvailable)) { + Install-Module -Name PSDepend -Scope CurrentUser -Force -Confirm:$false +} + +Import-Module -Name PSDepend +Invoke-PSDepend ` + -Path $PSScriptRoot ` + -Force ` + -Import ` + -Install ` + -Tags 'Bootstrap' + +Invoke-Build .