Skip to content

Commit

Permalink
[CI Environment] Enabled CI environment to handle DeploymentTest (bic…
Browse files Browse the repository at this point in the history
…ep) files for new self-contained dependency approach (#1624)

* added missing address space

* Fix param ref

* Further refactoring

* Update to latest

* Update to latest

* Fixed deployment ref

* Update to latest

* Updated GH piplines + minor improvements

* Fixed ref

* another try

* Another try

* Fixed GH pipeline

* Updated names

* Rename

* Stardted refactoring the readme function

* Renamed var

* Update modules/.global/global.module.tests.ps1

Co-authored-by: Marius Storhaug <Marius.Storhaug@microsoft.com>

* Update to latest

* Renamed variable

* Further updates

* [Utilities] Updated ReadMe Utility to handle bicep test files when generating deployment examples (#1628)

* Update to latest

* Fixed incorrect param file ref (#1626)

* Further updates

* Further updates

* Updated tool

* Upper case title update

* Commenting

* Formatting update

* Added order

* Added support for ARM deployment test file

* Updated handling of ARM-JSON deployment files + updated tests

* Update to latest

* Small updates

* Small updates

* Added documentation

* Added docs

* Update to latest

* Regenerated docs

* Added config exception

* Added config exception

* Mergef first couple changes from PR 1632

* Merged first batch of set-moduleReadMe script updates (not yet compatible with bicep-json)

* Latest draft including bicep to json intermediate format

* Further improvements when dealing with classic parameter files

* Updated function & tested arm converted test file

* Updated comments

* Added SQL server example & updated readme robustness

* Added SQL server example & updated readme robustness

* Updated pipeline

* Added additional error handling

* Fixed dpeloyment test

* Updated docs

* Adjusted publishing

* Adjusted var syntax

* Added initial draft for virtualHub

* Updated readme

* Minor updates

* Updated readmes

* Improved robustness

* Renamed folder

* Adjusted output

* Removed redundant dependency

* Regenerated docs

* Updated Set-ModuleReadMe with Bicep support & regenerated docs

* Updated Set-ModuleReadMe with Bicep support & regenerated docs

* Updated comments

* Updated robustness

* Updated robustness

* Updated docs

* Another update

* Changed casing

* Added error handling

* Added error handling

* Adjusted naming

* Refactored ADO dependency pipeline

* Refactored ADO dependency pipeline

* Renamed parameter

* Added var

* Test replace

* Test replace

* Test replace

* Test replace

* Test replace

* Attempt to parameterize parameter fetch for ADO

* Adjusted references

* Small fix

* Adjusted references

* Added var

* Added parameter file case handling

* Fixed condition

* Fixed ref

* Rename

* Added copied dependency pipeline template

* Simplified pipelines

* Minor refactoring

* Removed modulePath param from dependency pipeline

* Cleanup

* Cleanup

* Updated naming

* Update jobs.validateModuleDeployment.yml

* Cleanup

* Update to latest

* Restructured folders

* Updated test to new dependency folder structure

* Removed nameprefix from parameter

* Merged latest main

* Update readmes

* Update to latest

* Update to latest

* Changed namePrefix param to token

* Removed namePrefix param leftovers

* Changed comments

* Adjust case hanlding

* Adjusted name prefix handling

* Added output

* Update to latest

* Disabled pester

* Update to latest

* Refactored file handling

* Fallback

* Update to latest

* Update to latest

* Update to latest

* Update to latest

* Update to latest

* Update to latest

* Update to latest

* Removed namePrefix param

* Minor fix

* Added VM draft

* Improved case handling

* Updated readme

* Cleanup

* Update to latest

* Fixed Pester test

* Update to latest

* Update to latest

* Small fix

* Another small fix for linux

* Fixed ref

* Merged latest main

* Another small fix

* Update to latest

* Update to latest

* Update to latest

* Merged latest

* Added small upgrade to mgmtgroup removal + cleanup of  pipeline

* Update to latest

* Fixed sa name

* Renamed res

* Updated removal

* added commment

* Update to latest

* Adjusted conditions

* Update to latest

* Update to latest

* Update to latest

* Updated ReadMe

* Simplified names & updated readmes

* Renamed RG

* Fixed VM dependencies

* Naming update

* Updated VM dependencies

* Updated docs

* Added missing role assignment

* Small bracket fix

* RoleAssignment fix

* Further fixes

* Further fixes

* Further fixes

* Further fixes

* Sync

* Fixed folder ref

* Adjuted lb

* Update to latest

* Update to latest

* Update to latest

* Added missing pipeline flag

* Adjusted output

* Added docs for new dependencies approach

* Small update

* Fixed name

* Update to latest

* Reenabled param json compatibility

* Updated SQL server api

* Update to latest

* Several fixes

* Update to latest

* Update to latest

* Adjusted cond

* Fixed removal

* Added key rbac + small renames

* small renames

* Template fix

* Updated cse

* Update naming

* Removed reworked modules from PR

* Update to latest

* Update to latest

* Update to latest

* Small readmeGen fix + improved readability

* Updated AutomationAccount

* Small update

* Update to latest

* Update to latest

* Small regex update

* typoe

* Added missing quote

* Update Initialize-DeploymentRemoval.ps1

Ensured that key vault is removed before resource group to ensure purge

* Update Invoke-ResourcePostRemoval.ps1

Added KeyVault purge for purge protected key vaults

* Update .azuredevops/pipelineTemplates/jobs.validateModuleDeployment.yml

Co-authored-by: Marius Storhaug <Marius.Storhaug@microsoft.com>

* Update .azuredevops/pipelineTemplates/jobs.validateModuleDeployment.yml

Co-authored-by: Marius Storhaug <Marius.Storhaug@microsoft.com>

* Update .azuredevops/pipelineTemplates/jobs.validateModuleDeployment.yml

Co-authored-by: Marius Storhaug <Marius.Storhaug@microsoft.com>

* Update .github/actions/templates/validateModuleDeployment/action.yml

Co-authored-by: Marius Storhaug <Marius.Storhaug@microsoft.com>

* Update .github/actions/templates/validateModuleDeployment/action.yml

Co-authored-by: Marius Storhaug <Marius.Storhaug@microsoft.com>

* Update modules/.shared/dependencyConstructs/diagnostic.dependencies.bicep

Co-authored-by: Marius Storhaug <Marius.Storhaug@microsoft.com>

* Update modules/.shared/dependencyConstructs/diagnostic.dependencies.bicep

Co-authored-by: Marius Storhaug <Marius.Storhaug@microsoft.com>

* Update modules/.shared/dependencyConstructs/diagnostic.dependencies.bicep

Co-authored-by: Marius Storhaug <Marius.Storhaug@microsoft.com>

* Update modules/.shared/dependencyConstructs/diagnostic.dependencies.bicep

Co-authored-by: Marius Storhaug <Marius.Storhaug@microsoft.com>

* Update modules/.shared/dependencyConstructs/diagnostic.dependencies.bicep

Co-authored-by: Marius Storhaug <Marius.Storhaug@microsoft.com>

* Update docs/wiki/The CI environment - Static validation.md

Co-authored-by: Marius Storhaug <Marius.Storhaug@microsoft.com>

* Update docs/wiki/The library - Module design.md

Co-authored-by: Marius Storhaug <Marius.Storhaug@microsoft.com>

* Update docs/wiki/The library - Module design.md

Co-authored-by: Marius Storhaug <Marius.Storhaug@microsoft.com>

* Update to latest

* Update to latest

* Update to latest

Co-authored-by: Marius Storhaug <Marius.Storhaug@microsoft.com>
  • Loading branch information
AlexanderSehr and Marius Storhaug authored Aug 29, 2022
1 parent 0b7ee38 commit 6bb70a5
Show file tree
Hide file tree
Showing 25 changed files with 1,299 additions and 341 deletions.
17 changes: 12 additions & 5 deletions .azuredevops/pipelineTemplates/jobs.getModuleTestFiles.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,20 @@ jobs:
$deploymentTestPaths = Get-ModuleTestFileList @functionInput -Verbose
$testTable = @{}
foreach($deploymentTestPath in $deploymentTestPaths) {
$deploymentTestFileName = Split-Path $deploymentTestPath -Leaf
$testTable[$deploymentTestFileName] = @{
moduleTestFilePath = $deploymentTestPath
}
foreach ($deploymentTestPath in $deploymentTestPaths) {
if((Split-Path (Split-Path $deploymentTestPath) -Leaf) -ne '.test') {
# Using test files in subfolders (e.g. '.test/deploy.test.json')
$deploymentTestFileName = Split-Path (Split-Path $deploymentTestPath -Parent) -Leaf
} else {
# Using parameter files (e.g. '.test/parameters.json')
$deploymentTestFileName = Split-Path $deploymentTestPath -Leaf
}
$testTable[$deploymentTestFileName] += @{
moduleTestFilePath = $deploymentTestPath
}
}
$deploymentTestPathsOutput = $testTable | ConvertTo-Json -Compress
Write-Host ('##vso[task.setVariable variable=moduleTests;isOutput=true]{0}' -f ($testTable | ConvertTo-Json -Compress))
Write-Verbose "Module test files: $deploymentTestPathsOutput" -Verbose
49 changes: 32 additions & 17 deletions .azuredevops/pipelineTemplates/jobs.validateModuleDeployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ jobs:
$moduleTemplateFilePath = Join-Path '$(System.DefaultWorkingDirectory)' '${{ parameters.templateFilePath }}'
$moduleTestFilePath = Join-Path '$(System.DefaultWorkingDirectory)' '$(modulePath)' '$(moduleTestFilePath)'
# Determine possible parameters depending on file type
if ((Split-Path $moduleTemplateFilePath -Extension) -eq '.bicep') {
$moduleTemplateContent = az bicep build --file $moduleTemplateFilePath --stdout | ConvertFrom-Json -AsHashtable
$moduleTemplatePossibleParameters = $moduleTemplateContent.parameters.Keys
Expand All @@ -230,13 +231,18 @@ jobs:
# Building input object
$functionInput = @{
templateFilePath = $moduleTemplateFilePath
parameterFilePath = $moduleTestFilePath
location = $location
resourceGroupName = $resourceGroupName
subscriptionId = $subscriptionId
managementGroupId = $managementGroupId
additionalParameters = @{}
TemplateFilePath = ($moduleTestFilePath -like '*parameters.json') ? $moduleTemplateFilePath : $moduleTestFilePath
Location = $location
ResourceGroupName = $resourceGroupName
SubscriptionId = $subscriptionId
ManagementGroupId = $managementGroupId
AdditionalParameters = @{}
}
# Handle template file
if ($moduleTestFilePath -like '*parameters.json') {
# Original parameter file
$functionInput['parameterFilePath'] = $moduleTestFilePath
}
# Handle additional parameters
Expand Down Expand Up @@ -267,15 +273,16 @@ jobs:
# Load used functions
. (Join-Path '$(System.DefaultWorkingDirectory)' '$(pipelineFunctionsPath)' 'resourceDeployment' 'New-TemplateDeployment.ps1')
# Fetching parameters
$location = '${{ parameters.location }}'
$resourceGroupName = '${{ parameters.resourceGroupName }}'
$subscriptionId = '${{ parameters.subscriptionId }}'
$managementGroupId = '${{ parameters.managementGroupId }}'
$moduleTemplateFilePath = Join-Path '$(System.DefaultWorkingDirectory)' '${{ parameters.templateFilePath }}'
$moduleTestFilePath = Join-Path '$(System.DefaultWorkingDirectory)' '$(modulePath)' '$(moduleTestFilePath)'
# Determine possible parameters depending on file type
if ((Split-Path $moduleTemplateFilePath -Extension) -eq '.bicep') {
$moduleTemplateContent = az bicep build --file $moduleTemplateFilePath --stdout | ConvertFrom-Json -AsHashtable
$moduleTemplatePossibleParameters = $moduleTemplateContent.parameters.Keys
Expand All @@ -289,13 +296,19 @@ jobs:
# Building input object
$functionInput = @{
templateFilePath = $moduleTemplateFilePath
parameterFilePath = $moduleTestFilePath
location = $location
resourceGroupName = $resourceGroupName
subscriptionId = $subscriptionId
managementGroupId = $managementGroupId
additionalParameters = @{}
TemplateFilePath = ($moduleTestFilePath -like '*parameters.json') ? $moduleTemplateFilePath : $moduleTestFilePath
Location = $location
ResourceGroupName = $resourceGroupName
SubscriptionId = $subscriptionId
ManagementGroupId = $managementGroupId
doNotThrow = $true
AdditionalParameters = @{}
}
# Handle template file
if ($moduleTestFilePath -like '*parameters.json') {
# Original paramter file
$functionInput['parameterFilePath'] = $moduleTestFilePath
}
# Handle additional parameters
Expand Down Expand Up @@ -352,9 +365,11 @@ jobs:
. (Join-Path '$(System.DefaultWorkingDirectory)' '$(pipelineFunctionsPath)' 'resourceRemoval' 'Initialize-DeploymentRemoval.ps1')
$functionInput = @{
TemplateFilePath = Join-Path '$(System.DefaultWorkingDirectory)' '${{ parameters.templateFilePath }}'
TemplateFilePath = ('$(moduleTestFilePath)' -like '*parameters.json') ?
(Join-Path '$(System.DefaultWorkingDirectory)' '${{ parameters.templateFilePath }}') :
(Join-Path '$(System.DefaultWorkingDirectory)' '$(modulePath)' '$(moduleTestFilePath)')
ResourceGroupName = '${{ parameters.resourceGroupName }}'
subscriptionId = '${{ parameters.subscriptionId }}'
SubscriptionId = '${{ parameters.subscriptionId }}'
ManagementGroupId = '${{ parameters.managementGroupId }}'
deploymentName = '$(deploymentName)'
Verbose = $true
Expand Down
4 changes: 4 additions & 0 deletions .github/actions/templates/getModuleTestFiles/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,17 @@ runs:
Write-Output '::group::Get parameter files'
# Load used functions
. (Join-Path $env:GITHUB_WORKSPACE 'utilities' 'pipelines' 'sharedScripts' 'Get-ModuleTestFileList.ps1')
$functionInput = @{
ModulePath = Join-Path $env:GITHUB_WORKSPACE '${{ inputs.modulePath }}'
}
Write-Verbose "Invoke task with" -Verbose
Write-Verbose ($functionInput | ConvertTo-Json | Out-String) -Verbose
# Get the list of parameter file paths
$testFilePaths = Get-ModuleTestFileList @functionInput -Verbose
# Output values to be accessed by next jobs
$compressedOutput = $testFilePaths | ConvertTo-Json -Compress
if($compressedOutput -notmatch "\[.*\]") {
Expand Down
121 changes: 86 additions & 35 deletions .github/actions/templates/validateModuleDeployment/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -211,29 +211,57 @@ runs:
# Load used functions
. (Join-Path $env:GITHUB_WORKSPACE 'utilities' 'pipelines' 'resourceDeployment' 'Test-TemplateDeployment.ps1')
# Prepare general parameters
# --------------------------
# Fetching parameters
$location = '${{ inputs.location }}'
$resourceGroupName = '${{ inputs.resourceGroupName }}'
$subscriptionId = '${{ inputs.subscriptionId }}'
$managementGroupId = '${{ inputs.managementGroupId }}'
# Determine template & test file path
if ('${{ inputs.templateFilePath }}' -like '*.test*') {
Write-Verbose 'Using template test file [${{ inputs.templateFilePath }}]' -Verbose
$moduleTestFilePath = Join-Path $env:GITHUB_WORKSPACE '${{ inputs.templateFilePath }}'
$moduleTemplateFilePath = Resolve-Path ('{0}/deploy.*' -f ($moduleTestFilePath | Split-Path | Split-Path | Split-Path))
} else {
Write-Verbose 'Using parameter test file [${{ inputs.parameterFilePath }}]' -Verbose
$moduleTestFilePath = Join-Path $env:GITHUB_WORKSPACE '${{ inputs.parameterFilePath }}'
$moduleTemplateFilePath = Join-Path $env:GITHUB_WORKSPACE '${{ inputs.templateFilePath }}'
}
# Determine possible parameters depending on file type
if ((Split-Path $moduleTemplateFilePath -Extension) -eq '.bicep') {
$moduleTemplateContent = az bicep build --file $moduleTemplateFilePath --stdout | ConvertFrom-Json -AsHashtable
$moduleTemplatePossibleParameters = $moduleTemplateContent.parameters.Keys
} else {
$moduleTemplatePossibleParameters = ((Get-Content $moduleTemplateFilePath -Raw) | ConvertFrom-Json -AsHashtable).parameters.keys
}
# ----------------- #
# Invoke validation #
# ----------------- #
$functionInput = @{
templateFilePath = '${{ inputs.templateFilePath }}'
location = '${{ inputs.location }}'
resourceGroupName = '${{ inputs.resourceGroupName }}'
subscriptionId = '${{ inputs.subscriptionId }}'
managementGroupId = '${{ inputs.managementGroupId }}'
additionalParameters = @{}
TemplateFilePath = ($moduleTestFilePath -like '*parameters.json') ? $moduleTemplateFilePath : $moduleTestFilePath
Location = $location
ResourceGroupName = $resourceGroupName
SubscriptionId = $subscriptionId
ManagementGroupId = $managementGroupId
AdditionalParameters = @{}
}
if(-not [String]::IsNullOrEmpty('${{ inputs.parameterFilePath }}')) {
$functionInput['parameterFilePath'] = Join-Path $env:GITHUB_WORKSPACE '${{ inputs.parameterFilePath }}'
# Handle template file
if ($moduleTestFilePath -like '*parameters.json') {
$functionInput['parameterFilePath'] = $moduleTestFilePath
}
if (-not [System.Convert]::ToBoolean('${{ env.enableDefaultTelemetry }}') -and (Get-Content -Path $functionInput.templateFilePath -Raw) -like '*param enableDefaultTelemetry*') {
if (-not [System.Convert]::ToBoolean('${{ env.enableDefaultTelemetry }}') -and ($moduleTemplatePossibleParameters.Keys -contains 'enableDefaultTelemetry')) {
$functionInput['additionalParameters'] += @{
enableDefaultTelemetry = [System.Convert]::ToBoolean('${{ env.enableDefaultTelemetry }}')
}
}
Write-Verbose "Invoke task with" -Verbose
Write-Verbose 'Invoke task with' -Verbose
Write-Verbose ($functionInput | ConvertTo-Json | Out-String) -Verbose
Test-TemplateDeployment @functionInput -Verbose
Expand All @@ -254,30 +282,55 @@ runs:
# Load used functions
. (Join-Path $env:GITHUB_WORKSPACE 'utilities' 'pipelines' 'resourceDeployment' 'New-TemplateDeployment.ps1')
# Prepare general parameters
# --------------------------
$location = '${{ inputs.location }}'
$resourceGroupName = '${{ inputs.resourceGroupName }}'
$subscriptionId = '${{ inputs.subscriptionId }}'
$managementGroupId = '${{ inputs.managementGroupId }}'
# Determine template & test file path
if ('${{ inputs.templateFilePath }}' -like '*.test*') {
$moduleTestFilePath = Join-Path $env:GITHUB_WORKSPACE '${{ inputs.templateFilePath }}'
$moduleTemplateFilePath = Resolve-Path ('{0}/deploy.*' -f ($moduleTestFilePath | Split-Path | Split-Path | Split-Path))
} else {
$moduleTestFilePath = Join-Path $env:GITHUB_WORKSPACE '${{ inputs.parameterFilePath }}'
$moduleTemplateFilePath = Join-Path $env:GITHUB_WORKSPACE '${{ inputs.templateFilePath }}'
}
# Determine possible parameters depending on file type
if ((Split-Path $moduleTemplateFilePath -Extension) -eq '.bicep') {
$moduleTemplateContent = az bicep build --file $moduleTemplateFilePath --stdout | ConvertFrom-Json -AsHashtable
$moduleTemplatePossibleParameters = $moduleTemplateContent.parameters.Keys
} else {
$moduleTemplatePossibleParameters = ((Get-Content $moduleTemplateFilePath -Raw) | ConvertFrom-Json -AsHashtable).parameters.keys
}
# ----------------- #
# Invoke deployment #
# ----------------- #
$functionInput = @{
templateFilePath = Join-Path $env:GITHUB_WORKSPACE '${{ inputs.templateFilePath }}'
location = '${{ inputs.location }}'
resourceGroupName = '${{ inputs.resourceGroupName }}'
subscriptionId = '${{ inputs.subscriptionId }}'
managementGroupId = '${{ inputs.managementGroupId }}'
doNotThrow = $true
additionalParameters = @{}
TemplateFilePath = ($moduleTestFilePath -like '*parameters.json') ? $moduleTemplateFilePath : $moduleTestFilePath
Location = $location
ResourceGroupName = $resourceGroupName
SubscriptionId = $subscriptionId
ManagementGroupId = $managementGroupId
DoNotThrow = $true
AdditionalParameters = @{}
}
if(-not [String]::IsNullOrEmpty('${{ inputs.parameterFilePath }}')) {
$functionInput['parameterFilePath'] = Join-Path $env:GITHUB_WORKSPACE '${{ inputs.parameterFilePath }}'
# Handle template file
if ($moduleTestFilePath -like '*parameters.json') {
$functionInput['parameterFilePath'] = $moduleTestFilePath
}
if (-not [System.Convert]::ToBoolean('${{ env.enableDefaultTelemetry }}') -and (Get-Content -Path $functionInput.templateFilePath -Raw) -like '*param enableDefaultTelemetry*') {
if (-not [System.Convert]::ToBoolean('${{ env.enableDefaultTelemetry }}') -and ($moduleTemplatePossibleParameters.Keys -contains 'enableDefaultTelemetry')) {
$functionInput['additionalParameters'] += @{
enableDefaultTelemetry = [System.Convert]::ToBoolean('${{ env.enableDefaultTelemetry }}')
}
}
Write-Verbose "Invoke task with" -Verbose
Write-Verbose 'Invoke task with' -Verbose
Write-Verbose ($functionInput | ConvertTo-Json | Out-String) -Verbose
# Invoke deployment
Expand All @@ -287,11 +340,11 @@ runs:
Write-Output ('::set-output name={0}::{1}' -f 'deploymentName', $res.deploymentName)
# Populate further outputs
$deploymentOutputHash=@{}
$deploymentOutputHash = @{}
foreach ($outputKey in $res.deploymentOutput.Keys) {
Write-Output ('::set-output name={0}::{1}' -f $outputKey, $res.deploymentOutput[$outputKey].Value)
$deploymentOutputHash.add($outputKey,$res.deploymentOutput[$outputKey].Value)
$deploymentOutputHash.add($outputKey, $res.deploymentOutput[$outputKey].Value)
}
$deploymentOutput = $deploymentOutputHash | ConvertTo-Json -Compress -Depth 100
Expand Down Expand Up @@ -319,19 +372,17 @@ runs:
# Load used function
. (Join-Path $env:GITHUB_WORKSPACE 'utilities' 'pipelines' 'resourceRemoval' 'Initialize-DeploymentRemoval.ps1')
if (-not [String]::IsNullOrEmpty('${{ steps.deploy_step.outputs.deploymentName }}')) {
$functionInput = @{
DeploymentName = '${{ steps.deploy_step.outputs.deploymentName }}'
TemplateFilePath = Join-Path $env:GITHUB_WORKSPACE '${{ inputs.templateFilePath }}'
ResourceGroupName = '${{ inputs.resourceGroupName }}'
ManagementGroupId = '${{ inputs.managementGroupId }}'
Verbose = $true
}
$functionInput = @{
TemplateFilePath = Join-Path $env:GITHUB_WORKSPACE '${{ inputs.templateFilePath }}'
DeploymentName = '${{ steps.deploy_step.outputs.deploymentName }}'
ResourceGroupName = '${{ inputs.resourceGroupName }}'
ManagementGroupId = '${{ inputs.managementGroupId }}'
Verbose = $true
}
Write-Verbose 'Invoke task with' -Verbose
Write-Verbose ($functionInput | ConvertTo-Json | Out-String) -Verbose
Write-Verbose 'Invoke task with' -Verbose
Write-Verbose ($functionInput | ConvertTo-Json | Out-String) -Verbose
Initialize-DeploymentRemoval @functionInput
}
Initialize-DeploymentRemoval @functionInput
Write-Output '::endgroup::'
8 changes: 4 additions & 4 deletions docs/wiki/Contribution guide - Validate module locally.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Use this script to test a module from your PC locally, without a CI environment. You can use it to run only the static validation (Pester tests), a deployment validation (dryRun) or an actual deployment to Azure. In the latter cases the script also takes care to replace placeholder tokens in the used parameter file for you.
Use this script to test a module from your PC locally, without a CI environment. You can use it to run only the static validation (Pester tests), a deployment validation (dryRun) or an actual deployment to Azure. In the latter cases the script also takes care to replace placeholder tokens in the used module test & template files for you.

---

Expand All @@ -19,14 +19,14 @@ If the switch for Pester tests (`-PesterTest`) is provided the script will
1. Invoke the module test for the provided template file path and run all tests for it.

If the switch for either the validation test (`-ValidationTest`) or deployment test (`-DeploymentTest`) is provided alongside a HashTable for the token replacement (`-ValidateOrDeployParameters`), the script will
1. Either fetch all parameter files of the module's parameter folder (default) or you can specify a single parameter file by leveraging the `parameterFilePath` parameter instead.
1. Create a dictionary to replace all tokens in these parameter files with actual values. This dictionary will consist
1. Either fetch all module test files of the module's `.test` folder (default) or you can specify a single module test file by leveraging the `ModuleTestFilePath` parameter instead.
1. Create a dictionary to replace all tokens in these module test files with actual values. This dictionary will consist
- of the subscriptionID & managementGroupID of the provided `ValidateOrDeployParameters` object,
- add all key-value pairs of the `-AdditionalTokens` object to it,
- and optionally also add all key-value pairs specified in the `settings.yml`, under the 'local tokens settings'.
1. If the `-ValidationTest` parameter was set, it runs a deployment validation using the `Test-TemplateDeployment` script.
1. If the `-DeploymentTest` parameter was set, it runs a deployment using the `New-TemplateDeployment` script (with no retries).
1. As a final step, it rolls the parameter files back to their original state if either the `-ValidationTest` or `-DeploymentTest` parameters were provided.
1. As a final step, it rolls the module test files back to their original state if either the `-ValidationTest` or `-DeploymentTest` parameters were provided.

# How to use it

Expand Down
Loading

0 comments on commit 6bb70a5

Please sign in to comment.