Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: alz version check skip #283

Merged
merged 3 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/PullRequest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
shell: pwsh
run: Invoke-Build -File .\src\ALZ.build.ps1
- name: Upload pester results
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: pester-results
path: .\src\Artifacts\testOutput
Expand Down
51 changes: 27 additions & 24 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,18 @@ Example folder structure:
┗ 📂acc
┣ 📂bicep
┃ ┣ 📂config
┃ ┃ ┣ 📜inputs-azuredevops.yaml # ./docs/wiki/examples/powershell-inputs/inputs-azure-devops-bicep-complete.yaml
┃ ┃ ┣ 📜inputs-github.yaml # ./docs/wiki/examples/powershell-inputs/inputs-github-bicep-complete.yaml
┃ ┃ ┗ 📜inputs-local.yaml # ./docs/wiki/examples/powershell-inputs/inputs-local-bicep-complete.yaml
┃ ┃ ┣ 📜inputs-azure-devops.yaml
┃ ┃ ┣ 📜inputs-github.yaml
┃ ┃ ┗ 📜inputs-local.yaml
┃ ┗ 📂output
┃ ┣ 📂azuredevops
┃ ┣ 📂github
┃ ┗ 📂local
┗ 📂terraform
┣ 📂config
┃ ┣ 📜inputs-azuredevops.yaml # ./docs/wiki/examples/powershell-inputs/inputs-azure-devops-terraform-complete.yaml
┃ ┣ 📜inputs-github.yaml # ./docs/wiki/examples/powershell-inputs/inputs-github-terraform-complete.yaml
┃ ┗ 📜inputs-local.yaml # ./docs/wiki/examples/powershell-inputs/inputs-local-terraform-complete.yaml
┃ ┣ 📜inputs-azure-devops.yaml
┃ ┣ 📜inputs-github.yaml
┃ ┗ 📜inputs-local.yaml
┗ 📂output
┣ 📂azuredevops
┣ 📂github
Expand Down Expand Up @@ -92,21 +92,15 @@ git clone https://github.com/Azure/ALZ-PowerShell-Module
git clone https://github.com/Azure/alz-terraform-accelerator
cd /

$exampleFolder = "$targetFolder/code/ALZ-PowerShell-Module/docs/wiki/examples/powershell-inputs"
$bootstrapConfigFolderTerraform = "$targetFolder/code/alz-terraform-accelerator/templates/platform_landing_zone/examples/bootstrap"
Copy-Item -Path "$bootstrapConfigFolderTerraform/inputs-azure-devops.yaml" -Destination "$terraformConfigFolder/inputs-azure-devops.yaml" -Force
Copy-Item -Path "$bootstrapConfigFolderTerraform/inputs-github.yaml" -Destination "$terraformConfigFolder/inputs-github.yaml" -Force
Copy-Item -Path "$bootstrapConfigFolderTerraform/inputs-local.yaml" -Destination "$terraformConfigFolder/inputs-local.yaml" -Force

Copy-Item -Path "$exampleFolder/inputs-azure-devops-bicep-complete.yaml" -Destination "$bicepConfigFolder/inputs-azuredevops.yaml" -Force
Copy-Item -Path "$exampleFolder/inputs-github-bicep-complete.yaml" -Destination "$bicepConfigFolder/inputs-github.yaml" -Force
Copy-Item -Path "$exampleFolder/inputs-local-bicep-complete.yaml" -Destination "$bicepConfigFolder/inputs-local.yaml" -Force
Copy-Item -Path "$exampleFolder/inputs-azure-devops-terraform-complete-multi-region.yaml" -Destination "$terraformConfigFolder/inputs-azuredevops.yaml" -Force
Copy-Item -Path "$exampleFolder/inputs-github-terraform-complete-multi-region.yaml" -Destination "$terraformConfigFolder/inputs-github.yaml" -Force
Copy-Item -Path "$exampleFolder/inputs-local-terraform-complete-multi-region.yaml" -Destination "$terraformConfigFolder/inputs-local.yaml" -Force

$exampleFolder = "$targetFolder/code/ALZ-PowerShell-Module/docs/wiki/examples/starter-module-config/complete-multi-region"

Copy-Item -Path "$exampleFolder/config-hub-and-spoke-vnet-multi-region.yaml" -Destination "$terraformConfigFolder/config-hub-and-spoke-vnet-multi-region.yaml" -Force
Copy-Item -Path "$exampleFolder/config-hub-and-spoke-vnet-single-region.yaml" -Destination "$terraformConfigFolder/config-hub-and-spoke-vnet-single-region.yaml" -Force
Copy-Item -Path "$exampleFolder/config-virtual-wan-multi-region.yaml" -Destination "$terraformConfigFolder/config-virtual-wan-multi-region.yaml" -Force
Copy-Item -Path "$exampleFolder/config-virtual-wan-single-region.yaml" -Destination "$terraformConfigFolder/config-virtual-wan-single-region.yaml" -Force
$bootstrapConfigFolderBicep = "$targetFolder/code/ALZ-Bicep/accelerator/examples/bootstrap"
Copy-Item -Path "$bootstrapConfigFolderBicep/inputs-azure-devop.yaml" -Destination "$bicepConfigFolder/inputs-azure-devops.yaml" -Force
Copy-Item -Path "$bootstrapConfigFolderBicep/inputs-github.yaml" -Destination "$bicepConfigFolder/inputs-github.yaml" -Force
Copy-Item -Path "$bootstrapConfigFolderBicep/inputs-local.yaml" -Destination "$bicepConfigFolder/inputs-local.yaml" -Force

```

Expand All @@ -132,7 +126,8 @@ Deploy-Accelerator `
-bootstrapModuleOverrideFolderPath "/$targetFolder/code/accelerator-bootstrap-modules" `
-starterModuleOverrideFolderPath "/$targetFolder/code/ALZ-Bicep" `
-output "/$targetFolder/acc/bicep/output/azuredevops" `
-inputs "/$targetFolder/acc/bicep/config/inputs-azuredevops.yaml" `
-inputs "/$targetFolder/acc/bicep/config/inputs-azure-devops.yaml" `
-skipAlzModuleVersionRequirementsCheck `
-verbose `
-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

Expand All @@ -157,6 +152,7 @@ Deploy-Accelerator `
-starterModuleOverrideFolderPath "/$targetFolder/code/ALZ-Bicep" `
-output "/$targetFolder/acc/bicep/output/github" `
-inputs "/$targetFolder/acc/bicep/config/inputs-github.yaml" `
-skipAlzModuleVersionRequirementsCheck `
-verbose `
-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

Expand All @@ -181,6 +177,7 @@ Deploy-Accelerator `
-starterModuleOverrideFolderPath "/$targetFolder/code/ALZ-Bicep" `
-output "/$targetFolder/acc/bicep/output/local" `
-inputs "/$targetFolder/acc/bicep/config/inputs-local.yaml" `
-skipAlzModuleVersionRequirementsCheck `
-verbose `
-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

Expand All @@ -196,6 +193,7 @@ Run this from the VSCode terminal for the ALZ-PowerShell-Module repository:
Invoke-Build -File .\src\ALZ.build.ps1

$targetFolder = "dev"
$bootstrapConfigFolderTerraform = "$targetFolder/code/alz-terraform-accelerator/templates/platform_landing_zone/examples/full-multi-region"

# Uncomment to start fresh rather than relying on the -replaceFiles parameter
# Remove-Item -Path "/$targetFolder/acc/terraform/output/azuredevops" -Recurse -Force
Expand All @@ -204,7 +202,8 @@ Deploy-Accelerator `
-bootstrapModuleOverrideFolderPath "/$targetFolder/code/accelerator-bootstrap-modules" `
-starterModuleOverrideFolderPath "/$targetFolder/code/alz-terraform-accelerator/templates" `
-output "/$targetFolder/acc/terraform/output/azuredevops" `
-inputs "/$targetFolder/acc/terraform/config/inputs-azuredevops.yaml", "/$targetFolder/acc/terraform/config/config-hub-and-spoke-vnet-multi-region.yaml" `
-inputs "/$targetFolder/acc/terraform/config/inputs-azuredevops.yaml", "/$bootstrapConfigFolderTerraform/hub-and-spoke-vnet.tfvars" `
-skipAlzModuleVersionRequirementsCheck `
-verbose `
-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

Expand All @@ -222,6 +221,7 @@ Run this from the VSCode terminal for the ALZ-PowerShell-Module repository:
Invoke-Build -File .\src\ALZ.build.ps1

$targetFolder = "dev"
$bootstrapConfigFolderTerraform = "$targetFolder/code/alz-terraform-accelerator/templates/platform_landing_zone/examples/full-multi-region"

# Uncomment to start fresh rather than relying on the -replaceFiles parameter
# Remove-Item -Path "/$targetFolder/acc/terraform/output/github" -Recurse -Force
Expand All @@ -230,7 +230,8 @@ Deploy-Accelerator `
-bootstrapModuleOverrideFolderPath "/$targetFolder/code/accelerator-bootstrap-modules" `
-starterModuleOverrideFolderPath "/$targetFolder/code/alz-terraform-accelerator/templates" `
-output "/$targetFolder/acc/terraform/output/github" `
-inputs "/$targetFolder/acc/terraform/config/inputs-github.yaml", "/$targetFolder/acc/terraform/config/config-hub-and-spoke-vnet-multi-region.yaml" `
-inputs "/$targetFolder/acc/terraform/config/inputs-github.yaml", "/$bootstrapConfigFolderTerraform/hub-and-spoke-vnet.tfvars" `
-skipAlzModuleVersionRequirementsCheck `
-verbose `
-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

Expand All @@ -248,6 +249,7 @@ Run this from the VSCode terminal for the ALZ-PowerShell-Module repository:
Invoke-Build -File .\src\ALZ.build.ps1

$targetFolder = "dev"
$bootstrapConfigFolderTerraform = "$targetFolder/code/alz-terraform-accelerator/templates/platform_landing_zone/examples/full-multi-region"

# Uncomment to start fresh rather than relying on the -replaceFiles parameter
# Remove-Item -Path "/$targetFolder/acc/terraform/output/azuredevops" -Recurse -Force
Expand All @@ -256,7 +258,8 @@ Deploy-Accelerator `
-bootstrapModuleOverrideFolderPath "/$targetFolder/code/accelerator-bootstrap-modules" `
-starterModuleOverrideFolderPath "/$targetFolder/code/alz-terraform-accelerator/templates" `
-output "/$targetFolder/acc/terraform/output/local" `
-inputs "/$targetFolder/acc/terraform/config/inputs-local.yaml", "/$targetFolder/acc/terraform/config/config-hub-and-spoke-vnet-multi-region.yaml" `
-inputs "/$targetFolder/acc/terraform/config/inputs-local.yaml", "/$bootstrapConfigFolderTerraform/hub-and-spoke-vnet.tfvars" `
-skipAlzModuleVersionRequirementsCheck `
-verbose `
-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

Expand Down
46 changes: 33 additions & 13 deletions src/ALZ/Private/Tools/Test-Tooling.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
function Test-Tooling {
[CmdletBinding(SupportsShouldProcess = $true)]
param(
[Parameter(Mandatory = $false)]
[switch]$skipAlzModuleVersionCheck
)

$checkResults = @()
$hasFailure = $false

Expand Down Expand Up @@ -149,24 +155,38 @@ function Test-Tooling {
}
}

# Check if latest ALZ module is installed
Write-Verbose "Checking ALZ module version"
$alzModuleCurrentVersion = Get-InstalledModule -Name ALZ
$alzModuleLatestVersion = Find-Module -Name ALZ
if ($alzModuleCurrentVersion.Version -lt $alzModuleLatestVersion.Version) {
$checkResults += @{
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'."
result = "Failure"
}
$hasFailure = $true
if($skipAlzModuleVersionCheck.IsPresent) {
Write-Verbose "Skipping ALZ module version check"
} else {
$checkResults += @{
message = "ALZ module is the latest version ($($alzModuleCurrentVersion.Version))."
result = "Success"
# Check if latest ALZ module is installed
Write-Verbose "Checking ALZ module version"
$alzModuleCurrentVersion = Get-InstalledModule -Name ALZ -ErrorAction SilentlyContinue
if($null -eq $alzModuleCurrentVersion) {
$checkResults += @{
message = "ALZ module is not correctly installed. Please install the latest version using 'Install-Module ALZ'."
result = "Failure"
}
$hasFailure = $true
}
$alzModuleLatestVersion = Find-Module -Name ALZ
if ($null -ne $alzModuleCurrentVersion) {
if ($alzModuleCurrentVersion.Version -lt $alzModuleLatestVersion.Version) {
$checkResults += @{
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'."
result = "Failure"
}
$hasFailure = $true
} else {
$checkResults += @{
message = "ALZ module is the latest version ($($alzModuleCurrentVersion.Version))."
result = "Success"
}
}
}
}

Write-Verbose "Showing check results"
Write-Verbose $(ConvertTo-Json $checkResults -Depth 100)
$checkResults | ForEach-Object {[PSCustomObject]$_} | Format-Table -Property @{
Label = "Check Result"; Expression = {
switch ($_.result) {
Expand Down
12 changes: 9 additions & 3 deletions src/ALZ/Public/Deploy-Accelerator.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,15 @@ function Deploy-Accelerator {
Mandatory = $false,
HelpMessage = "[OPTIONAL] Determines whether to skip the requirements check. This is not recommended."
)]
[Alias("sr")]
[Alias("skipRequirementsCheck")]
[switch] $skip_requirements_check
[switch] $skip_requirements_check,

[Parameter(
Mandatory = $false,
HelpMessage = "[OPTIONAL] Determines whether to skip the requirements check for the ALZ PowerShell Module version only. This is not recommended."
)]
[Alias("skipAlzModuleVersionRequirementsCheck")]
[switch] $skip_alz_module_version_requirements_check
)

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

Write-InformationColored "Getting ready to deploy the accelerator with you..." -ForegroundColor Green -NewLineBefore -InformationAction Continue
Expand Down
11 changes: 9 additions & 2 deletions src/ALZ/Public/Test-AcceleratorRequirement.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ function Test-AcceleratorRequirement {
.COMPONENT
ALZ
#>

Test-Tooling
param (
[Parameter(
Mandatory = $false,
HelpMessage = "[OPTIONAL] Determines whether to skip the requirements check for the ALZ PowerShell Module version only. This is not recommended."
)]
[Alias("skipAlzModuleVersionRequirementsCheck")]
[switch] $skip_alz_module_version_requirements_check
)
Test-Tooling -skipAlzModuleVersionCheck:$skip_alz_module_version_requirements_check.IsPresent
}
Loading