From de839158851389ec6f5eb66f12f523fa126cb1f5 Mon Sep 17 00:00:00 2001 From: Sebastian Graef Date: Mon, 13 Jan 2025 08:52:46 +1000 Subject: [PATCH 1/2] Add AVM-ModuleTester.ps1 snippet and update PR search query for Terraform --- PowerShell/Snippets/AVM-ModuleTester.ps1 | 61 ++++++++++++++++++++++++ graphql/gh cli graphql.ps1 | 1 + 2 files changed, 62 insertions(+) create mode 100644 PowerShell/Snippets/AVM-ModuleTester.ps1 diff --git a/PowerShell/Snippets/AVM-ModuleTester.ps1 b/PowerShell/Snippets/AVM-ModuleTester.ps1 new file mode 100644 index 0000000..deda66a --- /dev/null +++ b/PowerShell/Snippets/AVM-ModuleTester.ps1 @@ -0,0 +1,61 @@ +# Start pwsh if not started yet + +# pwsh + +# Set default directory +$folder = "Git/Azure/bicep-registry-modules" # location of your local clone of bicep-registry-modules + +# Dot source functions + +. $folder/avm/utilities/tools/Set-AVMModule.ps1 +. $folder/avm/utilities/tools/Test-ModuleLocally.ps1 + +# Variables + +$modules = @( + "dev-center/devcenter" + # "managed-services/registration-definition" + # "compute/disk-encryption-set" + # "compute/disk" +) + +# Generate Readme + +foreach ($module in $modules) { + Write-Output "Generating ReadMe for module $module" + Set-AVMModule -ModuleFolderPath "$folder/avm/res/$module" -Recurse + + # Set up test settings + + $testcases = "waf-aligned", "max", "defaults" + + $TestModuleLocallyInput = @{ + TemplateFilePath = "$folder/avm/res/$module/main.bicep" + PesterTest = $true + ValidationTest = $true + DeploymentTest = $false + ValidateOrDeployParameters = @{ + Location = 'australiaeast' + SubscriptionId = '' + RemoveDeployment = $true + } + AdditionalTokens = @{ + namePrefix = '' + TenantId = '' + } + } + + # Run tests + + foreach ($testcase in $testcases) { + Write-Output "Running test case $testcase on module $module" + $TestModuleLocallyInput.ModuleTestFilePath = "$folder/avm/res/$module/tests/e2e/$testcase/main.test.bicep" + + try { + Test-ModuleLocally @TestModuleLocallyInput + } + catch { + Write-Output $_.Exception | Format-List -Force + } + } +} diff --git a/graphql/gh cli graphql.ps1 b/graphql/gh cli graphql.ps1 index 82e4497..cd2ce84 100644 --- a/graphql/gh cli graphql.ps1 +++ b/graphql/gh cli graphql.ps1 @@ -18,6 +18,7 @@ query($filter: String!){ " --jq ".data.search.edges[].node.url"' gh search prs --review-requested=Azure/avm-core-team-technical-bicep +gh search prs --review-requested=Azure/avm-core-team-technical-terraform gh alias set issues 'api graphql --paginate -f filter="type:issue state:open $1" -f query=" query($filter: String!){ From f20099c759f1f68c32240796d3168d939d529189 Mon Sep 17 00:00:00 2001 From: Sebastian Graef Date: Mon, 13 Jan 2025 09:00:05 +1000 Subject: [PATCH 2/2] Migrate GraphQL CLI commands from graphql.ps1 to graphql.txt --- graphql/{gh cli graphql.ps1 => gh cli graphql.txt} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename graphql/{gh cli graphql.ps1 => gh cli graphql.txt} (100%) diff --git a/graphql/gh cli graphql.ps1 b/graphql/gh cli graphql.txt similarity index 100% rename from graphql/gh cli graphql.ps1 rename to graphql/gh cli graphql.txt