diff --git a/.github/actions/templates/avm-validateModulePester/action.yml b/.github/actions/templates/avm-validateModulePester/action.yml index 4ec02eb3d8..83c5e7b97a 100644 --- a/.github/actions/templates/avm-validateModulePester/action.yml +++ b/.github/actions/templates/avm-validateModulePester/action.yml @@ -108,7 +108,7 @@ runs: $functionInput = @{ PesterTestResults = $testResults - OutputFilePath = Join-Path $env:GITHUB_WORKSPACE 'Pester-output.md' + OutputFilePath = Join-Path $env:GITHUB_WORKSPACE 'avm' 'Pester-output.md' GitHubRepository = $env:GITHUB_REPOSITORY BranchName = $env:GITHUB_REF } diff --git a/avm/utilities/pipelines/resourcePublish/Publish-ModuleFromTagToPBR.ps1 b/avm/utilities/pipelines/resourcePublish/Publish-ModuleFromTagToPBR.ps1 index a6f4025593..ea638cbde7 100644 --- a/avm/utilities/pipelines/resourcePublish/Publish-ModuleFromTagToPBR.ps1 +++ b/avm/utilities/pipelines/resourcePublish/Publish-ModuleFromTagToPBR.ps1 @@ -17,7 +17,7 @@ function Publish-ModuleFromTagToPBR { # TODO: Diff in between tag & tag^-1 to find modules to publish? # 1. Find tag as per function input - $repositoryRoot = (Get-Item $PSScriptRoot).Parent.Parent.Parent.Parent + $repositoryRoot = (Get-Item $PSScriptRoot).Parent.Parent.Parent.Parent.Parent $targetVersion = Split-Path $ModuleReleaseTagName -Leaf $moduleRelativeFolderPath = $ModuleReleaseTagName -replace "\/$targetVersion$", '' $moduleFolderPath = Join-Path $repositoryRoot $moduleRelativeFolderPath @@ -53,4 +53,4 @@ function Publish-ModuleFromTagToPBR { '--force' ) # bicep publish @publishInput -} \ No newline at end of file +} diff --git a/avm/utilities/pipelines/sharedScripts/Get-NestedResourceList.ps1 b/avm/utilities/pipelines/sharedScripts/Get-NestedResourceList.ps1 new file mode 100644 index 0000000000..6d4eefd0f3 --- /dev/null +++ b/avm/utilities/pipelines/sharedScripts/Get-NestedResourceList.ps1 @@ -0,0 +1,40 @@ +<# +.SYNOPSIS +Get a list of all resources (provider + service) in the given template content + +.DESCRIPTION +Get a list of all resources (provider + service) in the given template content. Crawls through any children & nested deployment templates. + +.PARAMETER TemplateFileContent +Mandatory. The template file content object to crawl data from + +.EXAMPLE +Get-NestedResourceList -TemplateFileContent @{ resource = @{}; ... } + +Returns a list of all resources in the given template object +#> +function Get-NestedResourceList { + + [CmdletBinding()] + param( + [Parameter(Mandatory)] + [Alias('Path')] + [hashtable] $TemplateFileContent + ) + + $res = @() + $currLevelResources = @() + if ($TemplateFileContent.resources) { + $currLevelResources += $TemplateFileContent.resources + } + foreach ($resource in $currLevelResources) { + $res += $resource + + if ($resource.type -eq 'Microsoft.Resources/deployments') { + $res += Get-NestedResourceList -TemplateFileContent $resource.properties.template + } else { + $res += Get-NestedResourceList -TemplateFileContent $resource + } + } + return $res +} diff --git a/avm/utilities/pipelines/sharedScripts/Get-PipelineFileName.ps1 b/avm/utilities/pipelines/sharedScripts/Get-PipelineFileName.ps1 new file mode 100644 index 0000000000..032a14d5d9 --- /dev/null +++ b/avm/utilities/pipelines/sharedScripts/Get-PipelineFileName.ps1 @@ -0,0 +1,38 @@ +<# +.SYNOPSIS +Find the correct yml pipeline naming for a given resource identifier. + +.DESCRIPTION +Find the correct yml pipeline naming for a given resource identifier. +If a child resource type is provided, the corresponding yml pipeline name is the one of its parent resource type + +.PARAMETER ResourceIdentifier +Mandatory. The resource identifier to search for, i.e. the relative module file path starting from the resource provider folder. + +.EXAMPLE +Get-PipelineFileName -ResourceIdentifier 'storage/storage-account/blob-service/container/immutability-policy'. + +Returns 'ms.storage.storageaccounts.yml'. + +.EXAMPLE +Get-PipelineFileName -ResourceIdentifier 'storage/storage-account'. + +Returns 'ms.storage.storageaccounts.yml'. +#> +function Get-PipelineFileName { + + [CmdletBinding()] + param ( + [Parameter(Mandatory = $true)] + [string] $ResourceIdentifier + ) + + . (Join-Path $PSScriptRoot 'Get-SpecsAlignedResourceName.ps1') + + $provider, $parentType, $childTypeString = $ResourceIdentifier -split '[\/|\\]', 3 + $parentResourceIdentifier = $provider, $parentType -join '/' + $formattedParentResourceType = Get-SpecsAlignedResourceName -ResourceIdentifier $parentResourceIdentifier + $pipelineFileName = '{0}.yml' -f (($formattedParentResourceType -replace 'Microsoft\.', 'ms.') -replace '\/', '.').ToLower() + + return $pipelineFileName +} diff --git a/avm/utilities/pipelines/staticValidation/Set-PesterGitHubOutput.ps1 b/avm/utilities/pipelines/staticValidation/Set-PesterGitHubOutput.ps1 index 20e3c24e7a..ac1cac877d 100644 --- a/avm/utilities/pipelines/staticValidation/Set-PesterGitHubOutput.ps1 +++ b/avm/utilities/pipelines/staticValidation/Set-PesterGitHubOutput.ps1 @@ -63,185 +63,199 @@ Generate a markdown file [C:/Pester-output.md], out of the Pester test results i #> function Set-PesterGitHubOutput { - [CmdletBinding(SupportsShouldProcess)] - param ( - [Parameter(Mandatory = $true)] - [PSCustomObject] $PesterTestResults, - - [Parameter(Mandatory = $false)] - [string] $OutputFilePath = './output.md', - - [Parameter(Mandatory = $false)] - [string] $GitHubRepository, - - [Parameter(Mandatory = $false)] - [string] $BranchName - ) - - $passedTests = $PesterTestResults.Passed - $failedTests = $PesterTestResults.Failed - $skippedTests = $PesterTestResults.Skipped - - Write-Verbose ('Formatting [{0}] passed tests' -f $passedTests.Count) - Write-Verbose ('Formatting [{0}] failed tests' -f $failedTests.Count) - Write-Verbose ('Formatting [{0}] skipped tests' -f $skippedTests.Count) - - ###################### - # Set output content # - ###################### - - # Header - $fileContent = [System.Collections.ArrayList]@( - '# Pester validation summary ', - '' - ) - - ## Header table - $fileContent += [System.Collections.ArrayList]@( - '| Total No. of Processed Tests| Passed Tests :white_check_mark: | Failed Tests :x: | Skipped Tests :paperclip: |', - '| :-- | :-- | :-- | :-- |' + [CmdletBinding(SupportsShouldProcess)] + param ( + [Parameter(Mandatory = $true)] + [PSCustomObject] $PesterTestResults, + + [Parameter(Mandatory = $false)] + [string] $OutputFilePath = './output.md', + + [Parameter(Mandatory = $false)] + [string] $GitHubRepository, + + [Parameter(Mandatory = $false)] + [string] $BranchName + ) + + $passedTests = $PesterTestResults.Passed + $failedTests = $PesterTestResults.Failed + $skippedTests = $PesterTestResults.Skipped + + Write-Verbose ('Formatting [{0}] passed tests' -f $passedTests.Count) + Write-Verbose ('Formatting [{0}] failed tests' -f $failedTests.Count) + Write-Verbose ('Formatting [{0}] skipped tests' -f $skippedTests.Count) + + ###################### + # Set output content # + ###################### + + # Header + $fileContent = [System.Collections.ArrayList]@( + '# Pester validation summary ', + '' + ) + + ## Header table + $fileContent += [System.Collections.ArrayList]@( + '| Total No. of Processed Tests| Passed Tests :white_check_mark: | Failed Tests :x: | Skipped Tests :paperclip: |', + '| :-- | :-- | :-- | :-- |' ('| {0} | {1} | {2} | {3} |' -f $PesterTestResults.TotalCount, $passedTests.count , $failedTests.count, $skippedTests.count), - '' - ) - - ###################### - ## Failed Tests ## - ###################### + '' + ) + + ###################### + ## Failed Tests ## + ###################### + Write-Verbose 'Adding failed tests' + $fileContent += [System.Collections.ArrayList]@( + '', + '
', + 'List of failed Tests', + '' + ) + + if ($failedTests.Count -gt 0) { Write-Verbose 'Adding failed tests' $fileContent += [System.Collections.ArrayList]@( - '', - '
', - 'List of failed Tests', - '' + '| Name | Error | Source |', + '| :-- | :-- | :-- |' ) - - if ($failedTests.Count -gt 0) { - Write-Verbose 'Adding failed tests' - $fileContent += [System.Collections.ArrayList]@( - '| Name | Error | Source |', - '| :-- | :-- | :-- |' - ) - foreach ($failedTest in ($failedTests | Sort-Object -Property { $PSItem.ExpandedName })) { - - $intermediateNameElements = $failedTest.Path - $intermediateNameElements[-1] = '**{0}**' -f $failedTest.ExpandedName - $testName = (($intermediateNameElements -join ' / ' | Out-String) -replace '\|', '\|').Trim() - - $errorTestLine = $failedTest.ErrorRecord.TargetObject.Line - $errorTestFile = (Split-Path $failedTest.ErrorRecord.TargetObject.File -Leaf).Trim() - $errorMessage = $failedTest.ErrorRecord.TargetObject.Message.Trim() -replace '\n', '
' # Replace new lines with
to enable line breaks in markdown - - $testReference = '{0}:{1}' -f $errorTestFile, $errorTestLine - if (-not [String]::IsNullOrEmpty($GitHubRepository) -and -not [String]::IsNullOrEmpty($BranchName)) { - # Creating URL to test file to enable users to 'click' on it - $testReference = "[$testReference](https://github.com/$GitHubRepository/blob/$BranchName/utilities/pipelines/staticValidation/module.tests.ps1#L$errorTestLine)" - } - - $fileContent += '| {0} | {1} | {2} |' -f $testName, $errorMessage, $testReference - } - } else { - $fileContent += ('No tests failed.') + foreach ($failedTest in ($failedTests | Sort-Object -Property { $PSItem.ExpandedName })) { + + $intermediateNameElements = $failedTest.Path + $intermediateNameElements[-1] = '**{0}**' -f $failedTest.ExpandedName + $testName = (($intermediateNameElements -join ' / ' | Out-String) -replace '\|', '\|').Trim() + + #TODO Remove + Write-Verbose "testName $testName" + $errorTestLine = $failedTest.ErrorRecord.TargetObject.Line + #TODO Remove + Write-Verbose "1" + $errorTestFile = (Split-Path $failedTest.ErrorRecord.TargetObject.File -Leaf).Trim() + #TODO Remove + Write-Verbose "2" + $errorMessage = $failedTest.ErrorRecord.TargetObject.Message.Trim() -replace '\n', '
' # Replace new lines with
to enable line breaks in markdown + #TODO Remove + Write-Verbose "3" + $testReference = '{0}:{1}' -f $errorTestFile, $errorTestLine + #TODO Remove + Write-Verbose "4" + if (-not [String]::IsNullOrEmpty($GitHubRepository) -and -not [String]::IsNullOrEmpty($BranchName)) { + # Creating URL to test file to enable users to 'click' on it + $testReference = "[$testReference](https://github.com/$GitHubRepository/blob/$BranchName/utilities/pipelines/staticValidation/module.tests.ps1#L$errorTestLine)" + #TODO Remove + Write-Verbose "5" + } + + $fileContent += '| {0} | {1} | {2} |' -f $testName, $errorMessage, $testReference } + } + else { + $fileContent += ('No tests failed.') + } + + $fileContent += [System.Collections.ArrayList]@( + '', + '
', + '' + ) + + ###################### + ## Passed Tests ## + ###################### + Write-Verbose 'Adding passed tests' + $fileContent += [System.Collections.ArrayList]@( + '', + '
', + 'List of passed Tests', + '' + ) + + if (($passedTests.Count -gt 0)) { $fileContent += [System.Collections.ArrayList]@( - '', - '
', - '' - ) - - ###################### - ## Passed Tests ## - ###################### - Write-Verbose 'Adding passed tests' - $fileContent += [System.Collections.ArrayList]@( - '', - '
', - 'List of passed Tests', - '' + '| Name | Source |', + '| :-- | :-- |' ) + foreach ($passedTest in ($passedTests | Sort-Object -Property { $PSItem.ExpandedName }) ) { - if (($passedTests.Count -gt 0)) { - - $fileContent += [System.Collections.ArrayList]@( - '| Name | Source |', - '| :-- | :-- |' - ) - foreach ($passedTest in ($passedTests | Sort-Object -Property { $PSItem.ExpandedName }) ) { - - $intermediateNameElements = $passedTest.Path - $intermediateNameElements[-1] = '**{0}**' -f $passedTest.ExpandedName - $testName = (($intermediateNameElements -join ' / ' | Out-String) -replace '\|', '\|').Trim() + $intermediateNameElements = $passedTest.Path + $intermediateNameElements[-1] = '**{0}**' -f $passedTest.ExpandedName + $testName = (($intermediateNameElements -join ' / ' | Out-String) -replace '\|', '\|').Trim() - $testLine = $passedTest.ScriptBlock.StartPosition.StartLine - $testFile = (Split-Path $passedTest.ScriptBlock.File -Leaf).Trim() + $testLine = $passedTest.ScriptBlock.StartPosition.StartLine + $testFile = (Split-Path $passedTest.ScriptBlock.File -Leaf).Trim() - $testReference = '{0}:{1}' -f $testFile, $testLine - if (-not [String]::IsNullOrEmpty($GitHubRepository) -and -not [String]::IsNullOrEmpty($BranchName)) { - # Creating URL to test file to enable users to 'click' on it - $testReference = "[$testReference](https://github.com/$GitHubRepository/blob/$BranchName/utilities/pipelines/staticValidation/module.tests.ps1#L$testLine)" - } + $testReference = '{0}:{1}' -f $testFile, $testLine + if (-not [String]::IsNullOrEmpty($GitHubRepository) -and -not [String]::IsNullOrEmpty($BranchName)) { + # Creating URL to test file to enable users to 'click' on it + $testReference = "[$testReference](https://github.com/$GitHubRepository/blob/$BranchName/utilities/pipelines/staticValidation/module.tests.ps1#L$testLine)" + } - $fileContent += '| {0} | {1} |' -f $testName, $testReference - } - } else { - $fileContent += ('No tests passed.') + $fileContent += '| {0} | {1} |' -f $testName, $testReference } + } + else { + $fileContent += ('No tests passed.') + } + + $fileContent += [System.Collections.ArrayList]@( + '', + '
', + '' + ) + + ####################### + ## Skipped Tests ## + ####################### + + Write-Verbose 'Adding skipped tests' + $fileContent += [System.Collections.ArrayList]@( + '', + '
', + 'List of skipped Tests', + '' + ) + + if ($skippedTests.Count -gt 0) { $fileContent += [System.Collections.ArrayList]@( - '', - '
', - '' - ) - - ####################### - ## Skipped Tests ## - ####################### - - Write-Verbose 'Adding skipped tests' - $fileContent += [System.Collections.ArrayList]@( - '', - '
', - 'List of skipped Tests', - '' + '| Name | Reason | Source |', + '| :-- | :-- | :-- |' ) + foreach ($skippedTest in ($skippedTests | Sort-Object -Property { $PSItem.ExpandedName }) ) { - if ($skippedTests.Count -gt 0) { + $intermediateNameElements = $skippedTest.Path + $intermediateNameElements[-1] = '**{0}**' -f $skippedTest.ExpandedName + $testName = (($intermediateNameElements -join ' / ' | Out-String) -replace '\|', '\|').Trim() - $fileContent += [System.Collections.ArrayList]@( - '| Name | Reason | Source |', - '| :-- | :-- | :-- |' - ) - foreach ($skippedTest in ($skippedTests | Sort-Object -Property { $PSItem.ExpandedName }) ) { + $reason = ('Test {0}' -f $skippedTest.ErrorRecord.Exception.Message -replace '\|', '\|').Trim() - $intermediateNameElements = $skippedTest.Path - $intermediateNameElements[-1] = '**{0}**' -f $skippedTest.ExpandedName - $testName = (($intermediateNameElements -join ' / ' | Out-String) -replace '\|', '\|').Trim() + $testLine = $passedTest.ScriptBlock.StartPosition.StartLine + $testFile = (Split-Path $passedTest.ScriptBlock.File -Leaf).Trim() - $reason = ('Test {0}' -f $skippedTest.ErrorRecord.Exception.Message -replace '\|', '\|').Trim() - - $testLine = $passedTest.ScriptBlock.StartPosition.StartLine - $testFile = (Split-Path $passedTest.ScriptBlock.File -Leaf).Trim() - - $testReference = '{0}:{1}' -f $testFile, $testLine - if (-not [String]::IsNullOrEmpty($GitHubRepository) -and -not [String]::IsNullOrEmpty($BranchName)) { - # Creating URL to test file to enable users to 'click' on it - $testReference = "[$testReference](https://github.com/$GitHubRepository/blob/$BranchName/utilities/pipelines/staticValidation/module.tests.ps1#L$testLine)" - } - - $fileContent += '| {0} | {1} | {2} |' -f $testName, $reason, $testReference - } - } else { - $fileContent += ('No tests were skipped.') - } - - $fileContent += [System.Collections.ArrayList]@( - '', - '
', - '' - ) + $testReference = '{0}:{1}' -f $testFile, $testLine + if (-not [String]::IsNullOrEmpty($GitHubRepository) -and -not [String]::IsNullOrEmpty($BranchName)) { + # Creating URL to test file to enable users to 'click' on it + $testReference = "[$testReference](https://github.com/$GitHubRepository/blob/$BranchName/utilities/pipelines/staticValidation/module.tests.ps1#L$testLine)" + } - if ($PSCmdlet.ShouldProcess("Test results file in path [$OutputFilePath]", 'Create')) { - $null = New-Item -Path $OutputFilePath -Force -Value ($fileContent | Out-String) + $fileContent += '| {0} | {1} | {2} |' -f $testName, $reason, $testReference } - Write-Verbose "Create results file [$outputFilePath]" + } + else { + $fileContent += ('No tests were skipped.') + } + + $fileContent += [System.Collections.ArrayList]@( + '', + '
', + '' + ) + + if ($PSCmdlet.ShouldProcess("Test results file in path [$OutputFilePath]", 'Create')) { + $null = New-Item -Path $OutputFilePath -Force -Value ($fileContent | Out-String) + } + Write-Verbose "Create results file [$outputFilePath]" } diff --git a/avm/utilities/pipelines/staticValidation/helper/helper.psm1 b/avm/utilities/pipelines/staticValidation/helper/helper.psm1 index 3c5e9a087f..3f6fdd96ce 100644 --- a/avm/utilities/pipelines/staticValidation/helper/helper.psm1 +++ b/avm/utilities/pipelines/staticValidation/helper/helper.psm1 @@ -1,14 +1,14 @@ ############################## # Load general functions # ############################## -$repoRootPath = (Get-Item $PSScriptRoot).Parent.Parent.Parent.Parent.FullName +$repoRootPath = (Get-Item $PSScriptRoot).Parent.Parent.Parent.Parent.Parent.FullName -. (Join-Path $repoRootPath 'utilities' 'pipelines' 'sharedScripts' 'Get-NestedResourceList.ps1') -. (Join-Path $repoRootPath 'utilities' 'pipelines' 'sharedScripts' 'Get-ScopeOfTemplateFile.ps1') -. (Join-Path $repoRootPath 'utilities' 'pipelines' 'sharedScripts' 'Get-ModuleTestFileList.ps1') -. (Join-Path $repoRootPath 'utilities' 'tools' 'Get-CrossReferencedModuleList.ps1') -. (Join-Path $repoRootPath 'utilities' 'tools' 'helper' 'ConvertTo-OrderedHashtable.ps1') -. (Join-Path $repoRootPath 'utilities' 'tools' 'helper' 'Get-PipelineFileName.ps1') +. (Join-Path $repoRootPath 'avm' 'utilities' 'pipelines' 'sharedScripts' 'Get-NestedResourceList.ps1') +. (Join-Path $repoRootPath 'avm' 'utilities' 'pipelines' 'sharedScripts' 'Get-ScopeOfTemplateFile.ps1') +. (Join-Path $repoRootPath 'avm' 'utilities' 'pipelines' 'sharedScripts' 'Get-ModuleTestFileList.ps1') +. (Join-Path $repoRootPath 'avm' 'utilities' 'pipelines' 'sharedScripts' 'Get-PipelineFileName.ps1') +. (Join-Path $repoRootPath 'avm' 'utilities' 'pipelines' 'sharedScripts' 'helper' 'ConvertTo-OrderedHashtable.ps1') +# . (Join-Path $repoRootPath 'utilities' 'tools' 'Get-CrossReferencedModuleList.ps1') #################################### # Load test-specific functions # @@ -34,21 +34,21 @@ Get the index of the '# Parameters' header in the given markdown array @('# Para #> function Get-MarkdownSectionStartIndex { - [CmdletBinding()] - param ( - [Parameter(Mandatory = $true)] - [array] $ReadMeContent, + [CmdletBinding()] + param ( + [Parameter(Mandatory = $true)] + [array] $ReadMeContent, - [Parameter(Mandatory = $true)] - [string] $MarkdownSectionIdentifier - ) + [Parameter(Mandatory = $true)] + [string] $MarkdownSectionIdentifier + ) - $sectionStartIndex = 0 - while ($ReadMeContent[$sectionStartIndex] -notlike $MarkdownSectionIdentifier -and -not ($sectionStartIndex -ge $ReadMeContent.count)) { - $sectionStartIndex++ - } + $sectionStartIndex = 0 + while ($ReadMeContent[$sectionStartIndex] -notlike $MarkdownSectionIdentifier -and -not ($sectionStartIndex -ge $ReadMeContent.count)) { + $sectionStartIndex++ + } - return $sectionStartIndex + return $sectionStartIndex } <# @@ -71,21 +71,21 @@ Search for the end index of the section starting in index 2 in array @('somrthin #> function Get-MarkdownSectionEndIndex { - [CmdletBinding()] - param ( - [Parameter(Mandatory = $true)] - [array] $ReadMeContent, + [CmdletBinding()] + param ( + [Parameter(Mandatory = $true)] + [array] $ReadMeContent, - [Parameter(Mandatory = $true)] - [int] $SectionStartIndex - ) + [Parameter(Mandatory = $true)] + [int] $SectionStartIndex + ) - $sectionEndIndex = $sectionStartIndex + 1 - while ($readMeContent[$sectionEndIndex] -notlike '*# *' -and -not ($sectionEndIndex -ge $ReadMeContent.count)) { - $sectionEndIndex++ - } + $sectionEndIndex = $sectionStartIndex + 1 + while ($readMeContent[$sectionEndIndex] -notlike '*# *' -and -not ($sectionEndIndex -ge $ReadMeContent.count)) { + $sectionEndIndex++ + } - return $sectionEndIndex + return $sectionEndIndex } <# @@ -108,28 +108,28 @@ Get the start & end index of the table in section '# Parameters' in the given Re #> function Get-TableStartAndEndIndex { - [CmdletBinding()] - param ( - [Parameter(Mandatory = $true)] - [array] $ReadMeContent, + [CmdletBinding()] + param ( + [Parameter(Mandatory = $true)] + [array] $ReadMeContent, - [Parameter(Mandatory = $true)] - [string] $MarkdownSectionIdentifier - ) + [Parameter(Mandatory = $true)] + [string] $MarkdownSectionIdentifier + ) - $sectionStartIndex = Get-MarkdownSectionStartIndex -ReadMeContent $ReadMeContent -MarkdownSectionIdentifier $MarkdownSectionIdentifier + $sectionStartIndex = Get-MarkdownSectionStartIndex -ReadMeContent $ReadMeContent -MarkdownSectionIdentifier $MarkdownSectionIdentifier - $tableStartIndex = $sectionStartIndex + 1 - while ($readMeContent[$tableStartIndex] -notlike '*|*' -and -not ($tableStartIndex -ge $readMeContent.count)) { - $tableStartIndex++ - } + $tableStartIndex = $sectionStartIndex + 1 + while ($readMeContent[$tableStartIndex] -notlike '*|*' -and -not ($tableStartIndex -ge $readMeContent.count)) { + $tableStartIndex++ + } - $tableEndIndex = $tableStartIndex + 2 - while ($readMeContent[$tableEndIndex] -like '|*' -and -not ($tableEndIndex -ge $readMeContent.count)) { - $tableEndIndex++ - } + $tableEndIndex = $tableStartIndex + 2 + while ($readMeContent[$tableEndIndex] -like '|*' -and -not ($tableEndIndex -ge $readMeContent.count)) { + $tableEndIndex++ + } - return $tableStartIndex, $tableEndIndex + return $tableStartIndex, $tableEndIndex } <# @@ -149,17 +149,17 @@ Returns @{ b = 'b' } #> function Remove-JSONMetadata { - [CmdletBinding()] - param ( - [Parameter(Mandatory = $true)] - [hashtable] $TemplateObject - ) - $TemplateObject.Remove('metadata') - for ($index = 0; $index -lt $TemplateObject.resources.Count; $index++) { - if ($TemplateObject.resources[$index].type -eq 'Microsoft.Resources/deployments') { - $TemplateObject.resources[$index] = Remove-JSONMetadata -TemplateObject $TemplateObject.resources[$index].properties.template - } + [CmdletBinding()] + param ( + [Parameter(Mandatory = $true)] + [hashtable] $TemplateObject + ) + $TemplateObject.Remove('metadata') + for ($index = 0; $index -lt $TemplateObject.resources.Count; $index++) { + if ($TemplateObject.resources[$index].type -eq 'Microsoft.Resources/deployments') { + $TemplateObject.resources[$index] = Remove-JSONMetadata -TemplateObject $TemplateObject.resources[$index].properties.template } + } - return $TemplateObject + return $TemplateObject } diff --git a/avm/utilities/pipelines/staticValidation/module.tests.ps1 b/avm/utilities/pipelines/staticValidation/module.tests.ps1 index 09478a4c01..074f44edac 100644 --- a/avm/utilities/pipelines/staticValidation/module.tests.ps1 +++ b/avm/utilities/pipelines/staticValidation/module.tests.ps1 @@ -7,7 +7,7 @@ param ( }), [Parameter(Mandatory = $false)] - [string] $repoRootPath = (Get-Item $PSScriptRoot).Parent.Parent.Parent.FullName, + [string] $repoRootPath = (Get-Item $PSScriptRoot).Parent.Parent.Parent.Parent.FullName, # Dedicated Tokens configuration hashtable containing the tokens and token prefix and suffix. [Parameter(Mandatory = $false)] @@ -37,7 +37,7 @@ $script:templateNotFoundException = 'No template file found in folder [{0}]' # - # Import any helper function used in this test script Import-Module (Join-Path $PSScriptRoot 'helper' 'helper.psm1') -Force -$script:crossReferencedModuleList = Get-CrossReferencedModuleList +# $script:crossReferencedModuleList = Get-CrossReferencedModuleList Describe 'File/folder tests' -Tag 'Modules' {