-
Notifications
You must be signed in to change notification settings - Fork 978
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/Azure/Enterprise-Scale into…
… policy-refresh-q1fy25
- Loading branch information
Showing
20 changed files
with
362 additions
and
567 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
Describe 'UnitTest-BuildPolicies' { | ||
|
||
BeforeAll { | ||
Import-Module -Name $PSScriptRoot\PolicyPesterTestHelper.psm1 -Force -Verbose | ||
|
||
New-Item -Name "buildout" -Type Directory | ||
|
||
# Build the PR policies, initiatives, and role definitions to a temp folder | ||
bicep build ./src/templates/policies.bicep --outfile ./buildout/policies.json | ||
bicep build ./src/templates/initiatives.bicep --outfile ./buildout/initiatives.json | ||
bicep build ./src/templates/roles.bicep --outfile ./buildout/customRoleDefinitions.json | ||
} | ||
|
||
Context "Check Policy Builds" { | ||
|
||
It "Check policies build done" { | ||
$prFile = "./eslzArm/managementGroupTemplates/policyDefinitions/policies.json" | ||
$buildFile = "./buildout/policies.json" | ||
|
||
$buildJson = Remove-JSONMetadata -TemplateObject (Get-Content $buildFile -Raw | ConvertFrom-Json -Depth 99 -AsHashtable) | ||
$buildJson = ConvertTo-OrderedHashtable -JSONInputObject (ConvertTo-Json $buildJson -Depth 99) | ||
|
||
$prJson = Remove-JSONMetadata -TemplateObject (Get-Content $prFile -Raw | ConvertFrom-Json -Depth 99 -AsHashtable) | ||
$prJson = ConvertTo-OrderedHashtable -JSONInputObject (ConvertTo-Json $prJson -Depth 99) | ||
|
||
# Compare files we built to the PR files | ||
(ConvertTo-Json $buildJson -Depth 99) | Should -Be (ConvertTo-Json $prJson -Depth 99) -Because "the [policies.json] should be based on the latest [policies.bicep] file. Please run [` bicep build ./src/templates/policies.bicep --outfile ./eslzArm/managementGroupTemplates/policyDefinitions/policies.json `] using the latest Bicep CLI version." | ||
} | ||
|
||
It "Check initiatives build done" { | ||
$PRfile = "./eslzArm/managementGroupTemplates/policyDefinitions/initiatives.json" | ||
$buildFile = "./buildout/initiatives.json" | ||
|
||
$buildJson = Remove-JSONMetadata -TemplateObject (Get-Content $buildFile -Raw | ConvertFrom-Json -Depth 99 -AsHashtable) | ||
$buildJson = ConvertTo-OrderedHashtable -JSONInputObject (ConvertTo-Json $buildJson -Depth 99) | ||
|
||
$prJson = Remove-JSONMetadata -TemplateObject (Get-Content $prFile -Raw | ConvertFrom-Json -Depth 99 -AsHashtable) | ||
$prJson = ConvertTo-OrderedHashtable -JSONInputObject (ConvertTo-Json $prJson -Depth 99) | ||
|
||
# Compare files we built to the PR files | ||
(ConvertTo-Json $buildJson -Depth 99) | Should -Be (ConvertTo-Json $prJson -Depth 99) -Because "the [initiatives.json] should be based on the latest [initiatives.bicep] file. Please run [` bicep build ./src/templates/initiatives.bicep --outfile ./eslzArm/managementGroupTemplates/policyDefinitions/initiatives.json `] using the latest Bicep CLI version." | ||
} | ||
|
||
It "Check role definitions build done" { | ||
$PRfile = "./eslzArm/managementGroupTemplates/roleDefinitions/customRoleDefinitions.json" | ||
$buildFile = "./buildout/customRoleDefinitions.json" | ||
|
||
$buildJson = Remove-JSONMetadata -TemplateObject (Get-Content $buildFile -Raw | ConvertFrom-Json -Depth 99 -AsHashtable) | ||
$buildJson = ConvertTo-OrderedHashtable -JSONInputObject (ConvertTo-Json $buildJson -Depth 99) | ||
|
||
$prJson = Remove-JSONMetadata -TemplateObject (Get-Content $prFile -Raw | ConvertFrom-Json -Depth 99 -AsHashtable) | ||
$prJson = ConvertTo-OrderedHashtable -JSONInputObject (ConvertTo-Json $prJson -Depth 99) | ||
|
||
# Compare files we built to the PR files | ||
(ConvertTo-Json $buildJson -Depth 99) | Should -Be (ConvertTo-Json $prJson -Depth 99) -Because "the [customRoleDefinitions.json] should be based on the latest [customRoleDefinitions.bicep] file. Please run [` bicep build ./src/templates/roles.bicep --outfile ./eslzArm/managementGroupTemplates/roleDefinitions/customRoleDefinitions.json `] using the latest Bicep CLI version." | ||
} | ||
} | ||
|
||
AfterAll { | ||
# These are not the droids you are looking for... | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
--- | ||
name: Check Policy Build | ||
|
||
########################################## | ||
# Start the job on PR for all branches # | ||
########################################## | ||
|
||
# yamllint disable-line rule:truthy | ||
on: | ||
pull_request: | ||
types: | ||
- opened | ||
- reopened | ||
- synchronize | ||
- ready_for_review | ||
paths: | ||
- "eslzArm/**.json" | ||
- "src/Alz.Tools/**" | ||
- "src/**.json" | ||
- "src/**.bicep" | ||
|
||
############### | ||
# Set the Job # | ||
############### | ||
|
||
jobs: | ||
check-policy: | ||
name: Check Policy Build | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Check out repository | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Check build | ||
shell: pwsh | ||
run: | | ||
Import-Module Pester -Force | ||
$pesterConfiguration = @{ | ||
Run = @{ | ||
Container = New-PesterContainer -Path "./.github/actions-pester/Test-BuildPolicies.Tests.ps1" | ||
PassThru = $true | ||
} | ||
Output = @{ | ||
Verbosity = 'Detailed' | ||
} | ||
} | ||
$result = Invoke-Pester -Configuration $pesterConfiguration | ||
exit $result.FailedCount |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.