Skip to content

Commit

Permalink
fix: Diverse Bugfixes & improved module.test.ps1 efficiency (#646)
Browse files Browse the repository at this point in the history
## Description

- Removed original caching solution and replaced it with a
multi-threaded solution that compiles are required files once in the
beginning
- Removed redundant test file script (formerly required to support
`parameter.json` files)
- Fixed API tests
- Fixed local test file paths

> Runtime **before** change
> 1. 14.4s
> 2. 14.9s
> 3. 15.9s
> 
> Runtime **after** change
> 1. 10.7s
> 1. 7.3s
> 1. 7.4s

| Pipeline |
| - |
|
[![avm.res.key-vault.vault](https://github.com/AlexanderSehr/bicep-registry-modules/actions/workflows/avm.res.key-vault.vault.yml/badge.svg?branch=users%2Falsehr%2FtestSpeedUp-20231117&event=workflow_dispatch)](https://github.com/AlexanderSehr/bicep-registry-modules/actions/workflows/avm.res.key-vault.vault.yml)
|

---------

Co-authored-by: Erika Gressi <[email protected]>
Co-authored-by: ChrisSidebotham-MSFT <[email protected]>
  • Loading branch information
3 people authored Nov 29, 2023
1 parent 10adf7c commit 1436704
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 196 deletions.
16 changes: 8 additions & 8 deletions .github/actions/templates/avm-getModuleTestFiles/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ runs:
# Grouping task logs
Write-Output '::group::Get parameter files'
# Load used functions
. (Join-Path $env:GITHUB_WORKSPACE 'avm' 'utilities' 'pipelines' 'sharedScripts' 'Get-ModuleTestFileList.ps1')
$functionInput = @{
ModulePath = Join-Path $env:GITHUB_WORKSPACE '${{ inputs.modulePath }}'
}
# Get the list of parameter file paths
$moduleFolderPath = Join-Path $env:GITHUB_WORKSPACE '${{ inputs.modulePath }}'
$testFilePaths = (Get-ChildItem -Path $moduleFolderPath -Recurse -Filter 'main.test.bicep').FullName | Sort-Object
Write-Verbose "Invoke task with" -Verbose
Write-Verbose ($functionInput | ConvertTo-Json | Out-String) -Verbose
$testFilePaths = $testFilePaths | ForEach-Object {
$_.Replace($moduleFolderPath, '').Trim('\').Trim('/')
}
# Get the list of parameter file paths
$testFilePaths = Get-ModuleTestFileList @functionInput -Verbose
Write-Verbose 'Found module test files' -Verbose
$testFilePaths | ForEach-Object { Write-Verbose "- [$_]" -Verbose }
# Output values to be accessed by next jobs
$compressedOutput = $testFilePaths | ConvertTo-Json -Compress
Expand Down
61 changes: 0 additions & 61 deletions avm/utilities/pipelines/sharedScripts/Get-ModuleTestFileList.ps1

This file was deleted.

3 changes: 1 addition & 2 deletions avm/utilities/pipelines/sharedScripts/Set-ModuleReadMe.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1173,7 +1173,7 @@ function Set-UsageExamplesSection {
$moduleNameCamelCase = $First.Tolower() + (Get-Culture).TextInfo.ToTitleCase($Rest) -Replace '-'
}

$testFilePaths = Get-ModuleTestFileList -ModulePath $moduleRoot | ForEach-Object { Join-Path $moduleRoot $_ }
$testFilePaths = (Get-ChildItem -Path $ModuleRoot -Recurse -Filter 'main.test.bicep').FullName | Sort-Object

$RequiredParametersList = $TemplateFileContent.parameters.Keys | Where-Object {
Get-IsParameterRequired -TemplateFileContent $TemplateFileContent -Parameter $TemplateFileContent.parameters[$_]
Expand Down Expand Up @@ -1627,7 +1627,6 @@ function Set-ModuleReadMe {

# Load external functions
. (Join-Path $PSScriptRoot 'Get-NestedResourceList.ps1')
. (Join-Path $PSScriptRoot 'Get-ModuleTestFileList.ps1')
. (Join-Path $PSScriptRoot 'helper' 'Merge-FileWithNewContent.ps1')
. (Join-Path $PSScriptRoot 'helper' 'Get-IsParameterRequired.ps1')
. (Join-Path $PSScriptRoot 'helper' 'Get-SpecsAlignedResourceName.ps1')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ $repoRootPath = (Get-Item $PSScriptRoot).Parent.Parent.Parent.Parent.Parent.Pare

. (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' 'Get-IsParameterRequired.ps1')
. (Join-Path $repoRootPath 'avm' 'utilities' 'pipelines' 'sharedScripts' 'helper' 'ConvertTo-OrderedHashtable.ps1')
Expand Down
Loading

0 comments on commit 1436704

Please sign in to comment.