Skip to content

Commit fc1161d

Browse files
feat: alz version check skip (#283)
# Pull Request ## Description Add the ability to skip the alz module version check, but retain the other checks. This primarily for local development and e2e tests. ## License By submitting this pull request, I confirm that my contribution is made under the terms of the projects associated license.
1 parent b6bf165 commit fc1161d

File tree

5 files changed

+79
-43
lines changed

5 files changed

+79
-43
lines changed

.github/workflows/PullRequest.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
shell: pwsh
3333
run: Invoke-Build -File .\src\ALZ.build.ps1
3434
- name: Upload pester results
35-
uses: actions/upload-artifact@v3
35+
uses: actions/upload-artifact@v4
3636
with:
3737
name: pester-results
3838
path: .\src\Artifacts\testOutput

CONTRIBUTING.md

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,18 @@ Example folder structure:
4848
┗ 📂acc
4949
┣ 📂bicep
5050
┃ ┣ 📂config
51-
┃ ┃ ┣ 📜inputs-azuredevops.yaml # ./docs/wiki/examples/powershell-inputs/inputs-azure-devops-bicep-complete.yaml
52-
┃ ┃ ┣ 📜inputs-github.yaml # ./docs/wiki/examples/powershell-inputs/inputs-github-bicep-complete.yaml
53-
┃ ┃ ┗ 📜inputs-local.yaml # ./docs/wiki/examples/powershell-inputs/inputs-local-bicep-complete.yaml
51+
┃ ┃ ┣ 📜inputs-azure-devops.yaml
52+
┃ ┃ ┣ 📜inputs-github.yaml
53+
┃ ┃ ┗ 📜inputs-local.yaml
5454
┃ ┗ 📂output
5555
┃ ┣ 📂azuredevops
5656
┃ ┣ 📂github
5757
┃ ┗ 📂local
5858
┗ 📂terraform
5959
┣ 📂config
60-
┃ ┣ 📜inputs-azuredevops.yaml # ./docs/wiki/examples/powershell-inputs/inputs-azure-devops-terraform-complete.yaml
61-
┃ ┣ 📜inputs-github.yaml # ./docs/wiki/examples/powershell-inputs/inputs-github-terraform-complete.yaml
62-
┃ ┗ 📜inputs-local.yaml # ./docs/wiki/examples/powershell-inputs/inputs-local-terraform-complete.yaml
60+
┃ ┣ 📜inputs-azure-devops.yaml
61+
┃ ┣ 📜inputs-github.yaml
62+
┃ ┗ 📜inputs-local.yaml
6363
┗ 📂output
6464
┣ 📂azuredevops
6565
┣ 📂github
@@ -92,21 +92,15 @@ git clone https://github.com/Azure/ALZ-PowerShell-Module
9292
git clone https://github.com/Azure/alz-terraform-accelerator
9393
cd /
9494
95-
$exampleFolder = "$targetFolder/code/ALZ-PowerShell-Module/docs/wiki/examples/powershell-inputs"
95+
$bootstrapConfigFolderTerraform = "$targetFolder/code/alz-terraform-accelerator/templates/platform_landing_zone/examples/bootstrap"
96+
Copy-Item -Path "$bootstrapConfigFolderTerraform/inputs-azure-devops.yaml" -Destination "$terraformConfigFolder/inputs-azure-devops.yaml" -Force
97+
Copy-Item -Path "$bootstrapConfigFolderTerraform/inputs-github.yaml" -Destination "$terraformConfigFolder/inputs-github.yaml" -Force
98+
Copy-Item -Path "$bootstrapConfigFolderTerraform/inputs-local.yaml" -Destination "$terraformConfigFolder/inputs-local.yaml" -Force
9699
97-
Copy-Item -Path "$exampleFolder/inputs-azure-devops-bicep-complete.yaml" -Destination "$bicepConfigFolder/inputs-azuredevops.yaml" -Force
98-
Copy-Item -Path "$exampleFolder/inputs-github-bicep-complete.yaml" -Destination "$bicepConfigFolder/inputs-github.yaml" -Force
99-
Copy-Item -Path "$exampleFolder/inputs-local-bicep-complete.yaml" -Destination "$bicepConfigFolder/inputs-local.yaml" -Force
100-
Copy-Item -Path "$exampleFolder/inputs-azure-devops-terraform-complete-multi-region.yaml" -Destination "$terraformConfigFolder/inputs-azuredevops.yaml" -Force
101-
Copy-Item -Path "$exampleFolder/inputs-github-terraform-complete-multi-region.yaml" -Destination "$terraformConfigFolder/inputs-github.yaml" -Force
102-
Copy-Item -Path "$exampleFolder/inputs-local-terraform-complete-multi-region.yaml" -Destination "$terraformConfigFolder/inputs-local.yaml" -Force
103-
104-
$exampleFolder = "$targetFolder/code/ALZ-PowerShell-Module/docs/wiki/examples/starter-module-config/complete-multi-region"
105-
106-
Copy-Item -Path "$exampleFolder/config-hub-and-spoke-vnet-multi-region.yaml" -Destination "$terraformConfigFolder/config-hub-and-spoke-vnet-multi-region.yaml" -Force
107-
Copy-Item -Path "$exampleFolder/config-hub-and-spoke-vnet-single-region.yaml" -Destination "$terraformConfigFolder/config-hub-and-spoke-vnet-single-region.yaml" -Force
108-
Copy-Item -Path "$exampleFolder/config-virtual-wan-multi-region.yaml" -Destination "$terraformConfigFolder/config-virtual-wan-multi-region.yaml" -Force
109-
Copy-Item -Path "$exampleFolder/config-virtual-wan-single-region.yaml" -Destination "$terraformConfigFolder/config-virtual-wan-single-region.yaml" -Force
100+
$bootstrapConfigFolderBicep = "$targetFolder/code/ALZ-Bicep/accelerator/examples/bootstrap"
101+
Copy-Item -Path "$bootstrapConfigFolderBicep/inputs-azure-devop.yaml" -Destination "$bicepConfigFolder/inputs-azure-devops.yaml" -Force
102+
Copy-Item -Path "$bootstrapConfigFolderBicep/inputs-github.yaml" -Destination "$bicepConfigFolder/inputs-github.yaml" -Force
103+
Copy-Item -Path "$bootstrapConfigFolderBicep/inputs-local.yaml" -Destination "$bicepConfigFolder/inputs-local.yaml" -Force
110104
111105
```
112106

@@ -132,7 +126,8 @@ Deploy-Accelerator `
132126
-bootstrapModuleOverrideFolderPath "/$targetFolder/code/accelerator-bootstrap-modules" `
133127
-starterModuleOverrideFolderPath "/$targetFolder/code/ALZ-Bicep" `
134128
-output "/$targetFolder/acc/bicep/output/azuredevops" `
135-
-inputs "/$targetFolder/acc/bicep/config/inputs-azuredevops.yaml" `
129+
-inputs "/$targetFolder/acc/bicep/config/inputs-azure-devops.yaml" `
130+
-skipAlzModuleVersionRequirementsCheck `
136131
-verbose `
137132
-replaceFiles # This will replace the files in the output folder with the files in the bootstrap and starter modules, so any updates are taken into account
138133
@@ -157,6 +152,7 @@ Deploy-Accelerator `
157152
-starterModuleOverrideFolderPath "/$targetFolder/code/ALZ-Bicep" `
158153
-output "/$targetFolder/acc/bicep/output/github" `
159154
-inputs "/$targetFolder/acc/bicep/config/inputs-github.yaml" `
155+
-skipAlzModuleVersionRequirementsCheck `
160156
-verbose `
161157
-replaceFiles # This will replace the files in the output folder with the files in the bootstrap and starter modules, so any updates are taken into account
162158
@@ -181,6 +177,7 @@ Deploy-Accelerator `
181177
-starterModuleOverrideFolderPath "/$targetFolder/code/ALZ-Bicep" `
182178
-output "/$targetFolder/acc/bicep/output/local" `
183179
-inputs "/$targetFolder/acc/bicep/config/inputs-local.yaml" `
180+
-skipAlzModuleVersionRequirementsCheck `
184181
-verbose `
185182
-replaceFiles # This will replace the files in the output folder with the files in the bootstrap and starter modules, so any updates are taken into account
186183
@@ -196,6 +193,7 @@ Run this from the VSCode terminal for the ALZ-PowerShell-Module repository:
196193
Invoke-Build -File .\src\ALZ.build.ps1
197194
198195
$targetFolder = "dev"
196+
$bootstrapConfigFolderTerraform = "$targetFolder/code/alz-terraform-accelerator/templates/platform_landing_zone/examples/full-multi-region"
199197
200198
# Uncomment to start fresh rather than relying on the -replaceFiles parameter
201199
# Remove-Item -Path "/$targetFolder/acc/terraform/output/azuredevops" -Recurse -Force
@@ -204,7 +202,8 @@ Deploy-Accelerator `
204202
-bootstrapModuleOverrideFolderPath "/$targetFolder/code/accelerator-bootstrap-modules" `
205203
-starterModuleOverrideFolderPath "/$targetFolder/code/alz-terraform-accelerator/templates" `
206204
-output "/$targetFolder/acc/terraform/output/azuredevops" `
207-
-inputs "/$targetFolder/acc/terraform/config/inputs-azuredevops.yaml", "/$targetFolder/acc/terraform/config/config-hub-and-spoke-vnet-multi-region.yaml" `
205+
-inputs "/$targetFolder/acc/terraform/config/inputs-azuredevops.yaml", "/$bootstrapConfigFolderTerraform/hub-and-spoke-vnet.tfvars" `
206+
-skipAlzModuleVersionRequirementsCheck `
208207
-verbose `
209208
-replaceFiles # This will replace the files in the output folder with the files in the bootstrap and starter modules, so any updates are taken into account
210209
@@ -222,6 +221,7 @@ Run this from the VSCode terminal for the ALZ-PowerShell-Module repository:
222221
Invoke-Build -File .\src\ALZ.build.ps1
223222
224223
$targetFolder = "dev"
224+
$bootstrapConfigFolderTerraform = "$targetFolder/code/alz-terraform-accelerator/templates/platform_landing_zone/examples/full-multi-region"
225225
226226
# Uncomment to start fresh rather than relying on the -replaceFiles parameter
227227
# Remove-Item -Path "/$targetFolder/acc/terraform/output/github" -Recurse -Force
@@ -230,7 +230,8 @@ Deploy-Accelerator `
230230
-bootstrapModuleOverrideFolderPath "/$targetFolder/code/accelerator-bootstrap-modules" `
231231
-starterModuleOverrideFolderPath "/$targetFolder/code/alz-terraform-accelerator/templates" `
232232
-output "/$targetFolder/acc/terraform/output/github" `
233-
-inputs "/$targetFolder/acc/terraform/config/inputs-github.yaml", "/$targetFolder/acc/terraform/config/config-hub-and-spoke-vnet-multi-region.yaml" `
233+
-inputs "/$targetFolder/acc/terraform/config/inputs-github.yaml", "/$bootstrapConfigFolderTerraform/hub-and-spoke-vnet.tfvars" `
234+
-skipAlzModuleVersionRequirementsCheck `
234235
-verbose `
235236
-replaceFiles # This will replace the files in the output folder with the files in the bootstrap and starter modules, so any updates are taken into account
236237
@@ -248,6 +249,7 @@ Run this from the VSCode terminal for the ALZ-PowerShell-Module repository:
248249
Invoke-Build -File .\src\ALZ.build.ps1
249250
250251
$targetFolder = "dev"
252+
$bootstrapConfigFolderTerraform = "$targetFolder/code/alz-terraform-accelerator/templates/platform_landing_zone/examples/full-multi-region"
251253
252254
# Uncomment to start fresh rather than relying on the -replaceFiles parameter
253255
# Remove-Item -Path "/$targetFolder/acc/terraform/output/azuredevops" -Recurse -Force
@@ -256,7 +258,8 @@ Deploy-Accelerator `
256258
-bootstrapModuleOverrideFolderPath "/$targetFolder/code/accelerator-bootstrap-modules" `
257259
-starterModuleOverrideFolderPath "/$targetFolder/code/alz-terraform-accelerator/templates" `
258260
-output "/$targetFolder/acc/terraform/output/local" `
259-
-inputs "/$targetFolder/acc/terraform/config/inputs-local.yaml", "/$targetFolder/acc/terraform/config/config-hub-and-spoke-vnet-multi-region.yaml" `
261+
-inputs "/$targetFolder/acc/terraform/config/inputs-local.yaml", "/$bootstrapConfigFolderTerraform/hub-and-spoke-vnet.tfvars" `
262+
-skipAlzModuleVersionRequirementsCheck `
260263
-verbose `
261264
-replaceFiles # This will replace the files in the output folder with the files in the bootstrap and starter modules, so any updates are taken into account
262265

src/ALZ/Private/Tools/Test-Tooling.ps1

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
function Test-Tooling {
2+
[CmdletBinding(SupportsShouldProcess = $true)]
3+
param(
4+
[Parameter(Mandatory = $false)]
5+
[switch]$skipAlzModuleVersionCheck
6+
)
7+
28
$checkResults = @()
39
$hasFailure = $false
410

@@ -149,24 +155,38 @@ function Test-Tooling {
149155
}
150156
}
151157

152-
# Check if latest ALZ module is installed
153-
Write-Verbose "Checking ALZ module version"
154-
$alzModuleCurrentVersion = Get-InstalledModule -Name ALZ
155-
$alzModuleLatestVersion = Find-Module -Name ALZ
156-
if ($alzModuleCurrentVersion.Version -lt $alzModuleLatestVersion.Version) {
157-
$checkResults += @{
158-
message = "ALZ module is not the latest version. Your version: $($alzModuleCurrentVersion.Version), Latest version: $($alzModuleLatestVersion.Version). Please update to the latest version using 'Update-Module ALZ'."
159-
result = "Failure"
160-
}
161-
$hasFailure = $true
158+
if($skipAlzModuleVersionCheck.IsPresent) {
159+
Write-Verbose "Skipping ALZ module version check"
162160
} else {
163-
$checkResults += @{
164-
message = "ALZ module is the latest version ($($alzModuleCurrentVersion.Version))."
165-
result = "Success"
161+
# Check if latest ALZ module is installed
162+
Write-Verbose "Checking ALZ module version"
163+
$alzModuleCurrentVersion = Get-InstalledModule -Name ALZ -ErrorAction SilentlyContinue
164+
if($null -eq $alzModuleCurrentVersion) {
165+
$checkResults += @{
166+
message = "ALZ module is not correctly installed. Please install the latest version using 'Install-Module ALZ'."
167+
result = "Failure"
168+
}
169+
$hasFailure = $true
170+
}
171+
$alzModuleLatestVersion = Find-Module -Name ALZ
172+
if ($null -ne $alzModuleCurrentVersion) {
173+
if ($alzModuleCurrentVersion.Version -lt $alzModuleLatestVersion.Version) {
174+
$checkResults += @{
175+
message = "ALZ module is not the latest version. Your version: $($alzModuleCurrentVersion.Version), Latest version: $($alzModuleLatestVersion.Version). Please update to the latest version using 'Update-Module ALZ'."
176+
result = "Failure"
177+
}
178+
$hasFailure = $true
179+
} else {
180+
$checkResults += @{
181+
message = "ALZ module is the latest version ($($alzModuleCurrentVersion.Version))."
182+
result = "Success"
183+
}
184+
}
166185
}
167186
}
168187

169188
Write-Verbose "Showing check results"
189+
Write-Verbose $(ConvertTo-Json $checkResults -Depth 100)
170190
$checkResults | ForEach-Object {[PSCustomObject]$_} | Format-Table -Property @{
171191
Label = "Check Result"; Expression = {
172192
switch ($_.result) {

src/ALZ/Public/Deploy-Accelerator.ps1

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,15 @@ function Deploy-Accelerator {
175175
Mandatory = $false,
176176
HelpMessage = "[OPTIONAL] Determines whether to skip the requirements check. This is not recommended."
177177
)]
178-
[Alias("sr")]
179178
[Alias("skipRequirementsCheck")]
180-
[switch] $skip_requirements_check
179+
[switch] $skip_requirements_check,
180+
181+
[Parameter(
182+
Mandatory = $false,
183+
HelpMessage = "[OPTIONAL] Determines whether to skip the requirements check for the ALZ PowerShell Module version only. This is not recommended."
184+
)]
185+
[Alias("skipAlzModuleVersionRequirementsCheck")]
186+
[switch] $skip_alz_module_version_requirements_check
181187
)
182188

183189
$ProgressPreference = "SilentlyContinue"
@@ -186,7 +192,7 @@ function Deploy-Accelerator {
186192
Write-InformationColored "WARNING: Skipping the software requirements check..." -ForegroundColor Yellow -InformationAction Continue
187193
} else {
188194
Write-InformationColored "Checking the software requirements for the Accelerator..." -ForegroundColor Green -InformationAction Continue
189-
Test-Tooling
195+
Test-Tooling -skipAlzModuleVersionCheck:$skip_alz_module_version_requirements_check.IsPresent
190196
}
191197

192198
Write-InformationColored "Getting ready to deploy the accelerator with you..." -ForegroundColor Green -NewLineBefore -InformationAction Continue

src/ALZ/Public/Test-AcceleratorRequirement.ps1

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ function Test-AcceleratorRequirement {
1515
.COMPONENT
1616
ALZ
1717
#>
18-
19-
Test-Tooling
18+
param (
19+
[Parameter(
20+
Mandatory = $false,
21+
HelpMessage = "[OPTIONAL] Determines whether to skip the requirements check for the ALZ PowerShell Module version only. This is not recommended."
22+
)]
23+
[Alias("skipAlzModuleVersionRequirementsCheck")]
24+
[switch] $skip_alz_module_version_requirements_check
25+
)
26+
Test-Tooling -skipAlzModuleVersionCheck:$skip_alz_module_version_requirements_check.IsPresent
2027
}

0 commit comments

Comments
 (0)