Merge pull request #20 from wcarroll/azure-pipelines

Set up CI with Azure Pipelines [skip ci]
This commit is contained in:
Wes Carroll
2019-03-28 10:37:29 -04:00
committed by GitHub
11 changed files with 326 additions and 132 deletions
+29 -13
View File
@@ -1,23 +1,39 @@
$moduleName = "ZertoApiWrapper"
$moduleFileName = "ZertoApiWrapper.psm1"
$filePath = (Split-Path -Parent $MyInvocation.MyCommand.Path) -replace 'Tests', 'ZertoApiWrapper'
$fileName = (Split-Path -Leaf $MyInvocation.MyCommand.Path ) -replace '.Tests.', '.'
$docsPath = (Split-Path -Parent $MyInvocation.MyCommand.Path) -replace 'Tests[\\\/]Public', 'docs'
$modulePath = $filePath -replace "Public", ""
Import-Module $modulePath\$moduleFileName -Force
$userName = "zerto\build"
$password = ConvertTo-SecureString -String "ZertoBuild" -AsPlainText -Force
$credential = New-Object -TypeName System.Management.Automation.PSCredential($userName, $password)
# $credential = Import-Clixml -Path C:\ZertoScripts\Creds.xml
$zertoServer = "192.168.1.100"
$zertoPort = "7669"
Import-Module $modulePath\$moduleFileName
Describe "File Tests" {
$commands = Get-Command -Module ZertoApiWrapper | Select-Object -ExpandProperty Name
Remove-Module $moduleName -Force
Import-Module $modulePath\$moduleFileName
$commands = Get-Command -Module $moduleName | Select-Object -ExpandProperty Name
foreach ($command in $commands) {
$externalHelpFile = "{0}/{1}.md" -f $docsPath, $command
$path = "{0}/{1}.ps1" -f $filePath, $command
it "$command is backed by a file with the same name" {
$path | should exist
context "$command File Tests" {
it "$command is backed by a file with the same name" {
$path | should exist
}
it "$command file has openbraces on the same line as the statement" {
$content = Get-Content -Path $path
$openingBracesExist = $content | Where-Object {$_.Trim() -eq '{'}
if ($openingBracesExist) {
Write-Warning "Found the following opening brances on their own line:"
foreach ($openingBrace in $openingBracesExist) {
Write-Warning "Opening Brace on it's own line - $openingBrace"
}
}
$openingBracesExist | should benullorempty
}
it "$command has an external help file" {
$externalHelpFile | should exist
}
it "$command has the External Help File Defined" {
Get-Content -Path $path -First 1 | should be "<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>"
}
}
}
}
}
+50
View File
@@ -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 = 'Bootstrap'
}
PSScriptAnalyzer = @{
Name = 'PSScriptAnalyzer'
DependencyType = 'PSGalleryModule'
Parameters = @{
Repository = 'PSGallery'
SkipPublisherCheck = $true
}
Target = 'CurrentUser'
Version = '1.17.1'
Tags = 'Bootstrap'
}
Platyps = @{
Name = 'Platyps'
DependencyType = 'PSGalleryModule'
Parameters = @{
Repository = 'PSGallery'
SkipPublisherCheck = $true
}
Target = 'CurrentUser'
Version = '0.12.0'
Tags = 'Bootstrap'
}
}
+55 -6
View File
@@ -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', 'PSUseToExportFieldsInManifest')
}
$saresults = Invoke-ScriptAnalyzer @scriptAnalyzerParams
@@ -21,3 +48,25 @@ task Analyze {
}
}
task FileTests CheckPesterInstalled, {
$testResultsFile = "$BuildRoot\Tests\Public\TestResults.xml"
Invoke-Pester -Script "$BuildRoot\Tests\Public\ZertoApiWrapper.Tests.ps1" -OutputFile $testResultsFile -PassThru
}
$buildMamlParams = @{
Inputs = { Get-ChildItem docs\*.md }
Outputs = ".\ZertoApiWrapper\Public\en-us\ZertoApiWrapper-help.xml"
}
task BuildMamlHelp CheckPlatyPSInstalled, {
if (Test-Path $buildMamlParams.Outputs) {
Remove-Item $buildMamlParams.Outputs
}
platyPS\New-ExternalHelp .\docs -Force -OutputPath $buildMamlParams.Outputs
}
task UpdateMarkdownHelp CheckPlatyPSInstalled, {
remove-module ZertoApiWrapper -force -ErrorAction SilentlyContinue
Import-Module .\ZertoApiWrapper\ZertoApiWrapper.psm1 -Force
Update-MarkDownHelp -Path docs -AlphabeticParamsOrder
}
+1 -1
View File
@@ -24,7 +24,7 @@ function Import-ZertoVpg {
$importedSettings.VpgSettingsIdentifier = $vpgSettingsIdentifier
$uri = "{0}/{1}" -f $baseUri, $vpgSettingsIdentifier
Invoke-ZertoRestRequest -uri $uri -method "PUT" -body $($importedSettings | convertto-json -Depth 10)
$vpgSettingsIdentifier | Save-ZertoVpgSettings
$vpgSettingsIdentifier | Save-ZertoVpgSetting
if ($settingsFile.Count -gt 1) {
Start-Sleep 5
}
@@ -1,5 +1,5 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Save-ZertoVpgSettings {
function Save-ZertoVpgSetting {
[cmdletbinding(
SupportsShouldProcess = $true
)]
@@ -5977,35 +5977,35 @@
<command:examples>
<command:example>
<maml:title>-------------------------- Example 1 --------------------------</maml:title>
<dev:code>PS C:\&gt; Get-ZertoVpgSettings -vpgSettingsIdentifier "MySettingsIdentifier"</dev:code>
<dev:code>PS C:\&gt; Get-ZertoVpgSetting -vpgSettingsIdentifier "MySettingsIdentifier"</dev:code>
<dev:remarks>
<maml:para>Returns all current settings for vpgSettingsIdentifier "MySettingsIdentifier"</maml:para>
</dev:remarks>
</command:example>
<command:example>
<maml:title>-------------------------- Example 2 --------------------------</maml:title>
<dev:code>PS C:\&gt; Get-ZertoVpgSettings -vpgSettingsIdentifier "MySettingsIdentifier" -vmIdentifier "MyVmId"</dev:code>
<dev:code>PS C:\&gt; Get-ZertoVpgSetting -vpgSettingsIdentifier "MySettingsIdentifier" -vmIdentifier "MyVmId"</dev:code>
<dev:remarks>
<maml:para>Returns all current vm level settings for the vmIdentifier "MyVmId" in vpgSettingsIdentifier "MySettingsIdentifier"</maml:para>
</dev:remarks>
</command:example>
<command:example>
<maml:title>-------------------------- Example 3 --------------------------</maml:title>
<dev:code>PS C:\&gt; Get-ZertoVpgSettings -vpgSettingsIdentifier "MySettingsIdentifier" -vmIdentifier "MyVmId" -volumes</dev:code>
<dev:code>PS C:\&gt; Get-ZertoVpgSetting -vpgSettingsIdentifier "MySettingsIdentifier" -vmIdentifier "MyVmId" -volumes</dev:code>
<dev:remarks>
<maml:para>Returns current vm level settings for volumes for vmId "MyVmId" in vpgSettingsIdentifier "MySettingsIdentifier"</maml:para>
</dev:remarks>
</command:example>
<command:example>
<maml:title>-------------------------- Example 4 --------------------------</maml:title>
<dev:code>PS C:\&gt; Get-ZertoVpgSettings -vpgSettingsIdentifier "MySettingsIdentifier" -nics</dev:code>
<dev:code>PS C:\&gt; Get-ZertoVpgSetting -vpgSettingsIdentifier "MySettingsIdentifier" -nics</dev:code>
<dev:remarks>
<maml:para>Returns current vm level settings for nics for vmId "MyVmId" in vpgSettingsIdentifier "MySettingsIdentifier"</maml:para>
</dev:remarks>
</command:example>
<command:example>
<maml:title>-------------------------- Example 5 --------------------------</maml:title>
<dev:code>PS C:\&gt; Get-ZertoVpgSettings -vpgSettingsIdentifier "MySettingsIdentifier" -basic</dev:code>
<dev:code>PS C:\&gt; Get-ZertoVpgSetting -vpgSettingsIdentifier "MySettingsIdentifier" -basic</dev:code>
<dev:remarks>
<maml:para>Returns current basic settings for vpgSettingsIdentifier "MySettingsIdentifier"</maml:para>
</dev:remarks>
@@ -10656,9 +10656,9 @@
</command:command>
<command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp">
<command:details>
<command:name>Save-ZertoVpgSettings</command:name>
<command:name>Save-ZertoVpgSetting</command:name>
<command:verb>Save</command:verb>
<command:noun>ZertoVpgSettings</command:noun>
<command:noun>ZertoVpgSetting</command:noun>
<maml:description>
<maml:para>Commits the updated Vpg Settings with the configured Vpg Settings Identifier</maml:para>
</maml:description>
@@ -10668,8 +10668,8 @@
</maml:description>
<command:syntax>
<command:syntaxItem>
<maml:name>Save-ZertoVpgSettings</maml:name>
<command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName, ByValue)" position="0" aliases="vpgSettingsId">
<maml:name>Save-ZertoVpgSetting</maml:name>
<command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName, ByValue)" position="1" aliases="vpgSettingsId">
<maml:name>vpgSettingsIdentifier</maml:name>
<maml:Description>
<maml:para>VpgSettings Identifier to save</maml:para>
@@ -10706,7 +10706,7 @@
</command:syntaxItem>
</command:syntax>
<command:parameters>
<command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName, ByValue)" position="0" aliases="vpgSettingsId">
<command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName, ByValue)" position="1" aliases="vpgSettingsId">
<maml:name>vpgSettingsIdentifier</maml:name>
<maml:Description>
<maml:para>VpgSettings Identifier to save</maml:para>
@@ -10771,7 +10771,7 @@
<command:examples>
<command:example>
<maml:title>-------------------------- Example 1 --------------------------</maml:title>
<dev:code>PS C:&gt; Save-ZertoVpgSettings -vpgSettingsIdentifier "MyVpgSettingsIdentifier"</dev:code>
<dev:code>PS C:&gt; Save-ZertoVpgSetting -vpgSettingsIdentifier "MyVpgSettingsIdentifier"</dev:code>
<dev:remarks>
<maml:para>Commits vpg settings with vpg settings identifier "MyVpgSettingsIdentifier"</maml:para>
</dev:remarks>
@@ -10780,7 +10780,7 @@
<command:relatedLinks>
<maml:navigationLink>
<maml:linkText>Online Version:</maml:linkText>
<maml:uri>https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Save-ZertoVpgSettings.md</maml:uri>
<maml:uri>https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Save-ZertoVpgSetting.md</maml:uri>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Zerto REST API VPG Settings End Point Documentation</maml:linkText>
+64
View File
@@ -0,0 +1,64 @@
# Starter pipeline
# Start with a minimal pipeline that you can customize to build and deploy your code.
# Add steps that build, run tests, deploy, and more:
# https://aka.ms/yaml
jobs:
- job: Build_PS_Win2016
pool:
vmImage: vs2017-win2016
steps:
- powershell: |
.\build.ps1 -Verbose
displayName: 'Build and Test'
- task: PublishTestResults@2
inputs:
testRunner: 'NUnit'
testResultsFiles: '**/Public/TestResults.xml'
testRunTitle: 'PS_Win2016'
displayName: 'Publish Test Results'
- job: Build_PSCore_Ubuntu1604
pool:
vmImage: ubuntu-16.04
steps:
- script: |
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list | sudo tee /etc/apt/sources.list.d/microsoft.list
sudo apt-get update
sudo apt-get install -y powershell
displayName: 'Install PowerShell Core'
- script: |
pwsh -c '.\build.ps1'
displayName: 'Build and Test'
- task: PublishTestResults@2
inputs:
testRunner: 'NUnit'
testResultsFiles: '**/Public/TestResults.xml'
testRunTitle: 'PSCore_Ubuntu1604'
displayName: 'Publish Test Results'
- job: Build_PSCore_MacOS1013
pool:
vmImage: xcode9-macos10.13
steps:
- script: |
brew update
brew tap caskroom/cask
brew cask install powershell
displayName: 'Install PowerShell Core'
- script: |
pwsh -c '.\build.ps1'
displayName: 'Build and Test'
- task: PublishTestResults@2
inputs:
testRunner: 'NUnit'
testResultsFiles: '**/Public/TestResults.xml'
testRunTitle: 'PSCore_MacOS1013'
displayName: 'Publish Test Results'
+16
View File
@@ -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 .
+5 -5
View File
@@ -118,35 +118,35 @@ It is important to note that only once a VPG settings object has been created, w
### Example 1
```powershell
PS C:\> Get-ZertoVpgSettings -vpgSettingsIdentifier "MySettingsIdentifier"
PS C:\> Get-ZertoVpgSetting -vpgSettingsIdentifier "MySettingsIdentifier"
```
Returns all current settings for vpgSettingsIdentifier "MySettingsIdentifier"
### Example 2
```powershell
PS C:\> Get-ZertoVpgSettings -vpgSettingsIdentifier "MySettingsIdentifier" -vmIdentifier "MyVmId"
PS C:\> Get-ZertoVpgSetting -vpgSettingsIdentifier "MySettingsIdentifier" -vmIdentifier "MyVmId"
```
Returns all current vm level settings for the vmIdentifier "MyVmId" in vpgSettingsIdentifier "MySettingsIdentifier"
### Example 3
```powershell
PS C:\> Get-ZertoVpgSettings -vpgSettingsIdentifier "MySettingsIdentifier" -vmIdentifier "MyVmId" -volumes
PS C:\> Get-ZertoVpgSetting -vpgSettingsIdentifier "MySettingsIdentifier" -vmIdentifier "MyVmId" -volumes
```
Returns current vm level settings for volumes for vmId "MyVmId" in vpgSettingsIdentifier "MySettingsIdentifier"
### Example 4
```powershell
PS C:\> Get-ZertoVpgSettings -vpgSettingsIdentifier "MySettingsIdentifier" -nics
PS C:\> Get-ZertoVpgSetting -vpgSettingsIdentifier "MySettingsIdentifier" -nics
```
Returns current vm level settings for nics for vmId "MyVmId" in vpgSettingsIdentifier "MySettingsIdentifier"
### Example 5
```powershell
PS C:\> Get-ZertoVpgSettings -vpgSettingsIdentifier "MySettingsIdentifier" -basic
PS C:\> Get-ZertoVpgSetting -vpgSettingsIdentifier "MySettingsIdentifier" -basic
```
Returns current basic settings for vpgSettingsIdentifier "MySettingsIdentifier"
+1 -2
View File
@@ -150,8 +150,7 @@ Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.
For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
@@ -1,92 +1,92 @@
---
external help file: ZertoApiWrapper-help.xml
Module Name: ZertoApiWrapper
online version: https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Save-ZertoVpgSettings.md
schema: 2.0.0
---
# Save-ZertoVpgSettings
## SYNOPSIS
Commits the updated Vpg Settings with the configured Vpg Settings Identifier
## SYNTAX
```
Save-ZertoVpgSettings [-vpgSettingsIdentifier] <String> [-WhatIf] [-Confirm] [<CommonParameters>]
```
## DESCRIPTION
Commits the updated Vpg Settings with the configured Vpg Settings Identifier
## EXAMPLES
### Example 1
```powershell
PS C:> Save-ZertoVpgSettings -vpgSettingsIdentifier "MyVpgSettingsIdentifier"
```
Commits vpg settings with vpg settings identifier "MyVpgSettingsIdentifier"
## PARAMETERS
### -vpgSettingsIdentifier
VpgSettings Identifier to save
```yaml
Type: String
Parameter Sets: (All)
Aliases: vpgSettingsId
Required: True
Position: 0
Default value: None
Accept pipeline input: True (ByPropertyName, ByValue)
Accept wildcard characters: False
```
### -Confirm
Prompts you for confirmation before running the cmdlet.
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases: cf
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -WhatIf
Shows what would happen if the cmdlet runs.
The cmdlet is not run.
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases: wi
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
### System.String
## OUTPUTS
### System.Object
## NOTES
## RELATED LINKS
[Zerto REST API VPG Settings End Point Documentation](http://s3.amazonaws.com/zertodownload_docs/Latest/Zerto%20Virtual%20Replication%20Zerto%20Virtual%20Manager%20%28ZVM%29%20-%20vSphere%20Online%20Help/RestfulAPIs/StatusAPIs.5.108.html#)
---
external help file: ZertoApiWrapper-help.xml
Module Name: ZertoApiWrapper
online version: https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Save-ZertoVpgSetting.md
schema: 2.0.0
---
# Save-ZertoVpgSetting
## SYNOPSIS
Commits the updated Vpg Settings with the configured Vpg Settings Identifier
## SYNTAX
```
Save-ZertoVpgSetting [-vpgSettingsIdentifier] <String> [-WhatIf] [-Confirm] [<CommonParameters>]
```
## DESCRIPTION
Commits the updated Vpg Settings with the configured Vpg Settings Identifier
## EXAMPLES
### Example 1
```powershell
PS C:> Save-ZertoVpgSetting -vpgSettingsIdentifier "MyVpgSettingsIdentifier"
```
Commits vpg settings with vpg settings identifier "MyVpgSettingsIdentifier"
## PARAMETERS
### -vpgSettingsIdentifier
VpgSettings Identifier to save
```yaml
Type: String
Parameter Sets: (All)
Aliases: vpgSettingsId
Required: True
Position: 1
Default value: None
Accept pipeline input: True (ByPropertyName, ByValue)
Accept wildcard characters: False
```
### -Confirm
Prompts you for confirmation before running the cmdlet.
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases: cf
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -WhatIf
Shows what would happen if the cmdlet runs.
The cmdlet is not run.
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases: wi
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
### System.String
## OUTPUTS
### System.Object
## NOTES
## RELATED LINKS
[Zerto REST API VPG Settings End Point Documentation](http://s3.amazonaws.com/zertodownload_docs/Latest/Zerto%20Virtual%20Replication%20Zerto%20Virtual%20Manager%20%28ZVM%29%20-%20vSphere%20Online%20Help/RestfulAPIs/StatusAPIs.5.108.html#)